Gammon Forum
Entire forum
MUSHclient
Lua
How to do this thing
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| Toldo
(1 post) bio
|
Date
| Tue 05 Jan 2010 05:33 PM (UTC) |
Message
| I have no knowledge of lua, I should fix that.
Is it possible to use a variable for the delay used with DoAfter
uh something like
DoAfter (var ,"make var1 on var2")
var is the time delay which needs to be 3 seconds, var1 is the id_number of the recipe to make which needs to increment by 1 each time to make each of the 50 recipes in a bench and var3 is the name of the bench to make it on
| top |
|
Posted by
| Twisol
USA (2,257 posts) bio
|
Date
| Reply #1 on Tue 05 Jan 2010 05:47 PM (UTC) Amended on Tue 05 Jan 2010 05:48 PM (UTC) by Twisol
|
Message
| Sure it is.
-- a new Lua variable
-- (this is different from the ones in the Variables dialog)
var = 10
DoAfter(var, "make var1 on var2")
If you want to use MUSHclient variables instead (which have the benefit of appearing in the Variables dialog directly, but are less flexible), you could do this (assuming you have the variable set in the dialog already).
DoAfter(tonumber(GetVariable("var")), "make var1 on var2")
EDIT: As for learning Lua, try this online book a try. [1]
[1] http://www.lua.org/pil/ |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | top |
|
Posted by
| Cdw
(4 posts) bio
|
Date
| Reply #2 on Mon 07 Mar 2011 07:40 PM (UTC) |
Message
| I figured posting in this old thread would be better than making YET ANOTHER thread with a one-off LUA DoAfter question; here goes.
I'm looking into LUA as a language on my own, but in the meantime I'm trying to put together little snippets to test it out and familiarize myself and I can't seem to figure out how to use DoAfter in an alias.
To be more specific I have an Alias named "test" which I created through the Config menu which has the following in the "send" box:
west
DoAfter(.5, "west")
DoAfter(.5, "east")
DoAfter(.5, "east")
Just as a proof-of-concept so I'm not eating up my character's resources.
I have it send to "Script" (I forgot and left it on "world" which clearly didn't work) with everything else blank (Label, Script, Group, Variable) and Sequence 100.
When I use the alias however I get a scripting error:
Error number: 0
Event: Compile error
Description: [string "Alias: "]:2: '=' expected near 'DoAfter'
Called by: Immediate execution
I've looked about here under the Lua basics pages, the DoAfter pages (including the scripts function page), on YouTube, and just Google'd it a bit and figured I should probably just ask since really I don't even know what it's asking me for.
Please let me know if you need more info. | top |
|
Posted by
| Nick Gammon
Australia (22,973 posts) bio
Forum Administrator |
Date
| Reply #3 on Mon 07 Mar 2011 08:44 PM (UTC) |
Message
| The first line is the problem. "west" isn't a Lua command. Change it to:
Send ("west")
DoAfter(.5, "west")
DoAfter(.5, "east")
DoAfter(.5, "east")
I should point out that all of the DoAfter will fire after 0.5 seconds. You probably want:
Send ("west")
DoAfter(0.5, "west")
DoAfter(1.0, "east")
DoAfter(1.5, "east")
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Nick Gammon
Australia (22,973 posts) bio
Forum Administrator |
Date
| Reply #4 on Mon 07 Mar 2011 08:46 PM (UTC) |
Message
| |
Posted by
| Cdw
(4 posts) bio
|
Date
| Reply #5 on Mon 07 Mar 2011 11:59 PM (UTC) |
Message
| Ah, of course; how ridiculously obvious - and I actually realized the timing error after this post while reading through DoAfter in another forum.
Much obliged and thank you for all the hard work. I'll keep that linked thread (and some others) bookmarked for later when my comprehension's a bit higher. In the interim DoAfter should serve my limited needs.
Thanks for the MUSH. | 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.
14,632 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
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.