Skip to content

Instantly share code, notes, and snippets.

@andythenorth
Created October 9, 2021 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andythenorth/64f3532ee4c148c5d7f9bf21ba36cda1 to your computer and use it in GitHub Desktop.
Save andythenorth/64f3532ee4c148c5d7f9bf21ba36cda1 to your computer and use it in GitHub Desktop.
switch(FEAT_INDUSTRIES, PARENT, increment_town_monthly_cycle_industry_counter,
[
LOAD_PERM(${get_perm_num("this_cycle_industry_counter")}) < count_industries_in_town()
?
STORE_PERM(
LOAD_PERM(${get_perm_num("this_cycle_industry_counter")}) + 1,
${get_perm_num("this_cycle_industry_counter")}
)
:
0
]) {
return;
}
@glx22
Copy link

glx22 commented Oct 9, 2021

replace https://github.com/OpenTTD/nml/blob/master/nml/ast/switch.py#L130-L131 with

   def is_read_only(self):
        for result in [r.result for r in self.body.ranges] + [self.body.default]:
            if result is not None and result.value is not None:
                if not result.value.is_read_only():
                    return false
        return self.expr.is_read_only()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment