SRL Archive - OSR Help

I need help with a structure of programming failsafes.


Eduard

2014-08-20 13:18:27

Dear SRL members,

After a long period of time not scripting, i'm in search of a method to incoorporate a nice way to program fail safes in a way that I don't have to call all the functions all the time.

For example, I would like to check if the Bankscreen is up. But if I don't place a Wait(x); in front of the function, the script will return false and goes to the next procedure without having it check again. I can solve this by using a While(Not()) loop, but this can cause infinite loops. I could use TimeMark, but is there a way to have a nice way to write failsafes in a matter of state feedback?

I'll give an example:



procedure WithdrawLogs;
begin
if not(FindTPALogs) then
begin
if(not(Bankscreen)) then
begin
//Withdraw my logs here.
end;
end;
end;

// In this procedure, FindTPALogs is a function that returns true if there are logs in the inventory.
// When I'm calling this procedure, it will try and find the logs, if not true, it will check if the bank is up.
// problem with this is, if my character is banking and this procedure is called, the bankscreen may not already be up.
// to solve this problem, I could place a random wait or a while loop before If(Not(Bankscreen)).
// How can I code this more efficiently? What is the best way to have a feedback of the current state of the character?


In other words, How do I script efficiently without needing so much random waits, it seems that waits are kinda buggy when it's laggy etc?

NKN

2014-08-20 13:57:33

There's a function you can do called WaitFunc


WaitFunc(@FindTPALogs,4000,10,10);

Can't remember the exact parameters, but its something like that.

Note the @, you'll need to make sure that your function doesn't take parameters as well, if my memory serves.

Eduard

2014-08-20 14:45:50

Thanks, that is indeed where I was looking for.
How should/could I call it efficiently? By using it in the mainloop for every function? or within the procedures called?

procedure mainloop;
begin
if(InvLogs > 0) then
begin
WaitFunc(@OpenBank,4000,10,10);
end;
end;
Does this wait until Openbank has returned a value? How should I use it at its best.

KeepBotting

2014-08-20 17:11:39

From: Eduard
Thanks, that is indeed where I was looking for.
How should/could I call it efficiently? By using it in the mainloop for every function? or within the procedures called?

procedure mainloop;
begin
if(InvLogs > 0) then
begin
WaitFunc(@OpenBank,4000,10,10);
end;
end;
Does this wait until Openbank has returned a value? How should I use it at its best.



It both calls the function & waits until it returns true. You could use it in the mainloop for every function, but I'm sure it'd be better practice to use it as a failsafe in each of your funcs/procs

Eduard

2014-08-20 17:14:54

Isn't there a better way to failsafe this?

NKN

2014-08-20 17:23:24

From: Eduard
Isn't there a better way to failsafe this?


if(InvLogs > 0 and WaitFunc(@OpenBank,4000,10,10)) then
begin
//code here
end;

Tell me if that works, dunno if Lape stops after the first failure or not.

Eduard

2014-08-20 18:05:04

I've made a quick chartflow for my fletcher, please give opinions in what could be better.

NKN

2014-08-20 18:42:27

From: Eduard
I've made a quick chartflow for my fletcher, please give opinions in what could be better.


Switch failed with login.

Login should be first.