How to use the 'If'

karinchan999
03 Oct 2016, 06:58

I wanted to know when a player will pass by a certain page in Gamebook. Like for example there's a choice of 3. Page 1, page 2 and page 3. The player chooses page 2 (which is the way to a hidden room). How do use the 'If' option to show in a future page that the player achieved to find the hidden room? Thank you in advanced!


karinchan999
03 Oct 2016, 08:03

And what does "Error running script: Too many parameters passed to ShowMenu function- 4 passed, but only 2 expected" means?


hegemonkhan
03 Oct 2016, 10:30

the Game Book may also use the 'visited' Boolean Attribute, as the Text Adventure does, so for example:

if (Page45.visited) {
  msg ("Page45 HAS been visited: page45.visited = true")
} else {
  msg ("Page45 has NOT been visited: page45.visited = false")
}

if it doesn't have/use the 'visited' Boolean Attribute, you then have to create/set your own for each Page, which will thus be activate/run/executed (created/set), upon moving-to/selecting-and-going-to that Page during game play:

Page Type: [script] or [script+text]

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

set variable NAME_OF_PAGE.NAME_OF_YOUR_ATTRIBUTE = [EXPRESSION] true

and then, when/where-ever you need to, elsewhere, you can then do this (checking if that Boolean Attribute of yours is true: aka, you've been to that Page):

Page Type: [script] or [script+text]

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

if [EXPRESSION] NAME_OF_PAGE.NAME_OF_ATTRIBUTE

then,

-> add new script -> whatever Script(s) you want to add/do

there may be some other/more things needed to done, due to being a Game Book, if it doesn't work. But for now, see if it works.


also, not sure if this will help/make-sense, but you can take a look at it, and if you don't get it, I can help further with understanding it and helping you get what you want to do with your game, working:

http://textadventures.co.uk/forum/quest/topic/4656/help-with-dynamic-menus-for-conversations#30927
(this is for a Text Adventure, so some of the stuff doesn't apply for Game Book, such as the usage of 'Verbs' for the scripting)
(also, the above posts/thread's-topic, is on List/Dictionary Attributes, which are a bit more complex, so if you're still working on understanding the basic Attributes: Strings, ints --- Integers, and Booleans, then you might want to hold off on List/Dictionary Attributes)

let me know if you need help with understanding it and with setting it up for what you want to do with your game

as again, I'm probably continuing to confuse and overwhelm you more, which don't worry about... it takes quite some time to get all this stuff understood, coding is NOT easy to get, and you're doing very well, just give it patience, it takes quite some time to start getting your brain trained in this alien/un-natural way of thinking and with this coding stuff.


karinchan999
04 Oct 2016, 07:42

Alright thanks. I'll try it out and report back to you.


karinchan999
13 Oct 2016, 12:56

Okay, I tried it and it works! Thank you!