Anti-theft script problem, setting variables

Posted by Happyhellodude on Thu 18 Jun 2009 06:52 AM — 8 posts, 36,849 views.

#0
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.
#1
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.
USA #2
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?
Australia Forum Administrator #3
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.
USA #4
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

Australia Forum Administrator #5
It is more complex than that, see:

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

You need to use wait.make.
#6
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
USA #7
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. :)