How to declare a variable inside another variable

Posted by Pokkie on Tue 27 Oct 2009 09:22 AM — 3 posts, 14,289 views.

#0
Hello all,

I have an alias that lets me recall on Aardwolf, called rec.

My alias goes something like this :
rem @dual_weapon
hold portal
enter
wield @dual_weapon

Now at the moment, @dual_weapon = (123456) but I want to change that to reference another variable, e.g.

@lvl200_dagger = (123456)

@dual_weapon = @lvl200_dagger

However, when my alias runs, then it says it doesn't know what @lvl200_dagger is, instead of seeing its another variable and expanding it.

So my question is, how can I expand a variable inside another variable?

Help much appreciated,
-- pok
Amended on Tue 27 Oct 2009 09:23 AM by Pokkie
Australia Forum Administrator #1
MUSHclient doesn't recursively expand variables, but you can do it with scripting.

For example:


weapon = GetVariable ("dual_weapon")  -- find which weapon (eg. lvl200_dagger)

weapon_id = GetVariable (weapon)  -- now find which number it is (eg. 123456)

Send ("rem " .. weapon_id)
Send ("hold portal")
Send ("enter")
Send ("wield " .. weapon_id)


You would set the Send field to "send to script" for this to work.
#2
It works :)

Thanks alot Nick