Skip to content

Commit

Permalink
Add: optimise random switches
Browse files Browse the repository at this point in the history
  • Loading branch information
glx22 committed Oct 17, 2020
1 parent 7f62081 commit aede745
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nml/expression/spritegroup_ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def reduce(self, id_dicts = [], unknown_id_fatal = True):
len(spritegroup.body.ranges) == 0:
generic.print_warning("Block '{}' returns a constant, optimising.".format(spritegroup.name.value), self.pos)
return spritegroup.body.default.value
elif isinstance(spritegroup, switch.RandomSwitch) and len(spritegroup.choices) == 1:
generic.print_warning("Block '{}' returns a constant, optimising.".format(spritegroup.name.value), self.pos)
return spritegroup.choices[0].result.value
return self

def supported_by_action2(self, raise_error):
Expand Down

0 comments on commit aede745

Please sign in to comment.