According to this mailing-list thread, it is possible to use IoObject_rawDoString_label_()
and IoState_retain_()
to compile a message from source and apply it with IoMessage_locals_performOn_()
.
Alternatively, the message can be constructed manually via IoMessage_newWithName_()
and the IoMessage_setCachedArg_*()
functions.
I did not find any documentation for this, but the list of relevant functions can be found in IoMessage.h.
The code that works for this particular case is
/* When you initialize everything */
renderMessage = IoObject_rawDoString_label_(IoState_lobby(state),
IoState_symbolWithCString_(state, "message(Game render())"),
IoState_symbolWithCString_(state, "[Game render]"));
IoState_retain_(state, renderMessage);
/* In the game loop's render function */
IoMessage_locals_performOn_(renderMessage, IoState_lobby(state), IoState_lobby(state));
For messages that you need to pass arguments to, you need this instead:
/* When you initialize everything */
updateMessage = IoMessage_newWithName_(state, IoState_symbolWithCString_(state, "update"));
IoState_retain_(state, updateMessage);
/* In the game loop's update function */
IoMessage_setCachedArg_toInt_(updateMessage, 0, deltaTime);
IoMessage_locals_performOn_(updateMessage, IoState_lobby(state),
IoObject_getSlot_(IoState_lobby(state), IoState_symbolWithCString_(state, "Game")));