How to put "Skill Requirements" before entering a certain level (Gamebook)
jessitayylor
15 Mar 2019, 08:12Returning member here. Forgot the password for my previous account after being MIA. Sooo, this is my question as I once again dive into codes to make a game.
How do I put a "Skill Requirement" that the player needs before entering a certain level or location in Gamebook?
For example, the player has Dance Level = 0. So the player won't be able to see a text that says "There is a secret door here.", it will not be revealed unless player has 1 or more value.

DarkLizerd
15 Mar 2019, 19:10With Text Adventure, You could make the exit invisible, then, where you have code that does:
dance=dance +1... (you gained a level)
make the exit visible.
But, you would need to name the exits.
Gamebook should do something similar.
jessitayylor
16 Mar 2019, 09:42How do I do that in Gamebook?

DarkLizerd
16 Mar 2019, 18:09I'm not sure you can.
hegemonkhan
17 Mar 2019, 08:52I'm not familiar with the Game Book, but you can certainly do it:
// creating the 'dance' Integer Attribute on the 'player' Object, and setting it's initial Value:
[first/initial Page] Page Object -> 'Page' Tab -> Page Type: [text + script] or [script]
add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)
set variable player.dance = [EXPRESSION] 0
// for the Page that you'd use for when you want to change/increase the 'dance' Attribute:
[WHATEVER] Page Object -> 'Page' Tab -> Page Type: [text + script] or [script]
add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)
set variable player.dance = [EXPRESSION] player.dance + 1
// for the Page that will then take you to the new page or not, based on your 'dance' Integer Attribute:
[WHATEVER] Page Object -> 'Page' Tab -> Page Type: [text + script] or [script]
add new script -> 'scripts' section/category -> 'if' Script -> (see below, an example)
if [EXPRESSION] player.dance >= 1
-> then -> add new script -> [the move player to page script / don't know the GUI/Editor that well, especially not the Game Book stuff]
else
-> add new script -> 'print a message' Script -> Print [EXPRESSION] "Your 'dance' Integer Attribute needs to be 1 or more, in order to go to PageX"
jessitayylor
17 Mar 2019, 11:32Hello HK.
I tried the first two parts you said about setting up the variables and the change/increase the 'dance' attribute.
But when I arrived at the IF part, things didn't work well.
Error running script: Error compiling expression 'player.dance =< 1': SyntaxError: Unexpected token "<"; expected one of "-", <INTEGER>, <REAL>, <STRING_LITERAL>, "True", "False", <HEX_LITERAL>, <CHAR_LITERAL>, "null", <DATETIME>, <TIMESPAN>, "(", <IDENTIFIER>, "if", or "cast"Line: 1, Column: 23
This error appears.
This is what I did.
if (player.dance >= 1) {
msg ("Your 'dance' Integer Attribute needs to be 1 or more, in order to go to PageX")
}
else if (player.dance =< 1) {
msg ("You can enter to this pageX")
MovePlayer (PageX)
}
How do I fix it?
hegemonkhan
17 Mar 2019, 20:07(filler for getting my edited post, updated/posted)
(again, filler for getting my edited post, updated/posted)
(again, filler for getting my edited post, updated/posted)
(again, filler for getting my edited post, updated/posted)
ah, welcome to coding/programming, you must have ZERO typos/mistakes... you must learn to be a "nazi grammer (syntax)" person, lol
in your 'else if', you must have the '=' symbol be on the right side (its just programmed this way to recognize it):
CORRECT:
'greater than or equal to' Operator: >=
'lesser than or equal to' Operator: <=
if (player.dance >= 1) {
msg ("Your 'dance' Integer Attribute needs to be 1 or more, in order to go to PageX")
}
WRONG:
'greater than or equal to' Operator: =>
'lesser than or equal to' Operator: =<
else if (player.dance =< 1) {
msg ("You can enter to this pageX")
MovePlayer (PageX)
}
the fix:
if (player.dance >= 1) {
msg ("Your 'dance' Integer Attribute needs to be 1 or more, in order to go to PageX")
}
else if (player.dance <= 1) {
msg ("You can enter to this pageX")
MovePlayer (PageX)
}
However.... you also got a logic error...
you got both conditions with the '=' (equal to), do you understand this logic error?
what happens if, 'player.dance = 1', ???
does it do this?: msg ("Your 'dance' Integer Attribute needs to be 1 or more, in order to go to PageX")
or
does it do this?: msg ("You can enter to this pageX") MovePlayer (PageX)
the (best) fix:
(you don't need the 'else if' at all in this case, and let's simplify it even more --- can you see/understand how it was simplified even more?)
if (player.dance > 0) {
msg ("Your 'dance' Integer Attribute needs to be 1 or more, in order to go to PageX")
}
else {
msg ("You can enter to this pageX")
MovePlayer (PageX)
}
oops... just saw/realized one more logic-conceptual issue that you got.... lol
(can you see/understand what your mistake was?)
THE FINAL BEST FIX:
if (player.dance > 0) {
msg ("You can enter to this pageX")
MovePlayer (PageX)
}
else {
msg ("Your 'dance' Integer Attribute needs to be 1 or more, in order to go to PageX")
}
// or, an example of alternative design (does the same thing):
if (player.dance < 1) {
msg ("Your 'dance' Integer Attribute needs to be 1 or more, in order to go to PageX")
}
else {
msg ("You can enter to this pageX")
MovePlayer (PageX)
}
OPERATORS:
Assignment Operator: =
storing the final Value on the right side of the '=' into the VARIABLE on the left side of the '='
player.strength = 100
the '100' final Value is STORED INTO the 'strength' Integer Attribute of the 'player' Player Object
player.strength = 30 + 70
the final Value of '100' (30+70) is STORED INTO the 'strength' Integer Attribute of the 'player' Player Object
x = 100
the '100' final Value is STORED INTO the 'x' Integer Variable
x = 20 + 10
the '30' (20+10) final Value is STORED INTO the 'x' Integer Variable
WRONG:
100 = x
100 = player.strength
unlike in math, it's just not programmed to understand this reversed syntax
Arithmetic Operators:
Addition Operator: +
Subtraction Operator: -
Multiplication Operator: *
Division Operator: /
Modulus (division, but it gets/finds/returns the REMAINDER) Operator: %
Comparison Operators:
equal to: =
quest is able to parse/know when you want 'assignment' operator/operation vs the 'equal to' comparison operator/operation, but usually in other programming languages the operators are separated:
Assignment: =
equal to: ==
'not equal' Operators:
VARIABLE <> FINAL_VALUE
// or:
not VARIABLE = FINAL_VALUE
'greater than' Operator: >
'lesser than' Operator: <
'greater than or equal to' Operator: >=
'lesser than or equal to' Operator: <=
String Operators:
Concatenation Operator: +
quest is able to know/parse between concatenation and addition operators/operations
an example of concatenation (and assignment too):
game.greeting = "Hi"
msg (game.greeting)
// output: Hi
game.greeting = game.greeting + ", how are you?"
msg (game.greeting)
// output: Hi, how are you?
game.greeting = game.greeting + " My name is HK."
msg (game.greeting)
// output: Hi, how are you? My name is HK.
game.greeting = game.greeting + " What is your name?"
msg (game.greeting)
// output: Hi, how are you? My name is HK. What is your name?
conceptually:
addition vs concatenation:
5 + 5 = 10
55 + 55 = 110
"5" + "5" = "55"
"55" + "55" = "5555"
5 + "5" = ERROR
"5" + 5 = ERROR
"mama" + 5 = ERROR
5 + "mama" = ERROR
"mama" + "mia" = "mamamia"
"mama" + "5" = "mama5"
"5" + "mama" = THIS_COULD_BE_AN_ERROR_(IT_DEPENDS:_IF_ITS_USED_AS_A_NAME_IT_CAN'T_START_WITH_A_NUMBER_IT_MUST_START_WITH_AN_ALPHETIC_LETTER_OR_MAYBE_IT_CAN_ALSO_START_WITH_AN_UNDERSCORE_AS_WELL)
// create ("orc5") // NO error
// create ("5orc") // ERROR!
// create ("_orc5") // maybe no error (never tried to see if quest accepts underscores as the first character of a name or not, often programming languages do allow for an underscore as the start of a name)
// create ("_5orc") // maybe no error (never tried to see if quest accepts underscores as the first character of a name or not, often programming languages do allow for an underscore as the start of a name)
"mama" + " " + "mia" = "mama mia" // "mama" + "[SPACE]" + "mia" = "mama[SPACE]mia"
the '[SPACE]' is a character/symbol, just like 'a' is a character/symbol
"mama " + "mia" = "mama mia" // "mama[SPACE]" + "mia" = "mama[SPACE]mia"
"mama" + " mia" = "mama mia" // "mama" + "[SPACE]mia" = "mama[SPACE]mia"