SRL Archive - OSR Help

Question And Problem: When is a DTM loaded, and Why Does This Parameter Not Work?


SomeGuyFromHere

2013-05-22 17:30:17

Hello Villavu,

two things are currently stopping me from developing a script. A little background: It is supposed to make it easier to sell stuff on the Grand Exchange. So if you just finished mining or farming or something similar and want to get your stackable items stored in your bank account sold you can do so automatically while drinking coffee or surfing the web :spot:

Stuff is working pretty well, but now I want the script to be able to sell various goods and not just the clay I have been experimenting with.
The obvious thing is to add a parameter to the routines actually withdrawing and selling your items, like so:

Function WithdrawClay (DTM: integer): Boolean;

var x, y, Clay: Integer;

begin

if TalkToBanker = True then

begin
MouseBox(112, 389, 408, 396, 1);
Wait(3000+(Random(7000)));

Clay:= DTMFromString('mlwAAAHicY2dgYNgKxHuBeCcQbwHiDUC8CYgPAvECIF4IxEugeBEQzwXieUDcWewLJJmwYi4G7AAkzogHQwEA+9cK4A==');
FindDTM(DTM, x, y, 31, 94, 490, 288);
//MMouse(x, y, 0, 0);
FreeDTM(DTM);

[yadayadayada]

Result:= True;

end;
end;
and then calling them like so:
if WithdrawClay(Clay) = True then


But obviously something is wrong with that since the compiler tells me this:
Unknown identifier 'Clay'


This ought to be a very simple error but I can't quite put my finger on it. DTMs are integers for sure…
Could somebody point me in the right direction?


Also, concerning DTMs: At which point are they actually getting "loaded"? After using them you're usually told to free them using FreeDTM, but what if I want to include a large amount of DTMs in my script and just define them in a procedure at the beginning of the script like I always do with my SRL walkpaths:
Procedure setglobals;

begin

SPS_Setup(RUNESCAPE_SURFACE,[yadayadayada]);//SPS Areas
VarrockToClerk := [yadayadayada];

end;

Will they take a lot of memory or are they only loaded when a procedure like FindDTM uses them?

Thanks so much for your help :)

t4q

2013-05-22 17:44:40

I'd try this:
Function WithdrawClay : Boolean;

var x, y, Clay: Integer;

begin

if TalkToBanker = True then

begin
MouseBox(112, 389, 408, 396, 1);
Wait(3000+(Random(7000)));

Clay:= DTMFromString('mlwAAAHicY2dgYNgKxHuBeCcQbwHiDUC8CYgPAvECIF4IxEugeBEQzwXieUDcWewLJJmwYi4G7AAkzogHQwEA+9cK4A==');
FindDTM(DTM, x, y, 31, 94, 490, 288);
//MMouse(x, y, 0, 0);
FreeDTM(DTM);

[yadayadayada]

Result:= WaitOption('ithdraw-All', 500); // You took all clay out from bank

end;
end;

If WithdrawClay then


DTM's are only loaded if you use that procedure

The Mayor

2013-05-22 17:46:35

You get the unknown identifier error because you are calling


if WithdrawClay(Clay) = True then

outside of the WithdrawClay function. The Clay variable is a local variable within that function. I.e. you need to make a var global if using within multiple procedures/functions.

I'm pretty sure DTMs get loaded when you first call them in a script, and are in the memory until you free them.

SomeGuyFromHere

2013-05-23 12:00:47

I'm pretty sure DTMs get loaded when you first call them in a script, and are in the memory until you free them.

As soon as they're defined they're loaded, and when they're "freed" you have to load them again, just like you said. Got to that conclusion while debugging my script.