elementalelf
2007-09-20 02:17:25
copied and pasted directly from my guildminer
no standards in this, so dont complain about it, i only standardize finished scripts… this is just a snippet of a half complete script, but it worked so well that i had to show you guys.
this is still a work in progress, but i will give you the basic rundown of what happens
first: it finds the coal colour, everyone knows how to make something like that in 2 lines or less… im sure there are prebuilt functions for colourfinding, but this one works fine for its purpose.
then the repeat, signifying the begin of the main loop of the function, that is, it will keep doing everything else until invent is full.
gets system time, this is like my own version of "timefrommark"
next bit is like findobj, except it actually works.
that repeats until it finds a coal rock.
then(and this is the bit where it gets really good)
it clicks the rock.
and it loops finding the colour of the rock within a box (x-10,y-10,x+10,y+10) and when it does, saving that color to var x,y(in this case hax and hay)
untill it doesnt find the colour anymore.
to see it working, delete the // from the line near the bottom
edit: forgot to say, hax and hay are globals.
2nd edit: hmm, i screwed it up, so i copy/pasted this one into scar, and it turns out this one on the forums doesnt work for some reason, ill work on it and post a working one in a second.
3rd edit: got it working again!
ive tried several times, and it seems to be beyond me, although i have no idea why…
however if someone could help me so that it finds the closest coal rock to the player instead of the one closest to the top of the screen, that would be much appreciated.
no standards in this, so dont complain about it, i only standardize finished scripts… this is just a snippet of a half complete script, but it worked so well that i had to show you guys.
this is still a work in progress, but i will give you the basic rundown of what happens
first: it finds the coal colour, everyone knows how to make something like that in 2 lines or less… im sure there are prebuilt functions for colourfinding, but this one works fine for its purpose.
then the repeat, signifying the begin of the main loop of the function, that is, it will keep doing everything else until invent is full.
gets system time, this is like my own version of "timefrommark"
next bit is like findobj, except it actually works.
that repeats until it finds a coal rock.
then(and this is the bit where it gets really good)
it clicks the rock.
and it loops finding the colour of the rock within a box (x-10,y-10,x+10,y+10) and when it does, saving that color to var x,y(in this case hax and hay)
untill it doesnt find the colour anymore.
to see it working, delete the // from the line near the bottom
procedure minecl;
var box1,boy1,box2,tim,timm,boy2,coalcolour:integer;
begin
repeat
findcolortolerance(hax,hay,2570810,MSX1,MSY1,MSX2,MSY2,5);
coalcolour:=getcolor(hax,hay);
tim:=getsystemtime;
repeat
findcolorspiral(hax,hay,coalcolour,MSX1,MSX2,MSY1,MSY2);
mmouse(hax,hay,0,0);
timm:=getsystemtime;
until(isuptextmulti('Mine', 'ine', 'Coal')) or (timm-tim=10000);
if(getcolor(hax,hay)=coalcolour)then
mouse(hax,hay,0,0,true);
repeat
wait(50);
box1:=hax-10;
box2:=hax+10;
boy1:=hay-10;
boy2:=hay+10;
findcolor(hax,hay,coalcolour,box1,boy1,box2,boy2);
// mmouse(hax,hay,0,0);
timm:=getsystemtime;
until(not(findcolor(hax,hay,coalcolour,box1,boy1,box2,boy2))) or (timm-tim>20000);
until(invfull);
end;
edit: forgot to say, hax and hay are globals.
2nd edit: hmm, i screwed it up, so i copy/pasted this one into scar, and it turns out this one on the forums doesnt work for some reason, ill work on it and post a working one in a second.
3rd edit: got it working again!
ive tried several times, and it seems to be beyond me, although i have no idea why…
however if someone could help me so that it finds the closest coal rock to the player instead of the one closest to the top of the screen, that would be much appreciated.