Page 1 of 1

Help with script needed here..

Posted: Fri Oct 30, 2009 3:01 am
by Tyrismido
Hello...
I have been trying to make my bot load a certian path after certian amount of time..but it always failed not sure why..
here is the code

Code: Select all

<!-- #16 --><waypoint x="-12364" z="10939">
if(player.free_counter1 == 0) then player.free_counter1 = os.time(); end;
	if( os.difftime(os.time(), player.free_counter1) > 3 )	
		player.free_counter1 = player.BotStartTime_nr;
		loadPaths("repair_1");
	end
</waypoint>
shouldnt it load "repair_1" after 3 secs of fighting?
I hope I am doing something wrong..

Re: Help with script needed here..

Posted: Fri Oct 30, 2009 4:09 am
by d003232
Try:

Code: Select all

	<!-- #16 --><waypoint x="-12364" z="10939">
	if(player.free_counter1 == 0) then player.free_counter1 = os.time(); end;
	if( os.difftime(os.time(), player.free_counter1) > 3600 )	
		player.free_counter1 = os.time();
		load_paths("5-7_bugs_repair.xml");
	end
	</waypoint>
If it's not working, just add your own 'printf' commands to set the content of your fields:

Code: Select all

	<!-- #16 --><waypoint x="-12364" z="10939">
	if(player.free_counter1 == 0) then player.free_counter1 = os.time(); end;
printf("counter: %s\n", player.free_counter1);
printf("diff: %s\n", os.difftime(os.time(), player.free_counter1));
	if( os.difftime(os.time(), player.free_counter1) > 3600 )	
		player.free_counter1 = os.time();
		load_paths("5-7_bugs_repair.xml");
	end
	</waypoint>
And you need to come 2x to that waypoint to have loaded the new path. Because at the first time you reach that wp the difference would be 0.

Re: Help with script needed here..

Posted: Fri Oct 30, 2009 5:54 am
by Tyrismido
thanks for help but wat is that printif used for ? I dont really know @.@
and 1 more thing please..how do I make the bot say something ?
like it to say "/script UseACtion(11);" so that it mount up.

Re: Help with script needed here..

Posted: Fri Oct 30, 2009 7:15 am
by d003232
Tyrismido wrote:thanks for help but wat is that printif used for ? I dont really know @.@
and 1 more thing please..how do I make the bot say something ?
like it to say "/script UseACtion(11);" so that it mount up.
With the 'printf' you will see the content of the fields in your MM window. So you can see if everything is right. Use

Code: Select all

sendMacro()
to use the RoM API functions. I would recommend to take a look into the RoM Bot Wiki -> Functions.

Re: Help with script needed here..

Posted: Fri Oct 30, 2009 11:33 am
by Tyrismido
thanks so much

Re: Help with script needed here..

Posted: Fri Oct 30, 2009 11:57 am
by j_schlott
RoMScript("UseAction(11);")
sendMacro("UseAction(11);")
or
keyboardPress(key.VK_MINUS);

inside a waypoint tag should use your horse, dont forget to add a wait for the spell cast or you will run off without mounting

Re: Help with script needed here..

Posted: Fri Oct 30, 2009 8:07 pm
by Tyrismido
oh thanks alot guys...
I have another problem ..
when I am stuck it usualy try 10 times to get out then log out..
wat if I want it to load a path after the 10 tries?
also wat if I have an addon for combat and I want it to take care of the combat...wat should I do ? just delete the class skills from my profile?
because I tried that and the bot kept just luring mobs and run to another..

Re: Help with script needed here..

Posted: Sat Oct 31, 2009 12:20 am
by droppen
Tyrismido wrote:oh thanks alot guys...
I have another problem ..
when I am stuck it usualy try 10 times to get out then log out..
wat if I want it to load a path after the 10 tries?
also wat if I have an addon for combat and I want it to take care of the combat...wat should I do ? just delete the class skills from my profile?
because I tried that and the bot kept just luring mobs and run to another..
you should try learning lua

Re: Help with script needed here..

Posted: Sat Oct 31, 2009 1:10 am
by d003232
Tyrismido wrote: also wat if I have an addon for combat and I want it to take care of the combat...wat should I do ? just delete the class skills from my profile?
because I tried that and the bot kept just luring mobs and run to another..
Create your own skill. And look at the wiki how to deactivate targting / movement functionality.

Re: Help with script needed here..

Posted: Sun Nov 01, 2009 3:51 pm
by hamncheese
d003232 wrote:Try:

Code: Select all

	<!-- #16 --><waypoint x="-12364" z="10939">
	if(player.free_counter1 == 0) then player.free_counter1 = os.time(); end;
	if( os.difftime(os.time(), player.free_counter1) > 3600 )	
		player.free_counter1 = os.time();
		load_paths("5-7_bugs_repair.xml");
	end
	</waypoint>
If it's not working, just add your own 'printf' commands to set the content of your fields:

Code: Select all

	<!-- #16 --><waypoint x="-12364" z="10939">
	if(player.free_counter1 == 0) then player.free_counter1 = os.time(); end;
printf("counter: %s\n", player.free_counter1);
printf("diff: %s\n", os.difftime(os.time(), player.free_counter1));
	if( os.difftime(os.time(), player.free_counter1) > 3600 )	
		player.free_counter1 = os.time();
		load_paths("5-7_bugs_repair.xml");
	end
	</waypoint>
And you need to come 2x to that waypoint to have loaded the new path. Because at the first time you reach that wp the difference would be 0.
need some guidance on repair with time, i tried to use this code :

Code: Select all

<waypoints>
	<!-- #  1 --><waypoint x="360" z="8870">
if( os.difftime(os.time(), player.BotStartTime) > 3660 ) then
	yrest(5000);
      	keyboardPress(key.VK_9);
	player.BotStartTime = 0; 
      	yrest(20000);
	loadPaths("Repair 17-18 Silverspring 38,23.xml");
</waypoint>
problem while using the code above : the timer wont reset, so after the bot press key 9 (recall button) and load the repair path, and back to grinding path, after the bot arrive on waypoint 1 (inside grinding path) , the timer is more than 3660 (1 hour and 1 minute) so the bot tried to use the recall button, which is on cooldown, so it run straight line to waypoint 2 to on my repair path which is quite far away from the original grinding spot
question : is there any other way/code to reset the timer ?

tried to use another code like the sample above, and inserting the recall code

Code: Select all

<waypoints>
	<!-- #  1 --><waypoint x="360" z="8870">
		if(player.free_counter1 == 0) then player.free_counter1 = os.time(); end;
		if( os.difftime(os.time(), player.free_counter1) > 10 )	
		player.free_counter1 = os.time();
		yrest(5000);
      		keyboardPress(key.VK_9);
		player.BotStartTime = 0; 
      		yrest(20000);
		load_paths("Repair 17-18 Silverspring 38,23.xml");
	end
	
		</waypoint>
problem while using the code above :
Image

Re: Help with script needed here..

Posted: Sun Nov 01, 2009 3:55 pm
by d003232

Code: Select all

if( os.difftime(os.time(), player.free_counter1) > 10 )   
THEN at the end of the line is missing.

And

Code: Select all

player.free_counter1 = os.time();
that's the 'reset' of the timer.

Re: Help with script needed here..

Posted: Sun Nov 01, 2009 11:33 pm
by hamncheese
woot thank you so much d003232, the code works flawlessly and a note to others, the "reset timer" for the code above does not actually put the timer back to 0 on your micromacro window, so if your timer is set on 3660 (61 minute) the timer showed on the micromacro window will keep on increasing.
hope this clear some confusion like i had :)

Re: Help with script needed here..

Posted: Mon Nov 02, 2009 2:20 am
by d003232
hamncheese wrote:woot thank you so much d003232, the code works flawlessly and a note to others, the "reset timer" for the code above does not actually put the timer back to 0 on your micromacro window, so if your timer is set on 3660 (61 minute) the timer showed on the micromacro window will keep on increasing.
hope this clear some confusion like i had :)
You are right. It set's the time to the acutal time and we allways count the difference between the actual time and the last timer value (last time we go to repair).