As many of you know, I’m working on a service called RBXMod. To demonstrate its capabilities, I’m planning on making a persistent game world that runs purely on RBXMod and create a pretty interface for it on Roblox. I planning on making a game similar to Screeps, but using Lua instead of JavaScript. (For those unfamiliar with Screeps, it is a persistent MMO RTS whose main feature is that there is almost no way to control your units except by programming them.)
However, I see myself running into an issue. Screeps runs user made scripts in the game loop, allowing malicious or accidental infinite loops to run. I’m not aware of how the Screeps developers handle this (I’ve searched and couldn’t find any information), but I’ve thought of a couple ways to handle it:
- Create a new thread / context for every script and kill any scripts that don’t finish within a time limit
- Parsing Lua, inserting checkpoints (this is how CodePen solved the issue), and killing long-running scripts
- Running scripts asynchronously (another thread / context again), having authors be responsible for the resources they use. (Robux / online payments for additional resources)
I’m leaning towards the last option, but I’d run into the issue of synchronization: how do scripts know what game step is currently running and when the next will be? I’d like to make the API approachable for those learning Lua.
How would you handle infinite loops? Be imaginative, a lot is possible on RBXMod that isn’t on Roblox.