Yes, I am passing arguments. I am not sure that you can do so with the postsync callback, but both 'call function ptr myPtr, myArgs' and 'call function name myFunc, myArgs' will accept them, up to something like 10.
For my dispatcher workaround, I just pass a single string, which can be type cast or split as needed.
In either case, you can just call your update function in the main loop before or after calling sync without necessarily attaching to sync
//register some timers to the update handler
System_setInterval("echoString", "oh hai", 1, 1000)
//this will be called once, after 1 second during the update as: App_callFunction(_System_timedIntervals[i].callback, _System_timedIntervals[i].args) -----> App_callFunction("echoString", "oh hai")
System_setInterval("echoNum", "1.0", 1, 2000)
//this will be called once, after 2 seconds during the update as: App_callFunction(_System_timedIntervals[i].callback, _System_timedIntervals[i].args) -----> App_callFunction("echoNum", "1.0")
System_SetInterval("echoComplex", "some message,123,yayNesting", -1, 5000)
//this will be called every 5 seconds, forever, during the update as: App_callFunction(_System_timedIntervals[i].callback, _System_timedIntervals[i].args) -----> App_callFunction("echoComplex", "some message,123,yayNesting")
//dispatcher:
//this is a less than ideal work around for 'call function name myFunc, myArgs' but it gets the job done.
//it just does a select/case on the function name, then passes the argument string as needed.
function App_callFunction(rFunctionName as string, rArgs as string)
err = TRUE
returnStr$ = ""
select rFunctionName
case "echoString": echoString(rArgs) : err = FALSE : endcase
case "echoNum": echoNum(val(rArgs)) : err = FALSE : endcase
case "echoComplex": echoComplex(rArgs) : err = FALSE : endcase
case "yayNesting": yayNesting() : err = FALSE : endcase
endselect
if err = TRUE
//System_log("main.dbx", 4, "error", "ERROR: Callback function not registered: " + rFunctionName)
//App_closeGame(TRUE)
endif
endfunction returnStr$
//callback functions
function echoString(rMessage as string)
print rMessage
endfunction
function echoNum(rNum as float)
inc rNum, 1000.0
print rNum
endfunction
function yayNesting()
print "!!!"
endfunction
function echoComplex(rArgs as string)
split string rArgs, ","
tMessage$ = get split word(1)
tNum# = val(get split word(2))
tFunc$ = get split word(3)
echoString(tMessage$)
echoNum(tNum#)
App_callFunction(tFunc$, "")
endfunction
do
System_updateIntervals()
sync
loop
http://games.joshkirklin.com/sulium
A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.