Anyone know the "Avast, Ye Mateys!" Quest game by peter123? Because I was wondering how you get counters and variables like that in a gamebook!

I was wondering if anyone had instrictions for how to display counters and whatnot like peter123 does in a gamebook. Is it even possible?
I'm definitely not very code savy...


It's definitely possible!

In the text area, use curly braces, like so:

"It'll cost ya {game.pricewater} bucks!" she said.

Or:

Your Stats:
Strength: {player.STR}
Dexterity: {player.DEX}
Constitution: {player.CON}
Etc...

In the above examples, 'game.pricewater', 'player.STR' etc are attributes that you can use as variables.
Counters work similarly, but are simpler. They only take numerical values:

Your Kill List:
Skeletons: {counter.skeletons}
Dragons: {counter.dragons}
Beholders: {counter.beholders}

You can also use conditional tests, like 'if-statements':

{if player.cash<game.pricewatch:Sorry, you cannot afford the watch.}{if player.cash>=game.pricewatch:Sure you can buy it!  ${game.pricewatch} please!}

You can also used fixed values in those if statements:

{if player.cash<150:Sorry, you cannot afford the watch.}

Oh man, thank you!
But, concerning attributes, I keep hearing a lot about them, but how do I actually add them in? In the drop down tab for adding new scrip, there doesn't seem to be any way to discern between attribute or variable. Do I have to type anything special in the expression portion?


quest has 3 types of VARIABLES (keeping this simple):

VARIABLES:
-> (1) Variables
-> (2) Attributes
-> (3) Parameters/Arguments: deals with using Functions, Commands, and Object+Script_Attribute+Delegate

I'm not getting into Parameters/Arguments in this post though, too tired/lazy... lol


for new to coding people, use 'Attribute' VARIABLES, until you understand/learn the difference between 'Attribute' (global/Objects' VARIABLES) and 'Variable' VARIABLES (local/non-Object VARIABLES):

'WHATEVER' Page -> 'Page' Tab -> Page Type: [script] or [script + text]

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


'Attribute' VARIABLES:

set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = [EXPRESSION] VALUE_OR_EXPRESSION

examples:

set variable player.alias = [EXPRESSION] "HK"
set variable game.introduction = [EXPRESSION] "Welcome to my game, I hope you enjoy it, muwhaha!"
set variable Page1.visited = [EXPRESSION] true
set variable player.strength = [EXPRESSION] 100
set variable game.state = [EXPRESSION] 0
set variable game.orc_dead = [EXPRESSION] false

create ("Page2")
set variable Page2.objectives_completed = [EXPRESSION] false

example of a complex expression: arithmetic operations, 'addition: +, multiplication: *, and division: /', using Attributes, 'player.weapon_damage and player.strength', and a literal/direct Value, '100' :

set variable player.strength = [EXPRESSION] GetRandomInt (0,100)
set variable player.weapon_damage = [EXPRESSION] GetRandomInt (1,50)
set variable player.damage = [EXPRESSION] player.weapon_damage + player.weapon_damage * player.strength / 100

example of a String List 'Attribute' VARIABLE:

set variable game.race_list = [EXPRESSION] NewStringList ()
list add (game.race_list, "human")
list add (game.race_list, "dwarf")
list add (game.race_list, "elf")
list add (game.race_list, "gnome")
list add (game.race_list, "halfling")
list add (game.race_list, "giant")

// or [ the 'Split' Script/Function below ONLY works for String Lists, whereas, for Object Lists you must use the above method, via using 'NewObjectList ()' and 'list adds']:

set variable game.race_list = [EXPRESSION] Split ("human;dwarf;elf;gnome;halfling;giant", ";")

.

set variable player.race = StringListItem (game.race_list, GetRandomInt (0, ListCount (game.race_list) - 1))

// or (the below is a helper Script/Function that does the above for you, that Pixie added into his new versions of quest):

set variable player.race = PickOneString (game.race_list)


'Variable' VARIABLES:

set variable NAME_OF_Variable = [EXPRESSION] VALUE_OR_EXPRESSION

examples:

set variable alias = [EXPRESSION] "HK"
set variable introduction = [EXPRESSION] "Welcome to my game, I hope you enjoy it, muwhaha!"
set variable visited = [EXPRESSION] true
set variable strength = [EXPRESSION] 100
set variable state = [EXPRESSION] 0
set variable orc_dead = [EXPRESSION] false

set variable objectives_completed = [EXPRESSION] false

example of a complex expression: arithmetic operations, 'addition: +, multiplication: *, and division: /', using Variables, 'weapon_damage and strength', and a literal/direct Value, '100' :

set variable strength = [EXPRESSION] GetRandomInt (0,100)
set variable weapon_damage = [EXPRESSION] GetRandomInt (1,50)
set variable damage = [EXPRESSION] weapon_damage + weapon_damage * strength / 100

example of a String List 'Variable' VARIABLE:

set variable race_list = [EXPRESSION] NewStringList ()
list add (race_list, "human")
list add (race_list, "dwarf")
list add (race_list, "elf")
list add (race_list, "halfling")
list add (race_list, "giant")

// or [ the 'Split' Script/Function below ONLY works for String Lists, whereas, for Object Lists you must use the above method, via using 'NewObjectList ()' and 'list adds']:

set variable race_list = [EXPRESSION] Split ("human;dwarf;elf;gnome;halfling;giant", ";")

.

set variable race = StringListItem (race_list, GetRandomInt (0, ListCount (race_list) - 1))

// or (the below is a helper Script/Function that does the above for you, that Pixie added into his new versions of quest):

set variable race = PickOneString (race_list)


You're welcome, Paper!

"...but how do I actually add them in?"

Good question! I'm kind of old school as far as my VERY limited coding skills go, so I like to declare my variables on the very first page of the game, 'Page1' (It doesn't have to be called that, it could be called "START" or anything you like). To me, Quest seems very forgiving, in that it never complains or throws errors no matter where I foolishly declare the variables.

So for a game like an RPG, I recommend declaring the variables (attributes) early. You do this by making your start page (the page with the 'player' object under it) able to run scripts. Change the 'type' of the page from 'Text' to 'Script' or 'Script + Text'. I recommend just 'Script' type because it's simple and non-interactive with the player. Now just click on the 'add script' button. There are several different categories, 'Output', 'Pages', 'Scripts', 'Variables' and 'Effects'. The one you want is under 'Variables'. It's called 'Set a variable or attribute'.

When you click that, it inserts the script as a line into the GUI, and the cursor is blinking in the field where you enter the name of the variable. Here is where you have to remember to attache the variable to a game object, like 'player' or 'game'. But don't worry, it's easy! Just type "player." (no quotes and keep the period) and the name of the variable, say, "player.strength". When we read this, we say, "Player dot strength". You could also attach it to the game object: game.strength, but that could get confusing.

After the 'expression' drop-down (ignore this for now), there's another field where you actually set the value. In this field, you can set the variable to a value of your choice. If every game starts off with a strength of 12, then jut type, "12". If you want to generate a random number, type "GetRandomInt(#,#)" and replace the number symbols with a low end of the range before the comma and the high end after the comma. Say you want to simulate rolling three six-sided dice, you would type:

GetRandomInt(1,6) + GetRandomInt(1,6) + GetRandomInt(1,6)

It's that easy! And remember, do NOT put scripts under the 'game' object, unless you want them to run EVERY time the player makes a move. Actually, they run every time the 'player' object is moved, but ignore that fact for now.


^well done, JC, well done. :)


Thank you, XanMag!

You guys are all so very helpful that I got caught up in the spirit of this place, LOL.


Log in to post a reply.

Support

Forums