You are browsing as a guest. Sign up (or log in) to start making projects!

5h 7m 10s logged

Script Scheduling Engine Revamp

The entire scripting engine has been redone. It was a lot of cascading changes again, with now each “Scope” having it’s own scheduler. A “scope” is a single logic component that gets attached to entities.

How it works now

The scheduler handles the Lua engine stuff. It wraps the main script around into a coroutine automatically now, and extracts the coroutine into a thread. It then creates a scheduler job object, pending into the queue. The scheduler then gets stepped, and initializes the jobs into the main queue and steps them. By stepping them, it resumes the coroutine until the script either ends or manually pauses the coroutine itself (usually done with a predefined “wait” function). I think this is very similar to how Roblox handles it’s script scheduler, although Roblox’s is of course much more complicated. Handling the events and callbacks was much more difficult though. Each of those ALSO need it’s own thread to run to access coroutine related functions and to access data (otherwise very weird errors will happen, like calling code over a boundary or something). This all gets added as a scheduler job, and that allows us to record telemetry data. Eventually, threads can be assigned a “budget”, where they can be stalled if they consume more than the allotted time or even do things like infinite loop detection, etc. There was just generally tedious work that was annoying.

0
10

Comments 0

No comments yet. Be the first!