Code: Select all
program asd;
var
PouchID : cardinal;
KeyID : cardinal;
a,b,c : integer;
stime : tdatetime;
{$Include 'all.inc'}
begin
setarstatus(true);
{-----------------------------------------}
PouchID := $6700D209;
KeyID := $6700D20A;
{-----------------------------------------}
hungry(1,ground);
while true do
begin
checksave;
waitconnection(5000);
findtype($14FB,ground);
if findfullquantity > 5 then
begin
if targetpresent then canceltarget;
waittargetobject(PouchID);
useobject(finditem);
stime := now;
repeat
wait(500);
waitconnection(5000);
checksave;
a := injournalbetweentimes('fail',stime,now);
b := injournalbetweentimes('Unlocked|not locked',stime,now);
until (a >= 0) or (b >= 0) or (now > stime + (0.5/1440));
if (b >= 0) then
begin
stime := now;
if targetpresent then canceltarget;
waittargetobject(PouchID);
useobject(KeyID);
repeat
checksave;
wait(500);
waitconnection(5000);
a := injournalbetweentimes('lock',stime,now);
until (a >= 0) or (now > stime + (0.5/1440));
end;
end
else begin wait(40000); uosay('.online'); end;
c := c + 1;
if c > 30 then
begin
c := 0;
hungry(1,ground);
end;
end;
end.