From: Zyt3x
Are you scripting in PascalScript or La-pe?
PascalScript doesn't support overloads, but la-pe does
Don't feel bad, I was thinking the same thing. :p
Ok let's see, adding potion-handling to a script will be done in this process (roughly):
1) Time to take a sip?
2) Find the potion in the inventory
3) Clicking the potion
4) Resetting a "potion timer"
I'll let you handle Step 1 & 4, but I'll show you how to do Step 2 & 3.
For finding an item in the inventory, your best bet is to use DTMs; these are commonly used as their accuracy and simplicity make them very practical. To learn how to make DTMs you can check out one of these tutorials:
Creating Accurate DTMsYohojo's DTM Tut 1(Item finding with DTMs)Now that you've made your DTM of your potion we'll want to find it & click it. I constructed a small example script of how to do this. It's self-explanatory:
{$I SRL/SRL.Simba}
Var
Potion: Integer;
Procedure LoadOurVars;
begin
Potion := DTMFromString('YOUR DTM STRING GOES HEREEEEEEE'); //First, let's define our "Potion" DTM
end;
Procedure FreeOurDTMs;
begin
FreeDTM(Potion);
end;
Function ClickPotion: Boolean;
var
x,y,PotionSlot: Integer;
begin
Result := False; //By default, this function should result False
if FindDTM(Potion,x,y,MIX1,MIY1,MIX2,MIY2) then //If our "Potion" DTM is found in the inventory then...
begin
PotionSlot := CoordsToItem(X,Y); //Convert the X/Y coordinate (that we found the Potion DMT at) into an inventory slot
MouseItem(PotionSlot, mouse_left); //Click the 'PotionSlot' inventory slot with a left-click action
Result := True; //We found & clicked the potion, so let's make this function result True (success!)
end;
end;
begin
SetupSRL;
LoadOurVars; //We MUST load our Potion DTM or the script won't know what to look for!
if ClickPotion then
Writeln('Took a sip of our potion!')
else
Writeln('No potion found...');
FreeOurDTMs; //ALWAYS free the DTMs after we're done using them (usually this is called when a script is stopped
end.
I hope that helps.
Edit:
Also as a small reference, MIX1 = Inventory X1, MIY1 = Inventory Y1, MIX2 = Inventory X2, MIY2 = Inventory Y2. Just in case you were wondering.