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.
 Entire forum ➜ MUSHclient ➜ Lua ➜ Anti-theft script problem, setting variables

Anti-theft script problem, setting variables

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


Posted by Happyhellodude   (9 posts)  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.
Top

Posted by Happyhellodude   (9 posts)  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.
Top

Posted by Metsuro   USA  (389 posts)  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
Top

Posted by Nick Gammon   Australia  (23,120 posts)  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
Top

Posted by WillFa   USA  (525 posts)  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

Top

Posted by Nick Gammon   Australia  (23,120 posts)  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
Top

Posted by Happyhellodude   (9 posts)  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
Top

Posted by Maxhrk   USA  (76 posts)  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. :)
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.


26,119 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.