player:cast("MAGE_PURGATORY_FIRE");
repeat
if 12000 > player.HP and not player:hasBuff("500469") then
player:cast("PRIEST_REGENERATE");
end;
if 6000 > player.HP then
player:cast("PRIEST_URGENT_HEAL");
end;
player:cast("MAGE_PURGATORY_FIRE");
until not player.Battling;
yrest(50);
player:lootAll();
if inventory:itemTotalCount(0) == 0 then
yrest(1000);
sendMacro("ViewDistanceSlider_SetValue(400)");
sendMacro("LeaveParty()");
waitForLoadingScreen();
yrest(3000);
__WPL:setWaypointIndex(__WPL:findWaypointTag("Zumhaendler"));
end
Obviously that code is packed into an userfunction so it doesn't cram the waypoint file. Now what sometimes happens is that the bot lags for a second (because I'm running several clients) and accidentally walks too far. Then the enemies go into the wall and are invincible. Then the bot just stucks there, continuously casting purgatory fire and sometimes healing himself. Sometimes, when I'm lucky, it runs out of mana and can't heal itself and dies, but sometimes it stucks there for hours.
So here's my question:
How do I add a timeout into that function? I want the bot to try for a while, but stop and go to the next waypoint after a couple of minutes.
Any ideas?
No idea what you are doing with your script but os.date() will give you a time value which by getting a difference would effectively give you a way of monitoring how long you did something.
If os.date() doesn't work then install the d303Fix from Curse.com
Or GetTime() will give you how many mSec it's been since the PC was switched on. Again a difference calc will tell you if you've waited too long.
os.date() gives a formated time that is hard to work with. You can use "getTime()" but because it's saved as a table, you would have to use the deltaTime function to get the difference eg. deltaTime(getTime(), starttime). I find it easieast to just use os.clock() which just gives you an easy to use number in seconds so.
rock5 wrote:os.date() gives a formated time that is hard to work with. You can use "getTime()" but because it's saved as a table, you would have to use the deltaTime function to get the difference eg. deltaTime(getTime(), starttime). I find it easieast to just use os.clock() which just gives you an easy to use number in seconds so.