ID:2599294
 
Code:
#define CREATETIMEDPROC(calledby, calledproc, tickingtime, macroargs...)\
var/datum/TimedProc/newTimedProc = new;\
newTimedProc.source = src;\
newTimedProc.caller = calledby;\
newTimedProc.calledProc = calledproc;\
newTimedProc.triggerTime = cServerTick + tickingtime;\
newTimedProc.arguments = list(macroargs);\
timerProcs.Add(newTimedProc);


#define CALLTIMEDPROCS for(var/datum/TimedProc/cTimedProc in timerProcs) if(cServerTick >= cTimedProc.triggerTime) {\
cTimedProc.Trigger()\
}



//Timed Procs: This calls procs that run on a timer ingame to reduce usage of sleep() and such
var/list/timerProcs = list()

datum/TimedProc
var/source
var/caller
var/calledProc
var/triggerTime
var/list/arguments

datum/TimedProc/proc/Trigger()
try
call(caller, calledProc)(arguments)
catch
world.log << "Timed procs queue error: source: [source] ([source.type]) caller: [caller] ([caller.type]) proc: [calledProc] arguments: [list2params(args)]"
OOCCHAT("Timed procs queue error: source: [source] ([source.type]) caller: [caller] ([caller.type]) proc: [calledProc] arguments: [list2params(args)]", world)
timerProcs.Remove(src)


mob/ghost/Login()
..()
CREATETIMEDPROC(src, "MakeParty", 30)

mob/ghost/proc/MakeParty()
..()
var/mob/party/single/s = new(STARTPOSITION)
s.client = client
client.AddPanes("icpane,wholepane")
OOCCHAT("test", src)
del(src)


Problem description:
Hi folks, I've been back to messing around with DM recently and revamping older projects to be more fluid and less buggy. One of the big improvements is that I am setting up a proc queue so I don't have to make heavy use of sleep() and spawn().

There is a little error though that I can't seem to iron out:

The trigger proc of my TimedProc datum seems to error easily, even if it executes the call() flawlessly. I believe this is due to the mob's indentation not being accounted by the caller var's, not sure. I wanted to ask if there is an easy way out of this, or should I just add an empty catch for that particular problem?
This timed proc system will be less efficient than sleep at scale. Sleep/spawn has seen improvements in recent years that make it much more efficient by using a binary insertion.

Also, what is the error that's being returned? Not enough info to go on here.
I tried removing the try and catch statement and for some reasons, the error message is gone. Not quite sure what happened right there. The error that was given out was just the catch. I'll update this thread if it resurfaces.

Also, you said that sleep and spawn have seen some major improvement, are there any cases where I might want to forego their use? I'm trying to fresh up my pseudo-3d battle engine, which uses tons of sleep procs to make icons turn and face around.
You could probably replace all of those with animate() calls.