Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use Cavebot function only when previous goto was successful
#1
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

Code:
-- 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
         CaveBot.gotoLabel("refill")
      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
    end
end

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


Forum Jump:


Users browsing this thread: 1 Guest(s)