SRL Archive - SRL Archives

AddToBelt function


Flight

2011-12-07 01:05:38

Very simple, maybe some scripters might want this. It'll added a specific tool (defined as a string) to your tool belt. If you already have that tool in your tool belt it'll return false. Just use as AddToBelt('Lobster pot');.

I don't have all of the tools defined in the function but it's quite obvious on how to add the rest. Anyways, it should cover the most popular tools.


Function AddToBelt(What: String): Boolean;
var
X,Y,Slot,T,Tool: Integer;
begin
Result := False;
case What of
'Tinderbox':
Tool := DTMFromString('mggAAAHicY2NgYDjMxMBwAojPAPFpID4IxDuA+CVQ7hkQPwLiN0D8AYpNdNgZoiPDgSwmFMwFJEEYHTDiwBAAAIohC78=');
'Barbarian rod':
Tool := DTMFromString('mggAAAHicY2NgYChlYmDIAOJKIC4C4hwgzgXi+0C5d0B8D4ifAfFbIH4IxDaB0Qy6hiZAFhMK5gKSIIwOGHFgCAAAnhsJrw==');
'Knife':
Tool := DTMFromString('mbQAAAHicY2VgYHBkYmBwAGJzILYBYk8g5mJkYOAFYjEgFgZiBiBurK5miLfjBXKY4JgLSIIwMmDEgsEAAB4RA9I=');
'Hammer':
Tool := DTMFromString('mggAAAHicY2NgYLBnYmCwBmIPIDYHYisg9gXiUEYGhhAg9gTiWCCOA2IvILbT5GTw0Odi8PfxAepmgmMuIAnDyIARB4YAAPp7BZI=');
'Chisel':
Tool := DTMFromString('mbQAAAHicY2VgYNjNxMBwCIi3A/E+IN4BxCKMDAzsQCwIxSB+iDkPg56ODlAHExxzAUkQRgaMWDAYAADN9QVM');
'Small fishing net':
Tool := DTMFromString('mbQAAAHicY2VgYDjCxMBwGIjPAvFJIN4HxAaMDAwmQKwDxBZQtqOxKoORugxQBxMccwFJEEYGjFgwGAAAEFgGGQ==');
'Fishing rod':
Tool := DTMFromString('mbQAAAHicY2VgYOhjYmCYCMQLgHg2EE8FYl5GBgY+IGYCYi4gFgZiPR0dhjB7HqAOJjjmApIgjAwYsWAwAACBxQSE');
'Harpoon':
Tool := DTMFromString('mggAAAHicY2NgYMhmYmAoBuIKIE4G4iwgLgViLkYGhv9A+T9ALA5k8zFC2Gbq7Awerq4M/j4+QB4THHMBSRhGBow4MAQAAPbNCBs=');
'Lobster pot':
Tool := DTMFromString('mrAAAAHic42BgYJjFBMETgXgaEM8D4iVAPAXKfg5U8xGIPwDxJyB+C8RPgfgdEL8E4jALHjBmYGBCwcnx8WDMBeSBMDqAiTMSwDAAAK4jD/k=');
end;

if ExistsItemDTM(Tool, X, Y) then
begin
Slot := CoordsToItem(X, Y);
MouseItem(Slot, False);
Wait(RandomRange(20, 75));
WaitOption('toolbelt', 300);
end else
Result := False;

MarkTime(T);
repeat
if (TimeFromMark(T) > 3000) then
break;
if not ExistsItemDTM(Tool, X, Y) then
break;
if FindBlackChatMessage('already on') then
break;
until(false)

Result := not ExistsItemDTM(Tool, X, Y);

FreeDTM(Tool);
end;

Kinda useless but if you want it, take it.

Dgby714

2011-12-07 01:26:02

lowercase(what), and lowercase them or use consts like TOOL_TINDERBOX

Flight

2011-12-07 01:36:46

From: Dgby714
lowercase(what), and lowercase them or use consts like TOOL_TINDERBOX


The only constants I've found (for items and such) were bitmaps. I didn't know SRL already had DTMs for such tools, where are they located? Also I wonder if they're up to date.

Dgby714

2011-12-07 01:39:14

From: Flight
The only constants I've found (for items and such) were bitmaps. I didn't know SRL already had DTMs for such tools, where are they located? Also I wonder if they're up to date.


Not what I ment. I ment creating TOOL_* constants for use with the function.

Daniel

2011-12-07 01:51:55

From: Flight
The only constants I've found (for items and such) were bitmaps. I didn't know SRL already had DTMs for such tools, where are they located? Also I wonder if they're up to date.


What he means is that 'What' does not equal 'what'. So it's best to make the variable What lowercase (What := Lowercase(What)) do avoid errors by the scripter.

And it's best to create and use constants for such tools to further avoid scripter error.

Flight

2011-12-07 01:55:10

From: Dgby714
Not what I ment. I ment creating TOOL_* constants for use with the function.


Oh okie dokie.

Yeah Daniel I know about lower case. Thanks for the heads up.