[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Variables in Timers

Variables in Timers

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


Posted by Lilbopeep   USA  (42 posts)  [Biography] bio
Date Wed 09 Sep 2009 05:22 AM (UTC)

Amended on Fri 11 Sep 2009 11:08 PM (UTC) by Nick Gammon

Message
Simply put, is it possible? I don't see an 'expand variables' option.

making scrolls on my mud is a tedious, often scripted process, but they are fairly handy to have. My solution was to make an alias that would turn on and off a 3 minute timer, which just about perfect for how long it takes to create the parchment object and write the spell onto it.

This all worked fine and dandy, but it only made scrolls of whatever spell I specified, so I thought.. improve it!

Now, I have an alias:


<aliases>
  <alias
   match="scrollmaker *"
   enabled="y"
   expand_variables="y"
   send_to="12"
   sequence="100"
  >
  <send>
if "%1" == "off" then
EnableTimer ("scroll_timer", false)
Note ("Turning off the Scroll Timer.")
else
SetVariable("spell", "%1")
EnableTimer ("scroll_timer", true)
Note ("Turning on the Scroll Timer with spell @spell")
end
</send>
  </alias>
</aliases>


the off part works fine. But the weird thing is, it seems to be giving the previous variable. If I typed 'scrollmaker blackmantle' it would give me what I typed in before?

Example:


>scrollmaker blackmantle
Turning on the Scroll Timer with spell blackmantle
>scrollmaker shriek
Turning on the Scroll Timer with spell blackmantle
>scrollmaker slow
Turning on the Scroll Timer with spell shriek


This also doesn't even address the problem that my timer isn't doing either of these.

the line that is failing in my alias is:

scribe '@spell'

Also, I am not sure if two word spells are already handled properly - it seems to work in the variable, but I've not been able to get beyond that to make sure.

Any ideas?

,.~`'~.,Dance Magic Dance,.~`'~.,
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Wed 09 Sep 2009 06:31 AM (UTC)
Message
Timers don't have an "expand variables" option, but you can do it in scripting, same as in aliases.

Quote:

SetVariable("spell", "%1")
EnableTimer ("scroll_timer", true)
Note ("Turning on the Scroll Timer with spell @spell")


Your problem here is that, when executing a script, MUSHclient replaces @spell by the value in the spell variable *before* executing the code. Thus, changing the variable mid-stream won't affect it. However all you need to do is this:


SetVariable("spell", "%1")
EnableTimer ("scroll_timer", true)
Note ("Turning on the Scroll Timer with spell " .. GetVariable ("spell") )


In this case the GetVariable is executed at runtime, so it will get the right variable. Or, more simply:


SetVariable("spell", "%1")
EnableTimer ("scroll_timer", true)
Note ("Turning on the Scroll Timer with spell %1")



Inside your scroll timer, you can use GetVariable as well. So for example if you wanted to cast "spell" every 5 seconds you could do this:


Send ("cast " .. GetVariable "spell")



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Lilbopeep   USA  (42 posts)  [Biography] bio
Date Reply #2 on Thu 10 Sep 2009 01:23 PM (UTC)
Message
thanks nick! It's working wonderfully!

,.~`'~.,Dance Magic Dance,.~`'~.,
[Go to top] 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.


10,414 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]