|
Tolkienfan Wanderer
Joined: 07 Apr 2001 Posts: 51 Location: Denmark
|
Posted: Mon Jan 07, 2002 4:42 pm
Swapping variables |
Ok i need to swap some variable values here...i cant make it work...
I want to change my targets with a macro...
target1 and target2 is to be stored in oldtarget1 and 2...and then secondarytarget1 and 2 are to be put in target1 and 2 and in the end i want to set secondarytargets 1 and 2 to the oldtarget vars values..So basicly be able to swap targets...
I use a macro that goes something like this...
oldtarget1=@target1
oldtarget2=@target2
target1=@secondarytarget1
target2=@secondarytarget2
secondarytarget1=@oldtarget1
secondarytarget2=@oldtarget2
But it wont seem the work...every second time i have to press it twice to make it change..or it just changes the target vars to nothing.....i dont really get it...
Tolkienfan - Still going strong! |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Jan 07, 2002 6:58 pm |
It's not a good idea (in zMUD) to update a variable in the same script which uses it. Experience indicates that the script will use the value that's in the variable at the beginning of the script instead of the one you changed it to. To get around this, I'd recommend using aliases. Your macro can call swap1.
#AL swap1 {oldtarget1=@target1;oldtarget2=@target2;swap2}
#AL swap2 {target1=@secondarytarget1;target2=@secondarytarget2;swap3}
#AL swap3 {secondarytarget1=@oldtarget1;secondarytarget2=@oldtarget2}
LightBulb
All scripts untested unless otherwise noted |
|
|
|
|
|