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 ?
Time-Function
- Administrator
- Site Admin
- Posts: 5307
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Time-Function
You can probably handle that with a bit of trickery in your waypoints. For example, something like this:
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>
<!-- 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 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>
-
- Posts: 42
- Joined: Tue Feb 02, 2016 5:14 pm
Re: Time-Function
thank you very much, I'll have to try that right away
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 10 guests