counters [solved]

so, this has probably been asked before, but being a newbie with scripts, i need it explained in this specific situation. ;A;

so for Gamebook mode.
basically, i'm making a game where the player's decisions affect an invisible morale number that is linked to a character. when the player makes decisions that please the character, they get +1 morale. i want to use this 'morale' to make future decisions available or not-available to make. so, if you make enough good decisions, for example get +30 morale, an otherwise unavailable decision becomes available in a future instance.

the only thing i've tried is using the counter script, and trying to make it increase and decrease between pages, but i'm probably not doing it right. help?


You should be able to do this with Object Counter function, use Player as the Object, call it morale and add one to it when the player makes the right decision. There is good help in the tutorial about using Object Counters and Flags, only just learnt them myself and a they're a real game changer.


If that wasn't clear, you need to use an If function on the decision the player makes then run Object Counter depending on decision made by player


Hey, thanks! I'm only wondering how you can do that in Gamebook mode? I can't seem to find anything like that. Dx


Ah, sorry, should have read you post more carefully. I've never used Gamebook mode.


Hahah it's ok, Gamebook mode seems limited I think ;_; But I'll wait in case someone knows \m/


you need to create your Attribute(s) first (usually you use your very first page to do this), before you can then use them:

'whatever' Page -> 'Page' Tab -> Page Type: [script] or [script + text] -> (see below)

add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = [EXPRESSION] VALUE_OR_EXPRESSION

in the Game Book, you only got two Objects that you can add Attributes to (unlike the Text Adventure):

  1. the 'game' Game Settings Object
  2. the 'player' Player Object

so, replace my 'NAME_OF_OBJECT' with either: 'player' or 'game', so it looks like this:

set variable game.NAME_OF_ATTRIBUTE = [EXPRESSION] VALUE_OR_EXPRESSION
or
set variable player.NAME_OF_ATTRIBUTE = [EXPRESSION] VALUE_OR_EXPRESSION

next, give your Attribute a name, which will replace my 'NAME_OF_ATTRIBUTE', for example using my own descriptive naming/labeling system/convention:

'npc_1_morale_integer_attribute'

set variable game.npc_1_morale_integer_attribute = [EXPRESSION] VALUE_OR_EXPRESSION
or
set variable player.npc_1_morale_integer_attribute = [EXPRESSION] VALUE_OR_EXPRESSION

the name of the Attribute has nothing to do with the type of the Attribute, I just like to be descriptive with it, as it works well for me, as I can just look/read its name, and know what the Attribute is and for, and it allows for keeping names unique, which they must be, as the name is the ID for quest, for an example of why I like my this labeling/naming system/convention of mine: player.strength_integer_attribute = 100, and, player.strength_string_attribute = "strong"

now, we give your Attribute (for what you want to do, you want your Attribute to be an Integer/int Attribute by giving it...), a Value (which we want the Value to be an Integer/int Value: etc,-100, -9, -1, 0, 1, 3, 100, etc), so for what you want, we'll give it an initial/starting Value of: 0, see below:

(quest is able to parse the type of Value, which it uses to determine the type of Attribute)

set variable game.npc_1_morale_integer_attribute = [EXPRESSION] 0
or
set variable player.npc_1_morale_integer_attribute = [EXPRESSION] 0


next, for whatever/whenever the events/actions/decisions/choices (scripting) in your game that you want to increase this 'morale' Integer Attribute, you do use the same script ('set a variable or attribute' Script), but with a slight change:

'whatever' Page -> 'Page' Tab -> Page Type: [script] or [script + text] -> (see below)

add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = [EXPRESSION] NAME_OF_OBJECT.NAME_OF_ATTRIBUTE OPERATOR VALUE_OR_EXPRESSION

so, for example:

set variable game.npc_1_morale_integer_attribute = [EXPRESSION] game.npc_1_morale_integer_attribute + 1
or
set variable player.npc_1_morale_integer_attribute = [EXPRESSION] player.npc_1_morale_integer_attribute + 1

'counters' are Integer Attributes, which you increase (aka addition, and usually) by 1, but you can do any operation (addition: +, subtraction: -, multiplication: *, division: /, and modulus which is division operation but you're finding/getting the remainder: %, or the string operation of concatenation: +) and any Value, using this 'set a variable or attribute' Script.


lastly, for whatever/whenever the events/actions in your game, you use the 'if' Script:

add new script -> 'scripts' section/category -> 'if' Script -> (see below)

if [EXPRESSION] CONDITION:EXPRESSION_OR_BOOLEAN_VALUE/ATTRIBUTE

for an example (in code):

(let me know if you need help with doing this with the GUI/Editor)

if (game.npc_1_morale_integer_attribute > 66) {
  // whatever script(s)
}
else if (game.npc_1_morale_integer_attribute > 33) {
  // whatever script(s)
}
else {
  // whatever script(s)
}

-------------

String Attribute comparison example:

game.npc_1_morale_string_attribute = "high" // or: "medium" // or: "low"

if (game.npc_1_morale_string_attribute = "high") {
  // whatever script(s)
}
else if (game.npc_1_morale_string_attribute = "medium") {
  // whatever script(s)
}
else if (game.npc_1_morale_string_attribute = "low") {
  // whatever script(s)
}

-----------

Boolean Attribute example:

game.orc_dead_boolean_attribute = false // or: true (though you usually don't want your monster/orc to start out logically dead, lol)

if (game.orc_dead_boolean_attribute) { // if TRUE
  // script(s)
}
else { // if FALSE
  // script(s)
}

or the opposite (via using negation: the 'not' OPERATOR):

if (not game.orc_dead_boolean_attribute) { // if FALSE
  // script(s)
}
else { // if TRUE
  // script(s)
}

here's a link of my guide on Attributes and the 'if' Script usage:

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk

(the guide is written for Text Adventure, but Attributes and the 'if' Script usage is the same, only the methods of accessing them differs)


P.S.

if you haven't noticed...

in Game Book, you only got two Objects that you can add Attributes to:

'player' and 'game'

but, notice how I've shown how you can cheat around this, giving the illusion (same effect) as/of if you had more Objects, examples (in code):

game.npc_1_morale_integer_attribute
game.npc_2_morale_integer_attribute
game.npc_3_morale_integer_attribute
game.monster_1_morale_integer_attribute
game.monster_2_morale_integer_attribute
game.monster_3_morale_integer_attribute
game.monster_1_current_life_integer_attribute
game.monster_2_current_life_integer_attribute
game.monster_3_current_life_integer_attribute

and/or (though using 'game' is more logical aesthetically than using 'player', but there's no practical/actual difference):

player.npc_1_morale_integer_attribute
player.npc_2_morale_integer_attribute
player.npc_3_morale_integer_attribute
player.monster_1_morale_integer_attribute
player.monster_2_morale_integer_attribute
player.monster_3_morale_integer_attribute
player.monster_1_current_life_integer_attribute
player.monster_2_current_life_integer_attribute
player.monster_3_current_life_integer_attribute


holy crap thanks hegemonkhan! ^^ i'll start messing around with this and report back if i've got any trouble. thanks again <3


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums