SRL Archive - Research & Development Lounge

New script concept (make your own script made easy?)


rj

2013-12-21 09:34:03

I don't know if this is original or not.. but I was thinking of making a noob friendly script were they could make their own script with my script. My script would have an massive include of basic functions

Script skeleton:

type
scriptPart = record
executeOn:array of function:boolean;
action:procedure;
increaseVar:Integer;
end;

type
script = array of scriptPart;
TBooleanArray = array of boolean;

var
yourScript:script;
nodes:Integer = 2;

procedure setUp;
begin
setLength(yourScript, nodes);
with yourScript[0] do
begin
executeOn[0] := @someFunction;
action := @mineRock;
end;
with yourScript[1] do
begin
executeOn[0] := @someFunction;
executeOn[1] := @someOtherFunction;
action := @walkBank;
end;
end;

function funcArrTrue(funcs:array of function:boolean):boolean;
var
i, l:Integer;
begin
for i := 0 to high(funcs) do
if (funcs[i] = true) then
l := l + 1;
result := (l = length(funcs));
end;

procedure executeScript;
var
i:Integer;
begin
for i := 0 to high(yourScript) do
begin
if funcArrTrue(yourScript[i].exectuteOn) then
yourScript[i].action;
end;
end;


Pretty much if an array of functions is true then it does a procedure

Kevin

2013-12-21 12:53:28

All this is in the end is making a more in-depth include basically.