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

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  How to do this thing

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

How to do this thing

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Toldo   (1 post)  [Biography] bio
Date Tue 05 Jan 2010 05:33 PM (UTC)  quote  ]
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

[Go to top] top

Posted by Twisol   USA  (2,230 posts)  [Biography] bio
Date Reply #1 on Tue 05 Jan 2010 05:47 PM (UTC)  quote  ]

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
[Go to top] top

Posted by Cdw   (4 posts)  [Biography] bio
Date Reply #2 on Mon 07 Mar 2011 07:40 PM (UTC)  quote  ]
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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,801 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Mon 07 Mar 2011 08:44 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,801 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Mon 07 Mar 2011 08:46 PM (UTC)  quote  ]
Message
Also see:

http://www.gammon.com.au/forum/?id=4956

That's another way of building in pauses.

- Nick Gammon

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

Posted by Cdw   (4 posts)  [Biography] bio
Date Reply #5 on Mon 07 Mar 2011 11:59 PM (UTC)  quote  ]
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.
[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.


1,976 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

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

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]