Difference between revisions of "Setarray"

From Hercules Wiki
Jump to: navigation, search
(Created page with "Category:Script_Command ==Syntax== * setarray <array name>[<first value>],<value>{,<value>...<value>}; ==Description== This command will allow you to quickly fill up a...")
 
 
Line 9: Line 9:
 
==Examples==
 
==Examples==
 
<pre>
 
<pre>
     setarray .@array[0],200,200,200;
+
     [[setarray]] .@array[0],200,200,200;
     setarray .@array[1],300,150;
+
     [[setarray]] .@array[1],300,150;
 
     // will produce:
 
     // will produce:
 
     // .@array[0]=200
 
     // .@array[0]=200
Line 16: Line 16:
 
     // .@array[2]=150
 
     // .@array[2]=150
 
</pre>
 
</pre>
 +
 +
 +
==String Array==
 +
[[setarray]] @array$[0],"word1","word2","word3","word4";
 +
// will produce:
 +
// @array$[0] = word1
 +
// @array$[1] = word2
 +
// @array$[2] = word3
 +
// @array$[3] = word4
 +
 +
// Example
 +
  [[setarray]] .@maps$[0],"guild_vs1","guild_vs2";
 +
  [[if]](class < 10) {[[warp]] .@maps$[1],0,0; }
 +
  [[if]](class > 10) {[[warp]] .@maps$[2],0,0; }

Latest revision as of 19:09, 23 June 2013

Contents

Syntax

  • setarray <array name>[<first value>],<value>{,<value>...<value>};

Description

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.

First value is the index of the first element of the array to alter.

Examples

    [[setarray]] .@array[0],200,200,200;
    [[setarray]] .@array[1],300,150;
    // will produce:
    // .@array[0]=200
    // .@array[1]=300
    // .@array[2]=150


String Array

setarray @array$[0],"word1","word2","word3","word4";
// will produce:
// @array$[0] = word1
// @array$[1] = word2
// @array$[2] = word3
// @array$[3] = word4
// Example
 setarray .@maps$[0],"guild_vs1","guild_vs2";
 if(class < 10) {warp .@maps$[1],0,0; }
 if(class > 10) {warp .@maps$[2],0,0; }