array index maths.

Forum Archive - from http://theuniversal.net
Locked
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

array index maths.

Post by morbydvisns »

Software:Universal Client
Version Number:
________________________________________________________________________
Location

________________________________________________________________________
Description:

Code: Select all

function AddButton($dir)
{


$index1 = $dir * 6
$index = $index1 + 1
$xPos = $index
$yPos = $index + 1
$width = $index + 2
$height = $index + 3
$name = $index + 4
$text = $index + 5


$var = $dirButtonSet[$index + 2]
$var2 = $dirButtonSet[width]
*say $var
*say $var2
}

*say $var shows as '2' while
*say $var2 shows as 75, or whatever the proper index value is.

if $index = 12 was set above, and then $var = $dirButtonSet[$index + 22] was done, *say would show as '22'
________________________________________________________________________
Steps to Replicate:
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

this isnt quite a bug - the language doesnt support maths operations within array brackets at the moment, so you can't do $array[ $index + 2 ] atm.
I'll leave it open as a feature request/bug tho :]
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

oh go on then.. thats been added for 0.68.2 server.
( Without much testing so far :] )
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

cool. thanks

Now I can replace all the
$var=$gPlayerVar27+#
$gPlayerVar26=$gBuildingVar[$var]

lines in zoric's scripts :)
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

awesome! =)
Locked