Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ help with trying to world.send a variable please!

help with trying to world.send a variable please!

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Jennkei   (7 posts)  Bio
Date Sat 19 Aug 2006 10:03 AM (UTC)

Amended on Sat 19 Aug 2006 10:04 AM (UTC) by Jennkei

Message
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~
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 19 Aug 2006 09:46 PM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Jennkei   (7 posts)  Bio
Date Reply #2 on Sun 20 Aug 2006 04:37 AM (UTC)
Message
Woo, it works! Thank you so much! :) :D Now to finish it with the replace thing. :)

Zhai'helleva, Stille'sawola,
~jenn~
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


15,035 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.