Page 1 of 1

script to send each bot separately to the mailbox

Posted: Mon May 02, 2011 6:13 am
by poulpito
first sorry for my english i'm french :lol:
As i'm running between 5 and 10 bots concurrently, i was looking for a way to send each bot to the mailbox separately between 3 and 4 am each day and to stop others if one hang outside

basically when a bot have 98egg and time is between 03 and 04am, it write in a file "1" asap and goes out
(if others bot are seeing "1" in the file they're staying inside)
after returning in the millersranch it write 0 in the file and the next bot can go out

i've add this code to the egg script

Code: Select all

nbegg=98;
if( os.date("%H") == "03" or os.date("%H") == "04") 
then 
if( inventory:getItemCount(204792) > nbegg ) then
	filename = getExecutionPath() .. "/profiles/out_bot.xml";
	file, err = io.open(filename, "r");
		if( not file ) then
		printf( "no file\n" );
		error(err, 0);
		end							
	out = file:read();
	file:close();
						
	if out == "1" then
		printf("a bot is already outside !\n");
	        else 
		if out == "0" then
	        printf("sortie ok !\n");
	        filename = getExecutionPath() .. "/profiles/out_bot.xml";
	        file, err = io.open(filename, "w");
	             if( not file ) then
		     error(err, 0);
	             end
	       file:write("1");
	       file:close();
	       loadPaths("Trajet_BAL_varranas.xml");
	       end
         end
end
end
and in the Trajet_BAL_varranas.xml at the end after reaching the millers ranch

Code: Select all

filename = getExecutionPath() .. "/profiles/out_bot.xml";
			file, err = io.open(filename, "w");
			if( not file ) then
				error(err, 0);
			end
			file:write("0");
			file:close();	
loadPaths("MillersRanchChickens.xml");

the next step is to add the last code in the
<onUnstickFailure></onUnstickFailure>
to be sure that if a bot is stuck outside it write "0" and logout so another one can try to reach the mailbox

i'm having several issue with the mailbox script (send items but never close the mailbox and don't go through other waypoint
but this part of the script is running smoothly
it's not optimize, not well coded but it's running :)
if it can help someone :) enjoy