textadventures / quest

Create text adventure games
http://textadventures.co.uk/quest
MIT License
303 stars 68 forks source link

Else function within container doesn't work (properly) #1096

Closed ReneFrijhoff closed 4 years ago

ReneFrijhoff commented 4 years ago

The IF THEN ELSE statement within a Container doesn't work properly.

<object name="coldwaterfaucet1">
  <inherit name="editor_object" />
  <inherit name="openable" />
  <attr name="feature_switchable" type="boolean">false</attr>
  <alias>cold water faucet</alias>
  <scenery type="boolean">false</scenery>
  <drop type="boolean">false</drop>
  <usedefaultprefix type="boolean">false</usedefaultprefix>
  <visible type="boolean">false</visible>
  <feature_container />
  <openscript type="script">
    if (not coldwaterfaucet1.isopen) {
      HelperOpenObject (coldwaterfaucet1)
      msg ("You open the cold water faucet and cold water is starting to run down.")
    }
    else {
      msg ("The cold water faucet is already open and the cold water is running.")
    }
  </openscript>
  <closescript type="script">
    if (not coldwaterfaucet1.isopen) {
      msg ("The cold water faucet is already closed.")
    }
    else {
      HelperCloseObject (coldwaterfaucet1)
      msg ("You close the cold water faucet.")
    }
  </closescript>
</object>

When using OPEN or CLOSE when it's already open or closed i.s.o. printing the custom message in the ELSE clause, it prints the default message.

Switching the IF and ELSE has no impact other then just the reverse happens: When using OPEN or CLOSE when it's already open or closed i.s.o. printing the custom message in the IF clause, it prints the default message.

ThePix commented 4 years ago

The openscript will only be used if Quest has already determined that the object is not open, so there is no situation when the else can apply.

All the openscript needs to do is print your custom message (in this situation); Quest will set the object to be in an open state.


  <openscript type="script">
      msg ("You open the cold water faucet and cold water is starting to run down.")
  </openscript>
  <closescript type="script">
      msg ("You close the cold water faucet.")
  </closescript>