Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Conditional raws  (Read 590 times)

Dirst

  • Bay Watcher
  • On hiatus
    • View Profile
Conditional raws
« on: February 20, 2014, 11:10:15 am »

I think this would be reasonably straightforward to implement, but I'd like to hear from the modders out there if this would actually be useful.

My idea is to include conditional tags inside the raws, basically giving the player a second page of options within world generation.

In the [WORLD_GEN] token one needs to call out each variable, its text for the worldgen screen, its default value and its possible values.

[PLAYER_CHOICE:GOOD_DWARVES:Dwarves settle in Good biomes:2:Yes:No]
[PLAYER_CHOICE:GOBLIN_AGGRESSION:Goblin aggression:3:Low:Medium:High:Fanatic]


The choices set up variables that can then be used later, with defaults of 2 and 3 respectively.  If the player chose "Yes" and "Fanatic" then GOOD_DWARVES would have a value of 1 and GOBLIN_AGGRESSION would have a value of 4.

Just before worldgen, while the raws are being copied into the new region's folder, they are processed in a SED-like manner to include or exclude tokens based on the variables.  For example:

[IF:GOBLIN_AGGRESSION:1:[PROGRESS_TRIGGER_POPULATION:5]]
[IF:GOBLIN_AGGRESSION:2:[PROGRESS_TRIGGER_POPULATION:4]]
[IF:GOBLIN_AGGRESSION:3:[PROGRESS_TRIGGER_POPULATION:3]]
[IF:GOBLIN_AGGRESSION:4:[PROGRESS_TRIGGER_POPULATION:2]]


If the condition is met, the process strips off the wrapper and processes it again in case of nested IFs, eventually leaving a tag.  If the condition is not met, the line is not copied over at all.  If DF allows repeated tags with last-in-wins, then this is even backwards compatible. Have an unconditioned tag first as a default and just expect a bunch of errors in the log.

A version that would break backwards compatibility and make raw processing a bit slower would be:

[IF_START:GOBLIN_AGGRESSION:1]
any number of tags, maybe changing the types of weapons or mounts available to Goblins
[IF_END]

These choices probably need to be very early in the [WORLD_GEN] token because conditional worldgen parameters would be a good use for this feature.  Or at least I think it'd be useful.

Do the modders out there think this would add value?
Logged
On hiatus. Feel free to adopt or update:
(0.42 & 0.43) The Earth Strikes Back! v2.15 - Pay attention...  It's a mine!  It's-a not yours!
(0.42 & 0.43) Appearance Tweaks v1.03 - Tease those hippies about their pointy ears.
(0.42 & 0.43) Accessibility Utility v1.04 - Console tools to navigate the map