Nava2
2009-12-05 15:07:23
No idea if its possible, but perhaps a way to run through an array of procedures/functions when a script terminates.
I think this could be beneficial to SRL. Calling things like last checks etc.
Perhaps a function like:
AddTerminateFunction
Widget
2009-12-05 15:22:50
In SCAR, you'd do this by overwriting the ScriptTerminate; function, which gets called at the end of a script. I suppose we could just do the same thing/similar (OnScriptTerminate?)
Nava2
2009-12-05 15:55:50
From: Widget
In SCAR, you'd do this by overwriting the ScriptTerminate; function, which gets called at the end of a script. I suppose we could just do the same thing/similar (OnScriptTerminate?)
Yeah, my thinking was though, what if a script user wants to use that function? Why not have one that takes an array or something along those lines, that way we can have multiple ScriptTerminate functions.
Method
2009-12-05 16:03:31
From: Nava2
Yeah, my thinking was though, what if a script user wants to use that function? Why not have one that takes an array or something along those lines, that way we can have multiple ScriptTerminate functions.
Why can't the user make a new function and call that one in OnScriptTerminate as well as wherever else they want in the script?
Why would multiple OnScriptTerminate functions be needed?
nielsie95
2009-12-05 17:01:35
Doesn't pascal script support units -> initialization/finalization?
mastaraymond
2009-12-05 17:41:13
From: nielsie95
Doesn't pascal script support units -> initialization/finalization?
Yes.. Except the main script is not a unit? So no finalization?
Also, I don't think we should work with the 'ScriptTerminate' override function. I think it's better to indeed use some kind of event-style trigger.
R0b0t1
2009-12-05 17:56:38
How about we add some general even triggers? For example, "srlOnScriptTerminate" or "srlOnScriptPause" or "srlOnLogout" or "srlOnLogin" or "srlOnChat" or "srlOnUptext". It'd be kinda useful, functions to register callbacks would make life easier.
Also, the callbacks would be optional, but it would be possible to orient SRL to an event-driven model without making it Evil by OOP.
mixster
2009-12-05 21:01:29
You could just have the ScriptTerminate function loop through an array of procedures then have them either as a public array to manipulate or just have wrapper procedures that add procedures to the array.
Widget
2009-12-05 22:37:04
var
OldScriptTerminate: function();
procedure MyFunction;
begin
OldScriptTerminate();
NewStuffs;
end;
begin
OldScriptTerminate := @ScriptTerminate;
ScriptTerminate := @MyFunction;
end.
Might be too complex, but I think that works :p
Nava2
2009-12-05 23:44:45
From: mixster
You could just have the ScriptTerminate function loop through an array of procedures then have them either as a public array to manipulate or just have wrapper procedures that add procedures to the array.
That was my idea, in better words.
R0b0t1
2009-12-06 15:00:14
EVENT-DRIVEN SCRIPTING WOOOOOOOOOOOOOOOOOOOO! a