Page 1 of 1
Time-Function
Posted: Wed Feb 16, 2022 8:05 am
by mattstar81
Hello
Is it possible to add a time function? that the bot e.g. go to an npc after 60 min ?
how could something like this look like ?
Re: Time-Function
Posted: Fri Feb 18, 2022 5:08 pm
by Administrator
You can probably handle that with a bit of trickery in your waypoints. For example, something like this:
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<waypoints>
<!-- Put this at the top of your waypoints script -->
<onLoad><![CDATA[
last_npc_visit = os.time()
visit_npc_minutes = 60
function reset_last_npc_visit()
last_npc_visit = os.time()
end
function should_visit_npc()
if( (os.time() - last_npc_visit)/60 > visit_npc_minutes ) then
return true
else
return false
end
end
]]></onLoad>
</waypoints>
<!-- Put your actual waypoints here. For example: -->
<!-- # 1 --><waypoint ...></waypoint>
<!-- # 2 --><waypoint ...></waypoint>
<!-- # 3 --><waypoint ...></waypoint>
<!-- At the last waypoint in your loop (or whichever waypoint you want to use), we can check if it's time to go back to NPC -->
<waypoint ...>
if( should_visit_npc() ) then
reset_last_npc_visit()
loadPath("path_to_npc_and_back")
end
</waypoint>
Then create your path (path_to_npc_and_back) which travels to the NPC, does whatever you need to do, then walks back.
Then your path_to_npc_and_back waypoints could look something like this:
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<waypoints>
<!-- # 1 --><waypoint ...></waypoint> <!-- Example, Walking to the NPC -->
<!-- # 2 --><waypoint ...></waypoint> <!-- Example, Interact with the NPC -->
<!-- # 3 --><waypoint ...></waypoint> <!-- Example, Walk back from NPC -->
<!-- At the last waypoint, reload your original waypoints-->
<waypoint ...>
loadPath("original_waypoints")
</waypoint>
Re: Time-Function
Posted: Sun Feb 20, 2022 5:03 am
by mattstar81
thank you very much, I'll have to try that right away