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

Gammon Forum

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

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Anti-theft script problem, setting variables
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Anti-theft script problem, setting variables

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


Posted by Happyhellodude   (9 posts)  [Biography] bio
Date Thu 18 Jun 2009 06:52 AM (UTC)
Message
The problem is that the Variable "scalemailwearstr" is only being set to "wear" and not wear plus the scale mail id.
Here is my code/script


local scalemailid

scalemailid = GetVariable("scalemailid")
scalemailwearstr = "wear ", scalemailid
if scalemailid == nil then
  Note ("scalemailid is not defined")
else
  DoAfter (3.5, scalemailwearstr)
end


Also I would prefer to instead of using the DoAfter command use somthing that would wait for a certain string of text to be printed like a trigger inside of a trigger but I have no idea if this is possable or what the command is .

Thank you very much for any help.
The happy one.
[Go to top] top

Posted by Happyhellodude   (9 posts)  [Biography] bio
Date Reply #1 on Thu 18 Jun 2009 07:42 AM (UTC)
Message
Sorry I figured it out, still learning.
But I would still like to know if there is a way to wait for a string to be printed before carrying on to the DoAfter.
[Go to top] top

Posted by Metsuro   USA  (389 posts)  [Biography] bio
Date Reply #2 on Thu 18 Jun 2009 09:38 PM (UTC)
Message
Couldn't you set a trigger to do something like set a variable and have a heartbeat timer to do the action. Or create a trigger to call the a function to do the command?

Everything turns around in the end
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Thu 18 Jun 2009 10:28 PM (UTC)
Message
Quote:

But I would still like to know if there is a way to wait for a string to be printed before carrying on to the DoAfter.


What do you mean "be printed"?

Like this?


local scalemailid

scalemailid = GetVariable("scalemailid")
scalemailwearstr = "wear " .. scalemailid
if scalemailid == nil then
  Note ("scalemailid is not defined")
else
  print ("about to do: " .. scalemailwearstr)
  DoAfter (3.5, scalemailwearstr)
end


I presume you worked out you have to use .. to concatenate strings.

- Nick Gammon

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

Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Reply #4 on Fri 19 Jun 2009 05:28 AM (UTC)
Message
I think with his trigger in a trigger comment, he's looking for wait.lua.

for example, if your mud does something like "buy scalemail", and then makes you wait a heartbeat or three while the smithy retrieves it...


require "wait"

function BuyStuff(aliasname, line, wildcards)

Boughtitem = wildcards[1]
wait.regexp("The smithy hands you your purchase.")

Send ("wear " .. Boughtitem)
end

[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Fri 19 Jun 2009 06:17 AM (UTC)
Message
It is more complex than that, see:

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

You need to use wait.make.

- Nick Gammon

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

Posted by Happyhellodude   (9 posts)  [Biography] bio
Date Reply #6 on Fri 19 Jun 2009 06:44 AM (UTC)
Message
Wow, That is great thanks everybody got it perfect.
Sorry about being a little "Abstract" with my question.

Here is code to anybody who wants it:

local scalemailid

scalemailid = GetVariable("scalemailid")

if scalemailid == nil then
  Note ("scalemailid is not defined")
else
  require "wait"
  wait.make (function ()
  wait.regexp("You have recovered balance on all limbs.")
  SendImmediate ("wear ", scalemailid)
end)
end
[Go to top] top

Posted by Maxhrk   USA  (76 posts)  [Biography] bio
Date Reply #7 on Sun 26 Jul 2009 01:20 AM (UTC)

Amended on Sun 26 Jul 2009 02:05 AM (UTC) by Maxhrk

Message
There is no need to repeat to include 'require 'wait' within if-else statement in your code, Happyhellodude. Just put it at the beginning of the code, this way its better. :)
[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.


6,682 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 FutureQuest]