Object Counters don't seem to work?

coldReactive
26 Apr 2018, 22:49

I looked at this question/answer document: http://docs.textadventures.co.uk/ifanswers/ifanswers.com/784/how-does-the-object-counter-in-quest-work.html

And noticed that the counter increase/decrease is meant to be along the lines of

player.deaths = player.deaths + 1

Unfortunately, when I try to use the actual "script" that says "increase object counter," nothing happens, even though the object "player.deaths" is an integer/etc. So I've had to replace all instances of counter increase with the above script instead. Is there an issue currently with this functionality of quest?


K.V.
26 Apr 2018, 23:15

Hello.

Test it with this in the script of a TEST command:

GUI View:

image


Code View:

IncreaseObjectCounter (game.pov, "deaths")
msg (game.pov.deaths)

image


I didn't even add the deaths attribute to the player object, and it works for me.


I always use game.pov instead of player because game.pov is whichever object is being controlled, which is usually player, but not always.


Here's the entire example game's code, if you'd like to load it into a new game to mess around with stuff:

<!--Saved by Quest 5.8.6689.24908-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Counters">
    <gameid>996009fa-513f-4743-a6c4-3fe72a1c681b</gameid>
    <version>1.0</version>
    <firstpublished>2018</firstpublished>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <isroom />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
  </object>
  <command name="test_cmd">
    <pattern>test</pattern>
    <script>
      IncreaseObjectCounter (game.pov, "deaths")
      msg (player.deaths)
    </script>
  </command>
</asl>

hegemonkhan
27 Apr 2018, 01:35

here's some help on learning to use quest and to code with quest, if you're interested:

http://textadventures.co.uk/forum/general/topic/ljjm32av4e2t9ot49k478g/help#710be61e-eae1-4af1-8363-520cc718ba1c

(see my 'attributes and if script usage guide' link for specifically help with scripting, scroll down to about the middle, to my 'attributes and if script usage, the two super scripts' section in it, though you may also want to read the part before it, as well as look at some of my other links first as well, like the 'quest code structure and coding basics' link)