Clean-up doc script commands (#4038)

* This commit changed the `@var` to `.@var` in the doc as it would promote bad scripting behavior.
This commit is contained in:
Atemo 2019-03-26 16:09:57 +01:00 committed by GitHub
parent 0c5f917d79
commit 7cc8c96467
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -582,8 +582,8 @@ Assigning variables
Variables can be accessed and modified much like in other programming languages.
@x = 100;
@x = @y = 100;
.@x = 100;
.@x = .@y = 100;
Support for modifying variable values using 'set' is still supported (and required
to exist for this new method to work) so previous scripts will continue to work.
@ -591,13 +591,13 @@ to exist for this new method to work) so previous scripts will continue to work.
When assigning values, all operator methods are supported which exist in the below
'Operators' section. For instance:
@x += 100;
@x -= 100;
@x *= 2;
@x /= 2;
@x %= 5;
@x >>= 2;
@x <<= 2;
.@x += 100;
.@x -= 100;
.@x *= 2;
.@x /= 2;
.@x %= 5;
.@x >>= 2;
.@x <<= 2;
Will all work. For more information on available operators, see the Operators section
described below. All operators listed there may be placed in-front of the '=' sign
@ -631,15 +631,15 @@ Arrays are specifically useful for storing a set of similar data (like several
item IDs for example) and then looping through it. You can address any array
variable as if it was a normal variable:
set @arrayofnumbers[0],1;
set .@arrayofnumbers[0],1;
You can also do things like using a variable (or an expression, or even a
value from another array) to get at an array value:
set @x,100;
set @arrayofnumbers[@x],10;
set .@x,100;
set .@arrayofnumbers[.@x],10;
This will make @arrayofnumbers[100] equal to 10.
This will make .@arrayofnumbers[100] equal to 10.
Index numbering always starts with 0 and arrays can hold over 2 billion
variables. As such, the (guaranteed) allowed values for indices are in the
@ -651,7 +651,7 @@ to be pretty.
Arrays can naturally store strings:
@menulines$[0] is the 0th element of the @menulines$ array of strings. Notice
.@menulines$[0] is the 0th element of the .@menulines$ array of strings. Notice
the '$', normally denoting a string variable, before the square brackets that
denotes an array index.
@ -697,7 +697,7 @@ Examples:
1 == 1 is True.
1<2 is True while 1>2 is False.
@x>2 is True if @x is equal to 3. But it isn't true if @x is 2.
.@x>2 is True if .@x is equal to 3. But it isn't true if .@x is 2.
Only ' == ' and '!=' have been tested for comparing strings. Since there's no way
to code a seriously complex data structure in this language, trying to sort
@ -754,14 +754,14 @@ Logical bitwise operators work only on numbers, and they are the following:
2 = 2^1 (2), so in bits (same size) it would be 0010
The & (AND) operator sets bits which are active (1) in both arguments, so in the
example 1010 & 0010, only the 2^1 bit is active (1) in both. Resulting in the bit
0010, which is 2.
0010, which is 2.
- Basic example of creating and using a bit-mask:
set @options,2|4|16; //(note: this is the same as 2+4+16, or 22)
if (@options & 1) mes "Option 1 is activated";
if (@options & 2) mes "Option 2 is activated";
if (@options & 4) mes "Option 3 is activated";
if (@options & 8) mes "Option 4 is activated";
if (@options & 16) mes "Options 5 is activated";
set .@options,2|4|16; //(note: this is the same as 2+4+16, or 22)
if (.@options & 1) mes "Option 1 is activated";
if (.@options & 2) mes "Option 2 is activated";
if (.@options & 4) mes "Option 3 is activated";
if (.@options & 8) mes "Option 4 is activated";
if (.@options & 16) mes "Options 5 is activated";
This would return the messages about option 2, 3 and 5 being shown (since we've set
the 2,4 and 16 bit to 1).
^ - Xor.
@ -1232,14 +1232,14 @@ other programming language (refer to the "Assigning variables" section).
This is the most basic script command and is used a lot whenever you try to do
anything more advanced than just printing text into a message box.
set @x,100;
set .@x,100;
will make @x equal 100.
will make .@x equal 100.
set @x,1+5/8+9;
set .@x,1+5/8+9;
will compute 1+5/8+9 (which is, surprisingly, 10 - remember, all numbers are
integer in this language) and make @x equal it.
integer in this language) and make .@x equal it.
Returns the variable reference (since trunk r12870).
@ -1278,7 +1278,7 @@ This can also be used to set an array dynamically:
Examples:
set getd("$varRefence"), 1;
set @i, getd("$" + "pikachu");
set .@i, getd("$" + "pikachu");
---------------------------------------
@ -1387,46 +1387,46 @@ with the strings that should go into the menu at this execution, making sure not
to leave any gaps. Normally, you do it with a loop and an extra counter, like
this:
setarray @possiblemenuitems$[0],<list of potential menu items>;
@j = 0; // That's the menu lines counter.
setarray .@possiblemenuitems$[0],<list of potential menu items>;
.@j = 0; // That's the menu lines counter.
// We loop through the list of possible menu items.
// @i is our loop counter.
for( @i = 0; @i < getarraysize(@possiblemenuitems$); @i++ )
// .@i is our loop counter.
for( .@i = 0; .@i < getarraysize(.@possiblemenuitems$); .@i++ )
{
// That 'condition' is whatever condition that determines whether
// a menu item number @i actually goes into the menu or not.
// a menu item number .@i actually goes into the menu or not.
if (<condition>)
{
// We record the option into the list of options actually available.
@menulist$[@j] = @possiblemenuitems$[@i];
.@menulist$[@j] = .@possiblemenuitems$[@i];
// We just copied the string, we do need its number for later
// though, so we record it as well.
@menureference[@j] = @i;
.@menureference[@j] = .@i;
// Since we've just added a menu item into the list, we increment
// the menu lines counter.
@j++;
.@j++;
}
// We go on to the next possible menu item.
}
This will create you an array @menulist$ which contains the text of all items
This will create you an array .@menulist$ which contains the text of all items
that should actually go into the menu based on your condition, and an array
@menureference, which contains their numbers in the list of possible menu items.
.@menureference, which contains their numbers in the list of possible menu items.
(Remember, arrays start with 0.) There's less of them than the possible menu
items you've defined, but the menu command can handle the empty lines - only if
they are last in the list, and if it's made this way, they are. Now comes a
dirty trick:
// X is whatever the most menu items you expect to handle.
menu @menulist$[0],-,@menulist$[1],-,....@menulist$[<X>],-;
menu .@menulist$[0],-,.@menulist$[1],-,...,.@menulist$[<X>],-;
This calls up a menu of all your items. Since you didn't copy some of the
possible menu items into the list, its end is empty and so no menu items will
@ -1441,18 +1441,18 @@ But how do you figure out which option the user picked? Enter the @menu.
starting with 1 for the first option. You know now which option the user picked
and which number in your real list of possible menu items it translated to:
mes "You selected " + @possiblemenuitems$[@menureference[@menu-1]] + "!";
mes "You selected " + .@possiblemenuitems$[.@menureference[@menu-1]] + "!";
@menu is the number of option the user picked.
@menu-1 is the array index for the list of actually used menu items that we
made.
@menureference[@menu-1] is the number of the item in the array of possible menu
.@menureference[@menu-1] is the number of the item in the array of possible menu
items that we've saved just for this purpose.
And @possiblemenuitems$[@menureference[@menu-1]] is the string that we used to
And .@possiblemenuitems$[.@menureference[@menu-1]] is the string that we used to
display the menu line the user picked. (Yes, it's a handful, but it works.)
You can set up a bunch of 'if (@menureference[@menu-1] == X) goto Y' statements to
You can set up a bunch of 'if (.@menureference[@menu-1] == X) goto Y' statements to
route your execution based on the line selected and still generate a different
menu every time, which is handy when you want to, for example, make users select
items in any specific order before proceeding, or make a randomly shuffled menu.
@ -1464,7 +1464,7 @@ probably since that wasn't documented anywhere.
See also 'select', which is probably better in this particular case. Instead of
menu, you could use 'select' like this:
@dummy = select(@menulist$[0],@menulist$[1],....@menulist$[<X>]);
.@dummy = select(.@menulist$[0],.@menulist$[1],...,.@menulist$[<X>]);
For the purposes of the technique described above these two statements are
perfectly equivalent.
@ -1580,8 +1580,8 @@ generally cleaner:
mes "[Man]"
mes "Gimme a number!";
next;
input @number;
if (callfunc("OddFunc",@number)) mes "It's Odd!";
input .@number;
if (callfunc("OddFunc",.@number)) mes "It's Odd!";
close;
}
function%TAB%script%TAB%OddFunc%TAB%{
@ -1890,15 +1890,15 @@ Notice that examples 1 and 2 have the same effect.
Example 3:
@count++;
.@count++;
mes "[Forgetful Man]";
if (@count == 1) mes "This is the first time you have talked to me.";
if (@count == 2) mes "This is the second time you have talked to me.";
if (@count == 3) mes "This is the third time you have talked to me.";
if (@count == 4) {
if (.@count == 1) mes "This is the first time you have talked to me.";
if (.@count == 2) mes "This is the second time you have talked to me.";
if (.@count == 3) mes "This is the third time you have talked to me.";
if (.@count == 4) {
mes "This is the fourth time you have talked to me.";
mes "I think I am getting amnesia, I have forgotten about you...";
@count = 0;
.@count = 0;
}
close;
@ -2182,19 +2182,19 @@ Example:
This command will allow you to quickly fill up an array in one go. Check the
Kafra scripts in the distribution to see this used a lot.
setarray @array[0], 100, 200, 300, 400, 500, 600;
setarray .@array[0], 100, 200, 300, 400, 500, 600;
First value is the index of the first element of the array to alter. For
example:
setarray @array[0],200,200,200;
setarray @array[1],300,150;
setarray .@array[0],200,200,200;
setarray .@array[1],300,150;
will produce:
@array[0]=200
@array[1]=300
@array[2]=150
.@array[0]=200
.@array[1]=300
.@array[2]=150
---------------------------------------
@ -2202,13 +2202,13 @@ will produce:
This command will change many array values at the same time to the same value.
setarray @array[0], 100, 200, 300, 400, 500, 600;
setarray .@array[0], 100, 200, 300, 400, 500, 600;
// This will make all 6 values 0
cleararray @array[0],0,6;
cleararray .@array[0],0,6;
// This will make array element 0 change to 245
cleararray @array[0],245,1;
cleararray .@array[0],245,1;
// This will make elements 1 and 2 change to 345
cleararray @array[1],345,2;
cleararray .@array[1],345,2;
See 'setarray'.
@ -2219,28 +2219,28 @@ See 'setarray'.
This command lets you quickly shuffle a lot of data between arrays, which is in
some cases invaluable.
setarray @array[0], 100, 200, 300, 400, 500, 600;
// So we have made @array[]
copyarray @array2[0],@array[2],2;
setarray .@array[0], 100, 200, 300, 400, 500, 600;
// So we have made .@array[]
copyarray .@array2[0],@array[2],2;
// Now, @array2[0] will be equal to @array[2] (300) and
// @array2[1] will be equal to @array[3].
// Now, .@array2[0] will be equal to .@array[2] (300) and
// .@array2[1] will be equal to .@array[3].
So using the examples above:
@array[0] = 100
@array[1] = 200
@array[2] = 300
@array[3] = 400
@array[4] = 500
@array[5] = 600
.@array[0] = 100
.@array[1] = 200
.@array[2] = 300
.@array[3] = 400
.@array[4] = 500
.@array[5] = 600
New Array:
@array2[0] = 300
@array2[1] = 400
@array2[2] = 0
@array2[3] = 0
.@array2[0] = 300
.@array2[1] = 400
.@array2[2] = 0
.@array2[3] = 0
Notice that @array[4] and @array[5] won't be copied to the second array, and it will return a
Notice that .@array[4] and .@array[5] won't be copied to the second array, and it will return a
0.
---------------------------------------
@ -2252,12 +2252,12 @@ array, shifting all the elements beyond this towards the beginning.
// This will delete array element 0, and move all the other array elements
// up one place.
deletearray @array[0],1
deletearray .@array[0],1
// This would delete array elements numbered 1, 2 and 3, leave element 0 in its
// place, and move the other elements ups, so there are no gaps.
deletearray @array[1],3
deletearray .@array[1],3
---------------------------------------
@ -2295,7 +2295,7 @@ While being optional, if [<start index>] is supplied, the search will begin from
.@variable = 100;
if(countinarray(.@array[0], .@variable))
mes "The number 100 was found in the array @array";
mes "The number 100 was found in the array .@array";
countinarray(.@array[0], .@variable);
//return 1 because the number 100 is an element of the array .@array
@ -2358,15 +2358,15 @@ counted towards this number.
For example:
setarray @array[0], 100, 200, 300, 400, 500, 600;
set @arraysize,getarraysize(@array);
setarray .@array[0], 100, 200, 300, 400, 500, 600;
set .@arraysize,getarraysize(.@array);
This will make @arraysize == 6. But if you try this:
This will make .@arraysize == 6. But if you try this:
setarray @array[0], 100, 200, 300, 400, 500, 600, 0;
set @arraysize,getarraysize(@array);
setarray .@array[0], 100, 200, 300, 400, 500, 600, 0;
set .@arraysize,getarraysize(.@array);
@arraysize will still equal 6, even though you've set 7 values.
.@arraysize will still equal 6, even though you've set 7 values.
---------------------------------------
@ -3083,11 +3083,11 @@ Example:
prontera,164,299,3%TAB%script%TAB%Nyah%TAB%730,{
mes "My name is Nyah.";
mes "I will now search for Meh all across the world!";
if (getmapxy(@mapname$, @mapx, @mapy, BL_NPC, "Meh") != 0) {
if (getmapxy(.@mapname$, .@mapx, .@mapy, BL_NPC, "Meh") != 0) {
mes "I can't seem to find Meh anywhere!";
close;
}
mes "And I found him on map " + @mapname$ + " at X:" + @mapx + " Y:" + @mapy + " !";
mes "And I found him on map " + .@mapname$ + " at X:" + .@mapx + " Y:" + .@mapy + " !";
close;
}
@ -4322,12 +4322,12 @@ class number system, but it's one that comes with constants which make it easy
to convert among classes. The command will return -1 if you pass it a job number
which doesn't have an eA job-number equivalent.
@eac = eaclass();
if ((@eac&EAJ_BASEMASK) == EAJ_SWORDMAN)
.@eac = eaclass();
if ((.@eac&EAJ_BASEMASK) == EAJ_SWORDMAN)
mes "Your base job is Swordman.";
if (@eac&EAJL_UPPER)
if (.@eac&EAJL_UPPER)
mes "You are a rebirth job.";
if ((@eac&EAJ_UPPERMASK) == EAJ_SWORDMAN)
if ((.@eac&EAJ_UPPERMASK) == EAJ_SWORDMAN)
mes "You must be a Swordman, Baby Swordman or High Swordman.";
For more information on the eA Job System, see the docs/ea_job_system.txt file.
@ -4343,16 +4343,16 @@ gender if none is given (if no player is attached, male will be used by default)
The command will return -1 if there is no valid class to represent the specified
job (for example, if you try to get the baby version of a Taekwon class).
@eac = eaclass();
.@eac = eaclass();
//Check if class is already rebirth
if (@eac&EAJL_UPPER) {
if (.@eac&EAJL_UPPER) {
mes "You look strong.";
close;
}
@eac = roclass(@eac|EAJL_UPPER);
.@eac = roclass(.@eac|EAJL_UPPER);
//Check if class has a rebirth version
if (@eac != -1) {
mes "Bet you can't wait to become a " + jobname(@eac) + "!";
if (.@eac != -1) {
mes "Bet you can't wait to become a " + jobname(.@eac) + "!";
close;
}
@ -4633,24 +4633,24 @@ this. Careful, minor magic ahead.
// First, let's get an ID of a character who's name will be on the item.
// Only an existing character's name may be there.
// Let's assume our character is 'Adam' and find his ID.
@charid = getcharid(0,"Adam");
.@charid = getcharid(0,"Adam");
// Now we split the character ID number into two portions with a binary
// shift operation. If you don't understand what this does, just copy it.
@card3 = @charid & 65535;
@card4 = @charid >> 16;
.@card3 = .@charid & 65535;
.@card4 = .@charid >> 16;
// If you're inscribing non-equipment, @card1 must be 254.
// If you're inscribing non-equipment, .@card1 must be 254.
// Arrows are also not equipment.
@card1 = 254;
.@card1 = 254;
// For named equipment, card2 means the Star Crumbs and elemental
// crystals used to make this equipment. For everything else, it's 0.
@card2 = 0;
.@card2 = 0;
// Now, let's give the character who invoked the script some
// Adam's Apples:
getitem2 512,1,1,0,0,@card1,@card2,@card3,@card4;
getitem2 512,1,1,0,0,.@card1,.@card2,.@card3,.@card4;
This wasn't tested with all possible items, so I can't give any promises,
experiment first before relying on it.
@ -4661,21 +4661,21 @@ To create equipment, continue this example it like this:
// values so we'll just set up card1 and card2 with data
// for an Ice Stiletto.
// If you're inscribing equipment, @card1 must be 255.
@card1 = 255;
// If you're inscribing equipment, .@card1 must be 255.
.@card1 = 255;
// That's the number of star crumbs in a weapon.
@sc = 2;
.@sc = 2;
// That's the number of elemental property of the weapon.
@ele = 1;
.@ele = 1;
// And that's the wacky formula that makes them into
// a single number.
@card2 = @ele+((@sc*5)<<8);
.@card2 = .@ele+((.@sc*5)<<8);
// That will make us an Adam's +2 VVS Ice Stiletto:
getitem2 1216,1,1,2,0,@card1,@card2,@card3,@card4;
getitem2 1216,1,1,2,0,.@card1,.@card2,.@card3,.@card4;
Experiment with the number of star crumbs - I'm not certain just how much will
work most and what it depends on. The valid element numbers are:
@ -8148,9 +8148,9 @@ Example:
monster "prontera",149,190,"Poring",1002,10;
.GID = $@mobid[9]; // Store and modify the 10th Poring spawned to make him stronger!
// Save the strong Poring's mob data in the @por_arr[] variable. (@por_arr[1] being level, @por_arr[13] being class, etc.)
// Save the strong Poring's mob data in the .@por_arr[] variable. (.@por_arr[1] being level, .@por_arr[13] being class, etc.)
// With this data we can have the NPC display or manipulate it how we want. This does not have to be ran before 'setunitdata'.
getunitdata .GID,@por_arr;
getunitdata .GID,.@por_arr;
// Set the max HP of the Poring to 1000 (current HP will also get updated to 1000).
setunitdata .GID,UMOB_MAXHP,1000;