I'm writing a game engine and I'd like to use Io for scripting. The engine is written in pure C99, not C++. I've successfully bound Io to some of the game's C functions, and it works well.
However, I'd like to call Io methods in the C game loop. Essentially, I'd like to load a script (probably with IoState_doFile_()
) containing something along the lines of
Game init := method(...)
Game keypress := method(key, ...)
// and update, render, etc
Then, in the C game loop, I'd like to call those functions, some of which I need to pass arguments to. Unfortunately, Io's documentation is good but incredibly sparse. I've dug through the IoVM code a bit and have found nothing useful (I'm probably not digging hard enough). What's the best way to do this? Something like
sprintf(buf, "Game update(%u)", &deltaTime);
IoState_doCString_(buf);
seems rather hackish (assuming it even works; I haven't tried), not to mention probably really inefficient.