Delayed responce

Posted by Val on Sat 12 Mar 2011 09:25 PM — 3 posts, 17,324 views.

#0
Hi

No doubt this has been on before, but I can't seem to find it and I'm sure I must of ticked a box by accident but cant find it.

I made a variable for my spells, which will send the nane of the spell to the status line when I change it, this was working well, however now it sends the previous variable and not the variable I change it too.

So, if I change my spell to magic missile, the old veriable (say light) gets sent to the status line although if I look in the variable box magic missile is there

Let me know what I did wrong please, the code I use is below

SetVariable ("spellname1", "magic missile")
ColourNote ("white", "blue", "Spell is now: @spellname1")
ColourNote ("white", "blue", "Target is still: @target")
SetStatus ("Target: @target / Spell: @spellname1")

(which will come out as light or whatever the last variable was

Thanks
Val
USA #1
The @variable form isn't actually part of Lua. MUSHclient evaluates @variables before running the script, so your code first becomes this:
SetVariable ("spellname1", "magic missile")
ColourNote ("white", "blue", "Spell is now: light")
ColourNote ("white", "blue", "Target is still: Somebody")
SetStatus ("Target: Somebody / Spell: light")

And -then- it's run. What you should do to avoid this is:
SetVariable ("spellname1", "magic missile")

local spellname1 = GetVariable("spellname1")
ColourNote ("white", "blue", "Spell is now: " .. spellname1)
ColourNote ("white", "blue", "Target is still: @target")
SetStatus ("Target: @target / Spell: " .. spellname1)

Here, I'm using a Lua function to get the spellname1 variable, so there aren't any nasty surprises.
#2
Thanks, I managed to work out by adding a comma I could get a split line for my target, it was going to be my next question

SetStatus ("Target: " .. target, " / Spell: @spellname1")

your help is much appreciated

Val