Hello, we apologize but forum registrations are non-functional at this time. This issue should be fixed around mid-December. Until then, please stop by our Discord channel if you'd like to get in touch with the team. Thanks!

New game mode - CustomMode

For discussion of the code running behind the game

Moderator: Staff

Post Reply
User avatar
Posts: 8669
Joined: Wed Jun 16, 2004 12:07 pm
Location: Austin TX

New game mode - CustomMode

Post by Roots » Mon Aug 15, 2016 1:09 pm

This weekend I built something cool that we've thought about doing for a long time. :hack: It's a game mode that is almost entirely implemented in Lua. The motivation for why I decided to write this now is that in the 1.0.0 release we are going to need some "transition" screens, such as text that says "Several days later..." after the attack on the capital, and something like a "To be continued..." screen with a background graphic. This type of small-scale game mode seemed perfectly suited for something that we want to implement in Lua.

I have it uploaded to my repository (not yet merged into the central repo). You can take a look here.

Naturally, it's pretty simple. You give the constructor a filename containing the script that implements the mode (custom game modes will be stored in lua/scripts/custom/). Then you can add any number of pairs of string "options" to tell the mode to load certain data or execute specific code. What options are recognized is completely up to the Lua script implementing the mode. The Lua code that implements the mode has only three requirements. There must be a Reset(), Update(), and Draw() function. Everything else is completely up to the script.

I'm about to finish the first custom mode script, which I named screen_text.lua. It allows you to set an image background (if desired), and one or more text strings to display on the screen. You can specify a time to wait after each line of text is fully visible before moving on to the next step. Once all lines have been presented, the screen fades out and the mode self-terminates. You can also specify an option to tell the mode to load a map (or other mode) and push it to the game stack to replace the departing custom mode.

Just thought I'd give a heads up about this new feature. Hopefully we'll find a lot more uses for it, maybe even utilizing it for testing purposes? I'll merge it into the central repo in a few days time. And at some point I'll write up documentation for it on the wiki as well. :approve:
Post Reply