How does the object counter in Quest work?

0 votes
275 views
asked Jun 18 in Authoring by anonymous
edited Jun 18

Object Counter

I'm confused by this code. Does it count the number of child lines beneath a parent?
Does it return a numerical value based on the number of objects present?
How can one take the object counter's output and use it to activate different scripts?

Object counter 1

Object counter 2


commented Jun 18 by Alex (486 points)
What code....?
commented Jun 18 by anonymous
Object counter...
It's in the title ._.
commented Jun 18 by Alex (486 points)
The phrase "object counter" is not code. Where are you seeing it? I created Quest and I have no idea what you're referring to.
commented Jun 18 by anonymous
I'm sorry. It must be maddening dealing with someone who has no idea what you're talking about.

Here are some pics of what I'm thinking of but don't know what to call.

1 Answer

0 votes
answered Jun 19 by hegemonkhan (161 points)
edited Jun 19 by hegemonkhan

in the GUI~Editor, the 'object counter' refers to this stuff below:

in the GUI~Editor, you can choose these scripts:

run as script -> add a script -> variables -> 'increase~decrease object counter' Script

which will ONLY increase or decrease (addition~subtraction only) by 1

in code, it looks like this:

Object_name.Attribute_name = Object_name.Attribute_name + 1
~OR~
Object_name.Attribute_name = Object_name.Attribute_name - 1

example:

player.strength = player.strength + 1
~OR~
player.strength = player.strength - 1

if you want to increase~decrease by more than 1 and~or want to use multiplication~division, then you got to choose this script in the GUI~Editor:

(I don't know the GUI~Editor's drop down choices very well, so I just use the [expression] and type in the code directly, lol. So this is the way I'm going to show you to do it, if you don't want to use the [expression] drop down choice to type in the code directly, than you got to figure out what drop down choices you use, as I'm just not familiar with them, sorry)

run as script -> add a script -> variables -> 'set a variable or attribute' Script -> (see below, an example)

Multiplication Operator: *
Division Operator: /
Modulus (same as division, but it returns the remainder instead) Operator: %

set variable player.strength = [expression] player.strength * 7
~OR~
set variable player.strength = [expression] player.strength / 3
~OR~
set variable game.minutes = [expression] game.turns % 60

in code:

player.strength = player.strength * 7
~OR~
player.strength = player.strength / 3
~OR~
game.minutes = game.turns % 60

how math computational expressions work CONCEPTUALLY ONLY:

(this is not actual code syntax!)

(using addition as the example)

initial Value: player.strength = 0
addition expression: player.strength = player.strength + 5

old Value: player.strength = 0

player.strength(new) = player.strength(old:0) + 5
player.strength(new) = 0+5=5

new Value: player.strength = 5

old Value: player.strength = 5

player.strength(new) = player.strength(old:5) + 5
player.strength(new) = 5+5=10

new Value: player.strength = 10

old Value: player.strength = 10

player.strength(new) = player.strength(old:10) + 5
player.strength(new) = 10+5=15

new Value: player.strength = 15
commented Jun 19 by anonymous
Alright, this is good. I think I understand that part, but how does one use that value?
(Referring to the second image.)
To go off your example- let's say there's a rock blocking your path. You need 20 strength to move it. So you go do 'exercises' (+5 strength per exercise) and then you return to move the rock.

How do you call back the value of your strength to make that check?
commented Jun 19 by anonymous
Nevermind! This is closed. I figured it out, and it work beautifully
Thanks Monk
commented Jun 19 by hegemonkhan (161 points)
edited Jun 19 by hegemonkhan
Great job, I presume you discovered the 'if' Script ???

as the two SUPER SCRIPTS:

1. Attributes (the 'set a variable or attribute' Script)
and
2. the 'if' (if~else if~else) Script

especially when used together, let's you do 90% of everything that you want to do in~for your game making, hehe :D

----------

in code example:

    player.strength_integer = GetRandomInt (0,100)

    if (player.strength_integer >= 0 and player.strength_integer < 34) {
      player.strength_string = "weak"
    } else if (player.strength_integer >= 34 and player.strength_integer < 67) {
      player.strength_string = "average"
    } else if (player.strength_integer >= 67 and player.strength_integer <= 100) {
      player.strength_string = "strong"
    } else {
      msg ("You're not suppose to have strength less than zero or nor more than 100...")
    }
commented Jun 20 by anonymous
I haven't done much with attributes honestly, but I ALWAYS use the if script. Because things are always changing. An empty vase picks up water, becomes full. A lit fire burns out, becomes dark. A player jumps off a cliff that's too high, becomes dead.

I use 'if' and 'set object flag' all the time. Lots of flags.
This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...