SRL Archive - OSR Help

If over x time has passed do y


Hasselihas

2014-09-06 18:16:38

So looking for a way to turn my camera back to north every few minutes to make sure my banking works at Pest Control bank which doesn't yet have working "OpenBank" function. Planned to do something like this down here, but obviously it didn't work out
procedure Spin
begin
if (TimeFromMark(time)>300000) then
time := 0;
MakeCompass('N');
MarkTime(time);
end
"Time" is my variable there which I turn on earlier with another
MarkTime(Time); 

I think my problem is that resetting the time with
time:= 0;
doesn't work and so when I for testing purposes writeln the time in debug it shows huge amounts like 57000000 ms etc.
So what I'm looking forward is a way to reset the time or alternatively an easier way to use pc bank :)

P.S. Sorry if my post is unclear, it's getting late here.

Brandon

2014-09-06 19:02:55

From: Hasselihas
…



https://github.com/SRL/SRL-6/blob/master/lib/utilities/time.simba#L352


..TTimeMarker.. Use it like:

marker.Start();
marker.getTime();
marker.reset();


etc.. marker.getTime() returns the amount of time elapsed since the timer was started. Marker is an instance of TTimeMarker.. You may call/name it whatever you want.

Hasselihas

2014-09-06 19:36:10

From: Brandon
https://github.com/SRL/SRL-6/blob/master/lib/utilities/time.simba#L352


..TTimeMarker.. Use it like:

marker.Start();
marker.getTime();
marker.reset();


etc.. marker.getTime() returns the amount of time elapsed since the timer was started. Marker is an instance of TTimeMarker.. You may call/name it whatever you want.


So I basicly add those procedures into my code and then I can use the markers? Assuming that was what I had to do I faced another obstacle
procedure marker.reset();
begin
Self.paused := False;
Self.time := 0;
Self.startTime := 0;
Self.__prevMark := 0;
end;
Comes out with an error "Access violation" at line 3, column 13

Brandon

2014-09-06 19:57:23

From: Hasselihas
Comes out with an error "Access violation" at line 3, column 13





{$include_once SRL-6/lib/utilities/time.simba}

var
Marker: TTimeMarker; //Create an instance of TTimeMarker called "Marker". "Marker" is just a "name/alias" to identify the TTimeMarker object instance.
Marker2: TTimeMarker;
begin
Marker.start(); //Call the start function of the TTimeMarker object with the alias "Marker".
Sleep(random(2000)); //Simulate your script doing some other stuff..
writeln('Time Passed: ', Marker.getTime(), 'ms'); //Print the amount of time passed since "Marker"'s start function was called.
Marker.reset(); //Reset Marker.




//use another marker for some other stuff..
//You could easily reset "Marker" and re-use it instead but I chose not to.
//just as an example.. Marker2 is another instance of TTimeMarker.
Marker2.start();
Sleep(random(3000));
writeln('Time Passed: ', Marker2.getTime(), 'ms');
Marker2.reset();
end.


Works perfectly fine.. You don't have to add "procedures" to your code.. You just need to "use" them. Note that in the above script, I used 2 markers.. This is just to show you that you can use as many as you want. It's up to you to decide how many you need and whether it should be global (global variable) or local (variable inside a function).

Hasselihas

2014-09-07 05:50:33

From: Brandon

helpfull code


Works perfectly fine.. You don't have to add "procedures" to your code.. You just need to "use" them. Note that in the above script, I used 2 markers.. This is just to show you that you can use as many as you want. It's up to you to decide how many you need and whether it should be global (global variable) or local (variable inside a function).


So its part of the include.. now I understand. Though I didn't get srl-6 work with srl-osr because of some duplicates (if I understood correctly), I got it working by moving the TTimeMarker to srl-osr. Might have been smarter if I created another include when I think about it now but still I am really thankful for your help :)

Flight

2014-09-07 06:39:50

From: Brandon
SRL-6 stuff…


Wrong include mate, he's asking for help with a SRL-OSR based script.

Here's one way to do it:

Var
globalTimer : Integer;

procedure Spin();
begin
if (timeFromMark(globalTimer) < 300000) then Exit; // Not yet time...
makeCompass('N');
markTime(globalTimer);
end;

begin
markTime(globalTimer);
repeat
Spin(); // Constantly called but only sets the compass when "globalTimer" reaches 300,000 ms
until(false);
end.

Brandon

2014-09-07 10:53:01

From: Flight
Wrong include mate, he's asking for help with a SRL-OSR based script.



Good eye. Didn't catch he wanted it for OSRS.. Though, the SRL-6 Time.Simba file has no dependencies so he can easily drag it to the OSRS include and it will still work.


I think OSRS should actually have that or at least copy the SRL-6 one over. It runs straight out of the box without modifications or errors.


@OP.. you are right about copying the file to OSRS. Glad it works. Pretty lucky lol.