counting the number of objects inside a container

I’m attempting to set up a system where the player can distribute attribute points between three stats. Right now I’m doing this by giving the player 30 tokens and three boxes, each box representing either Strength, Agility, or Intelligence.
Everything works well until I try to actually count how many tokens are in each box. I’m clearly doing something terribly wrong, but I’m not sure what.

This is the relevant bit of code (Strength, Agility, and Intelligence are the names of the containers):

To check for completion: Let S be a number equal to the number of attribute points in Strength; Let A be a number equal to the number of attribute points in Agility; Let I be a number equal to the number of attribute points in Intelligence; Let T be a number equal to S plus A plus I; If T equals 30: Now the player's Standard Strength is S; Now the player's Current Strength is S; Now the player's Standard Agiliy is A; Now the player's Current Agility is A; Now the player's Standard Intelligence is I; Now the player's Current Intelligence is I; say "A great bell rings out overhead."; Say "You haven't distributed all your ability points yet!".

I’ve also attempted to use ‘Let S be a number equal to the number of things in Strength’ and ‘Let S be a number equal to the number of things contained by Strength’, with the same results.
For all of my ‘Let’ attempts (except for Intelligence for some reason, Inform doesn’t seem to have a problem with that one), I get this:

[code]Problem. In the sentence ‘Let S be a number equal to the number of attribute points in Strength’ , I was expecting to read a value, but instead found some text that I couldn’t understand - ‘a number equal to the number of attribute points in Strength’.

I was trying to match one of these phrases:

  1. let (s - a new name) be (a number equal to the number of attribute points in strength - description of relations of values to values)

  2. let (s - a new name) be (a number equal to the number of attribute points in strength - name of kind)

  3. let (s - a new name) be (a number equal to the number of attribute points in strength - value)

  4. let (s - a temporary named value) be (a number equal to the number of attribute points in strength - value)

This was what I found out:

S = something unrecognised

a number equal to the number of attribute points in Strength = something unrecognised
[/code]

How do I get Inform count the number of things in a container and turn that number into something I can work with?

Also, I’m only really going with ‘distribute physical points to physical containers’ to represent stats because I don’t want to go with a straight up menu choice (“Do you want to play a fighter, rogue, or wizard?”) or make the player figure out points in their head. If anyone knows of a better way to do this I’m all ears.

Not tested, but does it work if you leave out the “a number equal to” phrase? I.e., just “Let S be the number of attribute points in Strength;”?

(You don’t need to define the kind of S, because it will automatically be set to the kind of whatever you make it equal to.)

That was actually the very first thing I tried. It gives me this error:

[code]Problem. In the sentence ‘Now the player’s Standard Strength is S’ , I was expecting to read a condition, but instead found some text that I couldn’t understand - ‘player’s Standard Strength is S’.

I was trying to match this phrase:

now (player’s standard strength is s - a condition)

This was what I found out:

player’s Standard Strength is S = something unrecognised
[/code]

… Which now that I’m looking at it again, is actually complaining about a different section of code.
… I broke my code trying to fix it… >.<

Thank you for the help, VictorGijsbers. :slight_smile:

Does it help if you change “player’s Standard Strength” to “Standard Strength of the player”? Like Victor, I’m just guessing.

It works now! Here’s how my code ended up:

To check for completion: Let S be the number of attribute points in Strength; Let A be the number of attribute points in Agility; Let I be the number of attribute points in Intelligence; Let T be S plus A plus I; If T is 30: Now the Standard Strength of the player is S; Now the Current Strength of the player is S; Now the Standard Agility of the player is A; Now the Current Agility of the player is A; Now the Standard Intelligence of the player is I; Now the Current Intelligence of the player is I; say "A great bell rings out overhead."; If T is not 30: Say "You haven't distributed all your ability points yet!".

Thanks for the help! :smiley: