Need Help with flags / Switching lights off - Gamebook

Hi, I've got 2/3 through my first game and realised that something is really broken. I need the ability to walk into a room, switch off a light, walk out, and the light to be off. On top of that, I don't want the option to be able to switch out the light in the room after it's done.

For Example, Start Room One (you can go to Room2 which has the flag set on) So Go to Room 2, switch off the light (you are then sent to a copy of Room2 with the flag set off)

That's fine, but when I return to room one I end up having 2 options; Go to room2 light on & Go to room 2 Light Off when really I want the game to remember what happened in Room2

The script I use is
If Flag is set - go to room2 light on
Else go to room 2 light off

I hope I've made myself clear as this is an integral part of my game and won't function if it doesn't remember when a light is on or off. If anyone can explain a better way of doing this in layman's terms that would be much appreciated, I don't know how to code so there's no point in getting me to change that, I only use the preset functionality for dummies like me :D

Cheers


the Game Book can create/add Attributes, but only through scripting, and also you only got two Objects you can add Attributes to: the 'game' Game Object and the 'player' Player Object. I think you are able to add Attributes for your Page Objects too.

Attributes:

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

run as script -> 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

some examples:

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

set variable page_0.is_light_on = [EXPRESSION] false
set variable page_0.is_light_on = [EXPRESSION] true

the 'if' Script:

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

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

if [EXPRESSION] NAME_OF_OBJECT.NAME_OF_ATTRIBUTE OPERATOR VALUE_OR_EXPRESSION

some examples:

if (page_0.is_light_on = true) {
  msg ("The the light is on within page_0")
} else if (page_0.is_light_on = false) {
  msg ("The light is not on within page_0")
}

see this link for much more detailed guide on Attribute usage and the 'if Script:

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

(its on the Text Adventure, but the scripting itself is the same for both Text Adventure and Game Book, aside from how you access the scripting and what you can do)


Also, the Text Adventure has a built-in room light-dark feature, but I don't know if the Game Book does or not (probably doesn't), so you'll have to create your own light on/off Boolean Attributes and/or a page light-dark system yourself.


Thanks, Hegemonkhan, so if I've understood you correctly I can do away with having 2 copies of 1 room (lights on & lights off) give the room an attribute, then if the attribute is on display an option to switch it off? Is that right?

PS 'so you'll have to create your own light on/off Boolean Attributes and/or a page light-dark system yourself.' Trust me to make things difficult for myself!


Room Objects are used in Text Adventure, Page Objects are used in Game Book, but you can of course name your Objects whatever you want (if you want to name your Page Objects as 'room1', 'room2', etc, that's perfectly fine, and vice versa too). The Game Book is much more limited though than the Text Adventure, as the Game Book was created to be mostly a CYOA, and not be that code/scripting heavy in terms of game features/functionalities (such as RPG aspects type stuff).

You are using Game Book, right? Or, are you using a Text Adventure? Or, are you using Pixie's Text Adventure hybrid as it looks like a Game Book? I just want to be clear on which quest type you're using.

This post's content will be on Game Book. (Let me know if you're doing a Text Adventure or Pixie's Text Adventure hybrid as it looks like a Game Book).

If you can add/create Attributes to your Page Objects, you're able can be specific as to which Pages have which Attributes and what is done with scripting.

However, I think for what you want, it'd be best to just create/add a single Boolean Attribute to your 'game' Game Object, used to be the 'light-dark' state of your game, which you can toggle on(true)/off(false), as you need to as the person playing the game progresses through it (visits your Pages). See below.


generally you want your first page to set up (create/add) all of your Attributes and their initial values, but you could have some intro text pages first, if you want. But, before you do anything with Attributes and scripting, you need to have those Attributes created/added. So you need a Page to add/create/set-up those Attributes, before you can have your next pages do stuff with those Attributes.

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

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

NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION

// conceptual understanding of simple boolean (true/false) Attribute logic involved:
//
// game.dark = true ---> effectively dark
// game.dark = false ---> effectively light
// or
// game.light = true ---> effectively light
// game.light = false ---> effectively dark

// I'm going to use 'dark', instead of 'light' and also instead of my own more descriptive naming/labeling system/convention, such as my use of 'is_light_on' in my previous post, I think. To keep the naming/labeling simple for you.

// I chose 'game.dark = false' assuming you want most (more than half) pages being initially light
// if you want most (more than half) of your Pages to be dark initially, then, it's better and more logical to use: game.light = false
//
// the logic/reasoning involved is like this:
// let's say you ask a 100 people to raise their hand if they have a dog
// and let's say 70 of them raised their hands
// would you rather count 70 hands, or...
// would you instead (seeing that most, more than half, of them raised their hands in having a dog), ask them instead to raise their hands if they don't have a dog (the opposite/inverse-reciprical whatever it is), having to only count 30 hands instead of 70 ?
// obviously, it's easier to count 30 hands than to count 70 hands, and so you'd rather be counting the 30 hands instead of 70, and so, you ask them to raise their hands if they don't have a dog, instead of asking them to raise their hands if they have a dog.

set variable game.dark = [EXPRESSION] false // deciding that the default state is for no darkness

// so, if you want your Pages to be dark, you need change your 'dark' Attribute's Value to 'true', and when you want your Pages to be light again, you need to change your 'dark' Attribute's Value to being 'false' again.


now, with your Pages you can do various scripting using your 'dark' Attribute, for some (simple-quick) examples:

// our page has different options/links/states/displayment/stuff based upon whether the dark-light game state is dark (game.dark = true) or light (game.dark = false):
if (game.dark) {
  msg ("The page is dark")
} else {
  msg ("The page is light")
}

// we want our page to initially be dark when going to it (this must be the first/top script added/created for the Page):
if (not game.dark) {
  game.dark = true
}

// before we go to another page, we change the dark-light game state to being back to light (this must be the last/bottom script added/created for the Page):
if (game.dark) {
  game.dark = false
}

the 'if' Script is done like this:

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

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

if [EXPRESSION] NAME_OF_OBJECT.NAME_OF_ATTRIBUTE OPERATOR VALUE_OR_EXPRESSION

some (more) examples:

if [EXPRESSION] game.dark // this is understood (shortened) by quest as being 'game.dark = true'
-> then, -> add new script -> (whatever script/s you want to do)
(optionally):
else,
-> add new script -> (whatever script/s you want to do)

if [EXPRESSION] not game.dark // or you can do this (same thing) instead (though using the 'not' is better): game.dark = false
-> then, -> add new script -> (whatever script/s you want to do)
(optionally):
else,
-> add new script -> (whatever script/s you want to do)

if [EXPRESSION] player.strength > 66
-> then, -> add new script -> (whatever script/s you want to do)
(optionally):
else if [EXPRESSION] player.strength > 33
 -> then, -> add new script -> (whatever script/s you want to do)
// optionally: as many more (or less) 'else ifs' as you want
(optionally):
else,
-> add new script -> (whatever script/s you want to do)

as for the person playing the game, being able to control the toggling of the 'game.dark = false/true'... hopefully you can use the 'get input' Script or use Commands, or to have clickable hyperlinks be able to do the scripting, otherwise, you may have to use page's scripting (Page Type: [script] or [script+text]) to do so... which would be more of a pain... I'm not that familiar with what the Game Book can do (or has) and can't do (or don't have).


Hi, thanks for your help. I've been trying to get my head around it for a while, nearly gave up on the whole endeavour because actually, I think I might be trying to walk before I can crawl. This is my very first attempt at making a game, which is why I opted for the reduced functionality of the Gamebook in the first place as there is a lot less to learn before you can get started. So I'm just going to strip the lights on/off feature out, and then do a lot more homework before attempting to do a similar thing as a Text Adventure instead. I know the gameplay won't be exactly what I was looking for, but even as it is its got some cool features (IMO)
I appreciate your help though bud
Cheers


Please feel free to ignore this, I thought you were using Squiffy

Sorry, isn't this just over complicating things.

Why not just use attributes and if statements within sections. So:

Set room1light = 1
Set room2light = 0
Set room3light = 1

So we will use 1 for a light that is on, and a 0 for a light that is off.

Then within the section you could have something like

[[room1]]:
{if room1light=1:You can put your content for if the light is on here}
{if room1light=0:You can put your content for if the light is off here}

Then within the content for each room, your link to turn a light off (or on if you wanted) would simply be:

[[Turn off the light]](room1, room1light=0)}

The above would change the attribute via the link, and then loop you back around into the same section, where your if statements will come into play.

Or have I misunderstood what you are trying to do?


I'm very sorry, I've just realised that you're using Quest to make a Gamebook, not Squiffy.

My mistake. In case anyone wants to have some fun with turning lights on and off in various rooms in Squiffy, you could use something like the following:

@set room1light = 1
@set room2light = 0

You are in a hallway. Do you go in room 1 or 2?

[[Room1]]<br>
[[Room2]]

[[Room1]]:
@clear
{if room1light=1:You are in room 1. It is nice and bright in here. Why don't you [[turn off the light]](Room1dosomething, room1light-=1) or [[go back to the hallway]](Hall)}
{if room1light=0:You are in room 1. It is really dark in here. Why don't you [[turn on the light]](Room1dosomething, room1light+=1) or [[go back to the hallway]](Hall)}

[[Room1dosomething]]:
@clear
{if room1light=0:You turned off the light... [[Continue]](Room1)}
{if room1light=1:You turned on the light... [[Continue]](Room1)}

[[Room2]]:
@clear
{if room2light=1:You are in room 2. It is nice and bright in here. Why don't you [[turn off the light]](Room2dosomething,     room2light-=1) or [[go back to the hallway]](Hall)}
{if room2light=0:You are in room 2. It is really dark in here. Why don't you [[turn on the light]](Room2dosomething, room2light+=1) or [[go back to the hallway]](Hall)}

[[Room2dosomething]]:
@clear
{if room2light=0:You turned off the light... [[Continue]](Room2)}
{if room2light=1:You turned on the light... [[Continue]](Room2)}

[[Hall]]:
@clear
You are back in the hallway. Do you go in room 1 or 2?

[[Room1]]<br>
[[Room2]]

The RoomXdosomething section has to be used as Squiffy doesn't seemingly let you loop directly back into the same section whilst changing a variable, which is a bit odd.


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

Support

Forums