Script engine updates in 0.66.4 server

Forum Archive - from http://theuniversal.net
Locked
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Script engine updates in 0.66.4 server

Post 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.
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

Ooo loops XD. Recursion is finally a thing of the past.
Locked