Skip to content

Addition of getters and setters (for Chests, Enemies, Doors, Jumpers, Blocks, Switches, Destructibles)

TwilCynder requested to merge TwilCynder/solarus:getters_update into dev

Added some of the accessors listed in #1455. As stated in this issue, the final goal is to have access to every single property set when creating an entity. However, for this MR i only included the ones that seemed the most useful / relevant. This includes:

  • chest:get/set_opening_method() : returns or sets the opening method of this chest.
  • chest:get/set_opening_condition() : returns or set the item or savegame variable required to open this chest.
  • chest:is/set_opening_condition_consumed() : returns or sets whether the opening condition is consumed on opening.
  • All of the above for doors.
  • enemy:get_savegame_variable() : returns the savegame variable indicating whether this enemy is dead or not (or "" if this enemy is not saved) (simply returns the savegame_variable attribute)
  • door:get_savegame_variable() : returns the savegame variable that contains the state of this door (or "" if this door is not saved) (simply returns the savegame_variable attribute)
  • jumper:get_jump_length() : returns the jump length of this jumper. (simply returns the jump_length attribute)
  • block:get_direction() : if this block can only be pulled/push to a specific direction, returns it, if it can be moved in any direction returns -1. (simply returns the direction attribute)
  • switch:get_inactivate_when_leaving() : returns true is this switch is inactivated when the hero/block leaves it, or false if it's not. (simply returns the inactivate_when_leaving attribute) [was originally is_inactivate_when_leaving]
  • destructible:get_weight() : returns the weight of this destructible.

Also added the corresponding setter in some cases (when it seemingly didn't risk breaking something):

  • jumper:set_jump_length(length)
  • switch:set_inactivate_when_leaving(state) (defaults to true)
  • destructible:set_weight()

The corresponding MR in the doc repo will come soon.

Edited by TwilCynder

Merge request reports