need some help about Gamebook

karinchan999
26 Sept 2016, 13:00
  1. How do I make a 'return to game' button in Gamebook? For example I entered a certain page (like a backpack the the character carries around) and when the player opens the backpack, he/she goes back to the game. I can use links but if the player is to open the backpack in every page then the link will lead him/her to the link I set up the first time. How do I deal with this?

  2. How do I create a menu? And a save/load game button? Is there some code like the one used to link stuff like {page:page name: name display}? I find it easier to understand than going to the Script thing. Although I'm working on it.

I hope someone can help me out. Thank you in advanced!


hegemonkhan
27 Sept 2016, 03:21
to do scripting in the GameBook:

'whatever' Page -> Page Type: [script] or [script+text] -> add new script -> (select/decide and set it up)

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

1. you got to save/store the Page you're currently on into a VARIABLE, before you change/move to the 'backpack' Page, so you can then use that VARIABLE to return to the Page you were on, before you moved to the 'backpack' Page:

(this is a big programming trick, storing/saving the old/previous whatever, which is used/useful for doing many different things)

game.previous_parent_object_attribute = player.parent
// then, the code that moves the player to the new Page, I'm not sure how the Page Linking works with GameBook, but in a Text Adventure, there's the 'MoveObject(MOVING_OBJECT, DESTINATION_OBJECT)' Function/Script, or you can just use the 'parent' Object Attribute, as well.

You might want to have the storing/saving of the previous Page happen every time, which I believe you can do via using this:

// 'game' Game Object -> 'Scripts' Tab -> 'onenterpage' (or whatever it is called) Script:

game.previous_parent_object_attribute = player.parent

instead of within the Page Linking scripting

and then for when/where you want to return, you'd use:

player.parent = NAME_OF_THE_VARIABLE_USED_TO_STORE/SAVE_THE OLD/PREVIOUS_PAGE_LOCATION
// so using our example: player.parent = game.previous_page_object_attribute

so for example, your 'backpack' Page, would only have a single Page Link, using that script above, for returning to your previous Page before moving to your 'backpack' Page.

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

2. I'm not sure if you can use the built-in menus... maybe the inline/text-box menu: 'ShowMenu(PARAMETERS)', but not sure.

you can always create your own custom inline/text-box menu, via using 'run as script -> add new script', for creating the displayment of the menu, and then for getting the person's typed-in input (or clicking on a blue hyperlink), then using the 'if' Script to match the person's inputs (typed in or clicked on blue hyperlink), and scripting what to do for them.

here's a good example of using the built-in a menu using typed-in input:

http://docs.textadventures.co.uk/quest/guides/character_creation.html

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

As to the specifics, that gets into more detail/explanation, which you probably will need help with, unless you can figure it out on your own.

karinchan999
27 Sept 2016, 04:03

Okay I tested it then I got lost all the way.
-I change page type to "Script + Text". Add a script "set variable or attribute" so player.parent = "Page 1".

I don't want to ask for more but can you teach me a step by step on how to perform this? (The saving/loading and menu can wait some other time, I want to focus on the 'return to last page' button for now). Thank you again!


hegemonkhan
27 Sept 2016, 20:57

arg... I can't get the built-in Page Linking 'options' String Dictionary Attribute to work right...

I need more time to work on it, but can't right now (school and its school work)


hegemonkhan
27 Sept 2016, 23:34

(why I'm having trouble, as seen by my previous post / lack of an answering post for karinchan)

@ Pixie or Jay or who-ever knows GameBook/quest well:

can you create the built-in 'options' Dictionary, via using 'set', ??? and if so, how, ??? is the 'options' Dictionary a String, Object, or Script Dictionary ??? How does the Page Linking work ???

is there any way to add an entry/item to the 'options' Dictionary, using a VARIABLE (dynamic) for its 'key string' (Page's string name or name ID --- GameBook seems funky: it needs the name ID/inference but requires it as a String Data/Attribute type) ???


as, just creating a hyperlink in the text box during game play, is a bit shoddy and a bit of code work to get it working (and thus harder to help karinchan through it via using the GUI~Editor), as the GameBook is more limited in its capabilities/functions/etc

or worse, manually putting in the needed scripting on every single Page...

surely, there's hopefully some ways to apply scripting to every Page... there is the 'game.script', but it's a bit messy and confusing, ...

... is there the special 'changed' Scripts for the 'player' or 'game' Attributes changing ??


karinchan999
28 Sept 2016, 05:52

That's the part that I don't know how to work out. The whole attribute and string data.
When I open the Add Script I see stuff like the Output, Script, Pages, Variables, Effects. And everything under Variables is confusing. But I try to experiment. And yeah you got me there, I don't know how to use the Dictionary as String, Object or whatever.

How do I set something as a variable? So I can do what you said here;
"you got to save/store the Page you're currently on into a VARIABLE, before you change/move to the 'backpack' Page, so you can then use that VARIABLE to return to the Page you were on, before you moved to the 'backpack' Page:"

Once I set the 'page' I'm in into a variable, then I can go back to it even after i open the 'backpack' page. If I were to repeat the same process on every page just to convenience the player to opening the backpack page, its okay. I'll work it out.

Did I understand that part right?


hegemonkhan
28 Sept 2016, 08:56

the backpage/returning to previous page, is much more complicated ... I'm just confused about how to do it in what would be an easy way to help you with doing it (I can help you in a less-elegant way, but it'd be more difficult/confusing for you and I in trying to explain/guide you through it. What I'm talking about with my problem, doesn't match up with your buttons/options/drop-downs/etc in the GUI~Editor, I'm talking more at the quest coding level, which doesn't really match up with that stuff you know about in the GUI~Editor) ... so, let me help you just with basic/general Attribute usage for now:


anyways, for Attribute usage (adding/creating/setting/changing/altering/re-setting/etc):

generally, you got/want/need Attributes (with initial Values) that you want/need to have existing at the start of your game, which in the GameBook, is done via the:

'game' Game Object -> 'Scripts' Tab -> 'start' Script -> (see below: add new script ->  blah blah blah)

otherwise, at any time or any where/means, via your Page's scripting (and/or which can optionally call upon your Functions, which hold your scripting), you can have a new Attribute (with an initial Value) be created and/or change an existing Attribute's Value:

'whatever' Page Object -> ( run as script / Page Type: [script] or [script+text] ) -> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

I am going to tell you to use the '[EXPRESSION]' option (which let's me/you-lol code in what scripting/action/etc you want directly --- my way of cheating past not knowing the GUI~Editor and its script options, lol), as I don't know the GUI~Editor's script options, but if you do, then you can click on the specific [xxx] script options

set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = [EXPRESSION] VALUE_OR_EXPRESSION
// do note/see that there IS a dot/period separating the 'NAME_OF_OBJECT' and the 'NAME_OF_ATTRIBUTE'
// this dot/period is required/very important, as it's the code way of telling quest that, that that Attribute will be added into/inside/(contained)-within that Object, which is what makes it an Attribute VARIABLE, which is your 'bread', lol. (The 'if' Scripts is/are your 'butter', lol)

However, in GameBook, you only have two Objects (we'll not get into messing with the Page Objects' Attributes for now), for (adding/creating) your own/custom Attributes:

the 'game' Game Object and the 'player' Player Object

so, replace my 'NAME_OF_OBJECT' with either:

game
~OR~
player

set variable game.NAME_OF_ATTRIBUTE = [EXPRESSION] VALUE_OR_EXPRESSION
~OR~
set variable player.NAME_OF_ATTRIBUTE = [EXPRESSION] VALUE_OR_EXPRESSION

next, replace my 'NAME_OF_ATTRIBUTE', with whatever you want to call/name/label-as your new Attribute or use an existing Attribute's name if you want to change/alter/re-set its Value, for example (what will be my 'strength' Integer Attribute with its new Value of '100'):

set variable game.strength = [EXPRESSION] VALUE_OR_EXPRESSION
~OR~
set variable player.strength = [EXPRESSION] VALUE_OR_EXPRESSION

then, replace my 'VALUE_OR_EXPRESSION' with whatever you want (depends upon what Attribute Type you want it to be, of course --- what you put in for my 'VALUE_OR_EXPRESSION' determines what Attribute Type your Attribute will be --- quest is programmed to do b able to do this), for example (what will be my 'strength' Integer Attribute with its new Value of '100'):

set variable game.strength = [EXPRESSION] 100
~OR~
set variable player.strength = [EXPRESSION] 100

now, we've created/added a 'strength' Integer Attribute (contained) within our 'game' Game Object, and stored it with the Value of '100'
~OR~
now, we've created/added a 'strength' Integer Attribute (contained) within our 'player' Player Object, and stored it with the Value of '100'

we, can now use this ( 'game.strength' ~~~OR~~~ 'player.strength' ) Integer Attribute in other scripting, for a full example, including an example of a simple displayment (GUI/Editor: 'print a message' Script, or in-Code: 'msg' Script) of it:

'game' Game Object -> 'Scripts' Tab -> 'start' Script -> (see below)

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

set variable player.strength = [EXPRESSION] 100

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

add new script -> 'output' section/category -> 'print a message' Script -> (see below)

print [EXPRESSION] "Player's Strength: " + player.strength

// this will output/display/show during game play:
// Player's Strength: 100

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

for a much more detailed resource on Attribute usage (and the 'if' Script):

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

(it's a bit more advanced especially having a lot of coding in it, but try to learn the different Attribute Types, see if you can create each of the basic Attribute Types: int --- integer, string, and boolean)

Answer/Help:

'game' Game Object -> 'Scripts' Tab -> 'start' Script -> (see below, repeat as needed)

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

// Integer Attribute example:
set variable player.strength = [EXPRESSION] 100
set variable game.strength = [EXPRESSION] 75
set variable game.orc_monster_strength = [EXPRESSION] 25
set variable game.state_as_an_integer = [EXPRESSION] 0

// String Attribute examples:
set variable player.sex = [EXPRESSION] "female"
set variable player.alias = [EXPRESSION] "karinchan999"
set variable game.state_as_a_string = [EXPRESSION] "0"

// Boolean Attribute examples:
set variable player.dead = [EXPRESSION] false
set variable player.flying = [EXPRESSION] false
set variable player.walking = [EXPRESSION] true
set variable game.orc_monster_dead = [EXPRESSION] false
set variable game.ogre_monster_dead = [EXPRESSION] true

'Page1' Page Object -> 'whatever' Tab -> Page Type: [script] or [script+text] -> (see below, repeat as needed)

add new script -> 'output' section/category -> 'print a message' Script -> (see below, repeat as needed)

print [EXPRESSION] "Player's Strength: " + player.strength
print [EXPRESSION] player.strength + " Player's Strength"
print [EXPRESSION] player.strength
print [EXPRESSION] "Game's Strength: " + game.strength
print [EXPRESSION] game.strength + " Game's Strength"
print [EXPRESSION] game.strength
print [EXPRESSION] ... etc etc etc .... see if you can do all of the Attributes above-above (see the 'Integer, String, Boolean examples sections), and then get them set up correctly with these 'print a message -> [exprssion]' Scripts, and see them displayed during game play

then, see if you can follow along in my more detailed link above, in doing addition/subtraction/multiplication/division... and then, beyond, lol

actually, I got a step by step guide on creating your own demo game (though it's for a Text Adventure, but I'd still recommend trying to do it, as the Attributes and 'if' Scripting is for the most part exactly the same between a Text Adventure and GameBook, with the only difference is that the GameBook uses its 'Page Type: [script] or [script+text] and its 'game.start' Script for the creation of Attributes at game start --- and the GameBook doesn't have the 'statusattributes' String Dictionary Attributes --- at least I don't think so, anyways, lol):

http://textadventures.co.uk/forum/quest/topic/5387/i-really-need-help#37375

ask if you need any help, as this is a lot to do and very complex, you likely are overwhelmed (especially if you actually read my posts, lol) with too much information... it's like that for everyone, it was at least for me... I was so confused and overwhelmed when I first started too!


karinchan999
29 Sept 2016, 13:06

Yeah, I definitely got overwhelmed by all this. But thank you! I was able to do as you've instructed! I also understood how the Integer and Strings work! You're awesome! Thank you thank you thank you for that! I just got back from school so I was only able to test it today and it was really helpful! I'll try it to follow your previous instruction regarding the 'return button' then I'll report back to you.


karinchan999
29 Sept 2016, 13:24

I tried working on the 'return button' and this came out:

"Error running script: Error compiling expression 'parent': Unknown object or variable 'parent'
game.previous:"

But I got what explained about the variables. I will practice to use them now. So uh, do I add script to both the 'backpack page' and the 'page 1 (example, where the player is from before opening the backpack)' and type the game.previous in the expression? I'm going to turn the page I'm in (page 1) into a variables so later when I open the 'backpack page' i can return to page 1, right? I got lost there.


hegemonkhan
29 Sept 2016, 22:05

YESSS... I figured it out... well... not fully yet... lol


It's really complicated...

this will create a Link to go to the previous page... but there's a lot of issues/problems involved with it... as I got to figure out how to remove the correct old added 'back to previous page' links (if you move back and forth amongst your pages many times)... still...

example (mostly in code):

<object name="player">
  <attr name="previous_page" type="object">Page1</attr>
</object>

Page1 -> Page Type: [script] or [script+text] -> (see below)

add new script -> 'page' section/category -> 'add new page link' -> (see below, in code though)

AddLinkPage (Page1, player.previous_page, "go back to previous page")

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

player.previous_page = player.parent

and do this same stuff, for each of your Pages..

... err... if you aren't revisiting any of your other Pages, then actually this only needs to be done for your 'backpack' Page... but I still got to think on how to deal with removing the old 'back links'....

but again... there's still a lot of really bad kinks to work out...


karinchan999
30 Sept 2016, 10:08

The link works very well!!! Wooow thank you so much!
My only problem is that every time I exit the backpack page and open it again, there are two links showing up. The link to the first one and the link to the present. So it's like Link 1 to Page1' then 'Link 2 to page2' but I got a solution. I used the "once script" in the text processor and it was pretty effective at first. But then I realized when the character opens a --for example a 'pocket page' when they go back to the backpack page, the 'return to game' link has disappeared because I used the "once script".

My next solution I tried using the "foreach" script that I read from here http://textadventures.co.uk/forum/quest/topic/5366/help-needed-with-links-in-a-gamebook and there's a "remove link" but I couldn't put it to practice. Error pops out or it disappears.

Thank you again by the way, it really helps!


hegemonkhan
30 Sept 2016, 23:49

ya, it's a bit complicated... I can get it figured out, but I'm just too busy at the moment (this week/weekend) with school work, got a test to study for and homework to do.


karinchan999
03 Oct 2016, 03:38

Oh alright. I'm sorry if I was disturbing you or anything. I guess I'll just wait for now. Waiting while figuring it out I mean.
Thank you again! I'll let you know if I discovered something!