Page 1 of 1

Script engine updates in 0.66.4 server

Posted: Thu Jun 05, 2014 5:55 pm
by Mit
I've added a few things to the script engine tonight..

1) Better array support and text strings in arrays.
So you can now do things like:

Code: Select all

$mProductionTable[] = 
{	// itemnum display name			image		size 
		230, "Special Item 1",		"red.jpg",		13, 
		250, "Special Item 2 (250)",     "blue.jpg",	27, 
} 

Event( "Custom", "TestArray" ) 
{ 
 $read1ItemNum = $mProductionTable[1] 
 $read1ImageName = $mProductionTable[3] 

 *say ItemNum = $read1ItemNum  Image name = $read1ImageName
 $mProductionTable[7] = "Amended.jpg" 
}
various restrictions no doubt apply.

2) While loops.
finally :)

Code: Select all

Event( "Custom", "TestWhile" ) 
{ 
 $X = 0 
 while( $X < 5 ) 
 { 
    DoSomeFunction() 
    $X += 1 
 } 
}
Currently i've got a thing in to abort an event or function if you loop more than 500 times (coz its easy to get your server stuck with a typo or duff logic otherwise). I'll refine that later. It probably won't cope with nested loops initially but you can work round that by calling a function with another loop in it.

One day soon I'll post some more script examples making use of this stuff.

Posted: Thu Jun 05, 2014 6:59 pm
by morbydvisns
Ooo loops XD. Recursion is finally a thing of the past.