Again on modular rules.js
Posted: 25 Dec 2013, 19:10
The story so far: not sure if anybody noticed, but in current master we have a feature that allows making scripted maps without turning them into a map-mod. We can include an ini file multiplay/maps/<map>.ini and specify custom map rules in it. Documented only here.
Well, i just tried to use this and it works! But there was one bell that rings.
Right now there is quite a few stuff unhardcoded into rules.js, which is a good thing. For example, we have GUI button code, tileset-specific texture code, upgrades code, oil drum spawning code, command center code, victory conditions code.
Now suppose i want to make a custom rules script. Then i have a choice of
Then i could have made a custom rules script that looks like that:
Then my map automatically stays up to date whenever anything changes in the base game's rules.js, breaking only in very rare situations when more functionality is pushed into the base game's rules.js in a separate file i did not include yet. I think we can easily avoid that in minor releases.
Well, i just tried to use this and it works! But there was one bell that rings.
Right now there is quite a few stuff unhardcoded into rules.js, which is a good thing. For example, we have GUI button code, tileset-specific texture code, upgrades code, oil drum spawning code, command center code, victory conditions code.
Now suppose i want to make a custom rules script. Then i have a choice of
- either running my script as "extra", alongside existing rules.js, and then i cannot override existing functions, eg. change victory conditions so that game didn't end when all enemy units are destroyed,
- or running my script as "rules", replacing existing rules.js, and then my script would have to re-implement all the things, eg. i wanted to only change victory conditions, but i have to carry the whole GUI and textures and upgrades code along with my mod and update it whenever it changes in the base game.
Code: Select all
include('multiplay/skirmish/gui.js");
include('multiplay/skirmish/upgrades.js");
include('multiplay/skirmish/victory.js");
Code: Select all
include('multiplay/skirmish/gui.js');
include('multiplay/skirmish/upgrades.js');
// implement my own victory conditions here