- added info about sleep,sleep2,awake commands and updated the variables section (hopefully all info is correct)
git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@9603 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
b6aac83a77
commit
2bd2fbacbe
@ -9,7 +9,7 @@
|
|||||||
//= Maeki Rika - A section on general concepts and lots of
|
//= Maeki Rika - A section on general concepts and lots of
|
||||||
//= other updates and additions.
|
//= other updates and additions.
|
||||||
//===== Version ===========================================
|
//===== Version ===========================================
|
||||||
//= 2.9
|
//= 2.10.20070101
|
||||||
//=========================================================
|
//=========================================================
|
||||||
//= 1.0 - First release, filled will as much info as I could
|
//= 1.0 - First release, filled will as much info as I could
|
||||||
//= remember or figure out, most likely there are errors,
|
//= remember or figure out, most likely there are errors,
|
||||||
@ -33,11 +33,13 @@
|
|||||||
//= 2.7a - delitem2, countitems2 commands [Lupus]
|
//= 2.7a - delitem2, countitems2 commands [Lupus]
|
||||||
//= 2.7b - clone command [Skotlex]
|
//= 2.7b - clone command [Skotlex]
|
||||||
//= 2.7c - disguise / undisguise, query_sql commands [Lupus]
|
//= 2.7c - disguise / undisguise, query_sql commands [Lupus]
|
||||||
|
//= 2.8 - Deleted a copy of the nude command. Added axtoi command (needing a
|
||||||
//= 2.8 - Deleted a copy of the nude command. Added axtoi command (needing a clearer
|
//= clearer explanation of atoi.Gave a better explanation of OnLabels
|
||||||
//= explanation of atoi.Gave a better explanation of OnLabels and modified
|
//= and modified monster explanation due that L_Label isn't working with
|
||||||
//= monster explanation due that L_Label isn't working with monster.
|
//= monster.
|
||||||
//= 2.9.20061230 - Updated getitem and guardian [FlavioJS]
|
//= 2.9.20061230 - Updated getitem and guardian. [FlavioJS]
|
||||||
|
//= 2.10.20070101 - added sleep,sleep2,awake and updated the variables section.
|
||||||
|
//= [FlavioJS]
|
||||||
//===== Compatible With ===================================
|
//===== Compatible With ===================================
|
||||||
//= LOL, can be used by anyone hopefully
|
//= LOL, can be used by anyone hopefully
|
||||||
//===== Description =======================================
|
//===== Description =======================================
|
||||||
@ -60,6 +62,9 @@ switch to Lua scripting language, which will rid us of most of the problems
|
|||||||
mentioned herein and make a new manual necessary. But while we have this one, we
|
mentioned herein and make a new manual necessary. But while we have this one, we
|
||||||
should make the most of it, and it might be helpful in making sure the new Lua
|
should make the most of it, and it might be helpful in making sure the new Lua
|
||||||
engine can actually do everything useful that the old engine could.
|
engine can actually do everything useful that the old engine could.
|
||||||
|
Note: The change to lua isn't going to happen because we are switching to eApp.
|
||||||
|
eApp has it's own scripting language and a converter to convert scripts
|
||||||
|
from the current script language.
|
||||||
|
|
||||||
This is not a place to teach you basic programming. This document will not teach
|
This is not a place to teach you basic programming. This document will not teach
|
||||||
you basic programming by itself. It's more of a reference for those who have at
|
you basic programming by itself. It's more of a reference for those who have at
|
||||||
@ -422,52 +427,89 @@ to 'mes 0x10' it will print '16'.
|
|||||||
|
|
||||||
This is not used much, but it pays to know about it.
|
This is not used much, but it pays to know about it.
|
||||||
|
|
||||||
Variables and scope
|
Variables
|
||||||
-------------------
|
---------
|
||||||
|
|
||||||
The meat of every programming language is variables - places where you store
|
The meat of every programming language is variables - places where you store
|
||||||
data.
|
data.
|
||||||
|
|
||||||
Variables are divided into global (not attached to any specific RID, and
|
Variables are divided into and uniquely identified by the combination of:
|
||||||
independent of whoever triggered the object) and local (attached to a specific
|
prefix - determines the scope and extent (or lifetime) of the variable
|
||||||
character object or a specific account object). They are further divided into
|
name - an identifier consisting of '_' and alfanumeric characters
|
||||||
permanent (they come back when the server resets) and temporary (they only
|
postfix - determines the type of the variable: integer or string
|
||||||
persist until the server dies). This is what's called variable scope. :)
|
|
||||||
|
|
||||||
Unlike in more advanced languages, all temporary variables are essentially
|
Scope can be:
|
||||||
'global', but not in the sense described above - if one NPC sets a temporary
|
global - global to all servers
|
||||||
variable, even if it is character based, if that character triggers another NPC
|
local - local to the server
|
||||||
object, the variable will still be there, so you should be careful and set the
|
account - attached to the account of the character identified by RID
|
||||||
variables you mean to be temporary to something sensible before using them. It
|
character - attached to the character identified by RID
|
||||||
also pays to keep variable names descriptive and reasonably long.
|
npc - attached to the NPC
|
||||||
|
|
||||||
Variable scope is defined by a prefix before the variable name:
|
Extent can be:
|
||||||
|
permanent - Permanent NPC variables exist while the server is running.
|
||||||
|
Others still exist when the server resets.
|
||||||
|
temporary - Temporary NPC variables exist while the script instance is running.
|
||||||
|
Others cease to exist when the server resets.
|
||||||
|
|
||||||
" " - Thats right, nothing before a variable, this a permanent variable
|
Prefix: scope and extent
|
||||||
attached to the character object.
|
nothing - A permanent variable attached to the character, the default
|
||||||
"@" - A temporary version of a character-based variable.
|
variable type.
|
||||||
SVN versions before 2094 revision and RC5 version will also treat 'l' as
|
"@" - A temporary variable attached to the character.
|
||||||
a temporary variable prefix, so bevare of having variable names starting
|
SVN versions before 2094 revision and RC5 version will also treat
|
||||||
with 'l', they will also be considered temporary, even if you didn't mean
|
'l' as a temporary variable prefix, so beware of having variable
|
||||||
them to be!
|
names starting with 'l' if you want full backward compatibility.
|
||||||
"$" - A global permanent variable.
|
"$" - A global permanent variable.
|
||||||
They are stored in "save\mapreg.txt" file and are the only kind of
|
They are stored in "save\mapreg.txt" file and are the only kind of
|
||||||
variables stored in a text file in the SQL version.
|
variables stored in a text file in the SQL version.
|
||||||
"$@" - A global temporary variable.
|
"$@" - A global temporary variable.
|
||||||
This is important for scripts which are called with no RID attached, that
|
This is important for scripts which are called with no RID
|
||||||
is, not triggered by a specific character object.
|
attached, that is, not triggered by a specific character object.
|
||||||
"#" - A permanent account-based variable.
|
"." - A variable that exists on the NPC as long as the server is running.
|
||||||
They are stored with all the account data in "save\accreg.txt" in TXT
|
They are only accessible from inside the NPC or by calling
|
||||||
versions and in the SQL versions in the 'global_reg_value' table using
|
'getvariableofnpc'.
|
||||||
type 2.
|
".@" - A temporary variable that exists until the script instance ends.
|
||||||
"##" - A permanent account-based variable stored by the login server.
|
They are only accessible in that NPC instance.
|
||||||
|
"#" - A permanent local account variable.
|
||||||
|
They are stored with all the account data in "save\accreg.txt" in
|
||||||
|
TXT versions and in the SQL versions in the 'global_reg_value'
|
||||||
|
table using type 2.
|
||||||
|
"##" - A permanent global account variable stored by the login server.
|
||||||
They are stored in "save\account.txt" and in the SQL versions in the
|
They are stored in "save\account.txt" and in the SQL versions in the
|
||||||
'global_reg_value' table, using type 1. The only difference you will
|
'global_reg_value' table, using type 1. The only difference you will
|
||||||
note from normal # variables is when you have multiple char-servers
|
note from normal # variables is when you have multiple char-servers
|
||||||
connected to the same login server. The # variables are unique to each
|
connected to the same login server. The # variables are unique to
|
||||||
char-server, while the ## variables are shared by all these
|
each char-server, while the ## variables are shared by all these
|
||||||
char-servers.
|
char-servers.
|
||||||
|
|
||||||
|
Postfix: integer or string
|
||||||
|
nothing - integer variable, can store positive and negative numbers, but only
|
||||||
|
whole numbers (so don't expect to do any fractional math)
|
||||||
|
'$' - string variable, can store text
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
name - permanent character integer variable
|
||||||
|
name$ - permanent character string variable
|
||||||
|
@name - temporary character integer variable
|
||||||
|
@name$ - temporary character string variable
|
||||||
|
$name - permanent global integer variable
|
||||||
|
$name$ - permanent global string variable
|
||||||
|
$@name - temporary global integer variable
|
||||||
|
$@name$ - temporary global string variable
|
||||||
|
.name - permanent npc integer variable
|
||||||
|
.name$ - permanent npc string variable
|
||||||
|
.@name - temporary npc integer variable
|
||||||
|
.@name$ - temporary npc string variable
|
||||||
|
#name - permanent local account integer variable
|
||||||
|
#name$ - permanent local account string variable
|
||||||
|
##name - permanent global account integer variable
|
||||||
|
##name$ - permanent global account string variable
|
||||||
|
|
||||||
|
If a variable was never set, it is considered to equal zero for integer
|
||||||
|
variables or an empty string ("", nothing between the quotes) for string
|
||||||
|
variables. Once you set it to that, the variable is as good as forgotten
|
||||||
|
forever, and no trace remains of it even if it was stored with character or
|
||||||
|
account data.
|
||||||
|
|
||||||
Some variables are special, that is, they are already defined for you by the
|
Some variables are special, that is, they are already defined for you by the
|
||||||
scripting engine. You can see the full list somewhere in 'db/const.txt', which
|
scripting engine. You can see the full list somewhere in 'db/const.txt', which
|
||||||
is a file you should read, since it also allows you to replace lots of numbered
|
is a file you should read, since it also allows you to replace lots of numbered
|
||||||
@ -508,21 +550,7 @@ or a function to set something, it's usually preferable to use that instead. The
|
|||||||
notable exception is Zeny, which you can and often will address directly -
|
notable exception is Zeny, which you can and often will address directly -
|
||||||
setting it will make the character own this number of zeny.
|
setting it will make the character own this number of zeny.
|
||||||
|
|
||||||
All of the above variables store numbers. They can store positive and negative
|
|
||||||
numbers, but only whole numbers (so don't expect to do any fractional math). You
|
|
||||||
can also store a string in a variable, but this means naming it specially to
|
|
||||||
denote it contains text rather than a number:
|
|
||||||
|
|
||||||
@variable$ is a temporary string variable.
|
|
||||||
$@variable$ is a global temporary string variable.
|
|
||||||
|
|
||||||
Etc, etc.
|
|
||||||
|
|
||||||
If a variable was never set, it is considered to equal zero (for number
|
|
||||||
variables) or an empty string ("", nothing between the quotes) for string
|
|
||||||
variables. Once you set it to that, the variable is as good as forgotten
|
|
||||||
forever, and no trace remains of it even if it was stored with character or
|
|
||||||
account data.
|
|
||||||
|
|
||||||
Arrays
|
Arrays
|
||||||
------
|
------
|
||||||
@ -3309,6 +3337,21 @@ Example 4:
|
|||||||
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
|
*sleep {<milliseconds>};
|
||||||
|
*sleep2 {<milliseconds>};
|
||||||
|
*awake "<NPC name>";
|
||||||
|
|
||||||
|
Sleep Timers:
|
||||||
|
'sleep' and 'sleep2' pauses the execution of the script.
|
||||||
|
'sleep' detaches the player from the script and 'sleep2' doesn't.
|
||||||
|
'awake' forces all sleep queues on an NPC to execute.
|
||||||
|
|
||||||
|
sleep 10000; // Sleep for 10 seconds, without player attached.
|
||||||
|
sleep2 5000; // Sleep for 5 seconds, with player attached.
|
||||||
|
awake "npc_name"; // Awakes the NPC.
|
||||||
|
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
*announce "<text>",<flag>{,<color>}
|
*announce "<text>",<flag>{,<color>}
|
||||||
|
|
||||||
This command will broadcast a message to all or most players, similar to
|
This command will broadcast a message to all or most players, similar to
|
||||||
|
Loading…
x
Reference in New Issue
Block a user