Foundry
2014-04-14 14:15:09
This is what I have:
I am trying to cycle through an array of functions and break when one of them returns true. I have tried everything I can think of to get this to work but it ends up either not compiling or not working correctly. I tried looking at SRLs waitFunc procedure but I still couldn't figure it out. Thanks in advance.
{$include_once srlutilities\srlutilities.simba}
{$include_once wurmopengl.simba}
{$loadlib Riddler.dll}
{$f-} // Thought I might put this in to see if it would fix my problem.
type
TWurmClient = record
ID, ResX, ResY: Integer;
Name: String;
Queue: array of function: Boolean;
end;
procedure TWurmClient.switchTo();
begin
setOpenGLTarget(ID, ResX, ResY);
activateClient();
end;
function TWurmClient.init(_ID: Integer; _Name: String; _Queue: array of function: Boolean): Boolean;
var
i: Integer;
begin
Name := _Name;
Queue := _Queue;
ID := _ID;
getWindowSize(findMainWindow(ID), ResX, ResY);
ResX := ResX - 6;
ResY := ResY - 29;
switchTo();
end;
function no(): Boolean;
begin
result := false;
end;
function yes(): Boolean;
begin
result := true;
end;
function TWurmClient.cycle(): Boolean;
var
i: Integer;
begin
for i to high(Queue) do
begin
writeLn(Queue[i]);
if Queue[i] then
begin
writeLn(toStr(ID) + ' is ceding control.' + toStr(i));
break;
end;
end;
end;
var
test: TWurmClient;
begin
test.init(getPID('Wurm Online 3.'), 'charnamehere', [@no, @yes]);
test.cycle();
end.
I am trying to cycle through an array of functions and break when one of them returns true. I have tried everything I can think of to get this to work but it ends up either not compiling or not working correctly. I tried looking at SRLs waitFunc procedure but I still couldn't figure it out. Thanks in advance.