Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use Cavebot function only when previous goto was successful
I am trying to put together a script to check a text message that I will receive onTextMessage such as: You completed the task!

Once I receive this message I will go to a different label, and if I dont receive this message or if the message is null, I would keep hunting - gotoLabel("starthunt") 

So I managed to do all of this with one minor problem. I am using string.find inside a function in the cavebot and it triggers every time I receive a server message. Therefore, whenever I kill a monster it either goes to the start of the hunt or other label.

Is there a way to run the function only when the previous command is successful?

The code that I have is somewhat like the one below

-- check the previous waypoints* this is where I am having problem, it checks every time that I complete any waypoint
if waypoints == true then
say("entering function") --
        if string.find(text, "You completed the task") or nil then -- check if task is completed
      elseif string.find(text, "killed") then -- check if
       return true -- there is a label that goes to the start of the hunt after the function

Hey guys, I figured it out. If anyone has a problem like mine, feel free to contact me.
Inside cavebot custom function you have variable prev which is true / false, based on results from previous function

Forum Jump:

Users browsing this thread: 1 Guest(s)