help with trying to world.send a variable please!

Posted by Jennkei on Sat 19 Aug 2006 10:03 AM — 3 posts, 15,784 views.

#0
Heyla everyone,

I'm trying to make a script that will check my xp to next level and automatically switch my equipment to a different set which I use for leveling. Three variables are involved in this - lvl (sends more than ten lines to the mud, starting with - remove neck1\nremove neck2\n...removes all the item slots and puts the right ones in with wear <item>), replace (similar to lvl), and lowtnl, which has a value of 0 or 1, and which I use to activate a trigger which is supposed to send lvl(variable) to the mud.

So, for example, when my xp reaches <800, a trigger (lowtnl) will detect this in my prompt and set the variable lowtnl to 1.

<triggers>
<trigger
keep_evaluating="y"
match="*Xp:*tnl*"
name="lowtnl"
send_to="12"
sequence="100"
>
<send>if %2<800 then
world.send "gt %2" **just to make sure the trigger worked, removing this line when everything is done
world.setVariable "lowtnl", "1"
world.EnableTrigger "lowtnl", FALSE
world.EnableTrigger "every", TRUE
end if</send>
</trigger>
</triggers>

I realise it's confusing to have both a variable and trigger called lowtnl, but I mixed them up when one was leveling and the other was lowtnl, so decided might as well make both the same. XD it shouldn't affect things, right?

After lowtnl(trigger) changes lowtnl(variable) to 1, it disables itself and enables every, a trigger, below -

<triggers>
<trigger
expand_variables="y"
keep_evaluating="y"
match="*[Hp:*"
name="every"
send_to="12"
sequence="100"
>
<send>if @lowtnl="1" then
world.send "@lvl"
world.EnableTrigger "every", FALSE
end if</send>
</trigger>
</triggers>

I wanted to put this in the script, but I couldn't figure out how to make it constantly evaluate (or loop?) so I just stuffed it to trigger from my prompt. Ideally it should run on for only a line, in any case.

I finally get to the point - world.send "@lvl" is the one I'm having trouble with. Because @lvl includes \n, I think, I get this error -
Unterminated string constant
Line in error:
world.send "remove neck1

Is there any way for me to be able to send the variable, as itself, with all the lines intact? Or am I forced to have to edit my equipment changes in the trigger itself, with world.send for every line, if I want this to work?

Thanks!

Zhai'helleva, Stille'sawola,
~jenn~
Amended on Sat 19 Aug 2006 10:04 AM by Jennkei
Australia Forum Administrator #1
The solution to that is pretty simple. Instead of this line:


world.send "@lvl"


do this instead:


Send (GetVariable ("lvl"))


This version gets the actual variable as an argument to Send, rather than trying to put it into a string literal. As it doesn't use a string literal, it can be multiple lines without any problems.
#2
Woo, it works! Thank you so much! :) :D Now to finish it with the replace thing. :)

Zhai'helleva, Stille'sawola,
~jenn~