Clothes and Weapons (Gamebook)

Hi, it's me again. I have another question. Since the game I am working on (finally progressing) is done with Stat tutorial, I am now working on the combat tutorial. I have a question on how to code the weapons and clothes that will boost the player's character stats.

1. GUNS & AMMO
Ex. Player has a gun with 12 bullets per mag. This is the question.
1.1. How do I put a trigger than when the player's mag drops to 0 (if player finishes 12 bullets), a link will appear to tell the player to reload his/her weapon before continue using it.
See sample below.
Ex. IF PLAYER NEEDS TO RELOAD

Page 1 Player has gun (12 bullets, 2 mags) goes to Page 2
Page 2 Player encounters enemy.
     (Page 3) go all out
     (Page 4) shoot twice
Page 3 Player goes all out and used 12 bullets (1 mag) and has 1 remaining mag left.
     (Page 5) Reload Weapon [*trigger to show this link because player finished 1st mag]
     (Page 6) Shoot (uses 3 bullets) [*will NOT appear because player has bullets left)
     (Page 7) Use pocketknife

Ex. IF PLAYER DOES NOT NEED TO RELOAD

Page 1 Player has gun (12 bullets, 2 mags) goes to Page 2
Page 2 Player encounters enemy.
     (Page 3) go all out
     (Page 4) shoot twice
Page 4 shoots twice
     (Page 5) Reload Weapon [*will not appear because player still has 10 bullets left]
     (Page 6) Shoot (uses 3 bullets) [*will appear because player has bullets left)
     (Page 7) Use pocketknife

1.2. How do I limit the mags/items that player picks up?

Ex. Player can pick up 2 weapons only. If player wants to pick up another weapon the "You cannot use another weapon!" text will appear.

Another instance could be for the inventory or the ammo,

Ex. Player has 5 mags. Player can only carry 7 all mags. So if player wants to pick up 3 more the "You don't have a slot for more ammo" text will appear.
Ex. If it's an item like first aid, etc., the player can only carry - let's say - 4 items. If player wants to pick up a 5th item the "You cannot carry anymore!" text will appear instead.

1.3. Is it possible to change weapons?
This may be too complicated already, but just wanted to ask.

1.4. Upgrading an item
If player is given a chance to upgrade an item, like after finishing a level, how do I do that? If this is too complicated then it's okay,

1.5. CHOOSING A WEAPON

But I guess this is what I really want to know. I think it has the same concept as choosing a gender but instead of gender, the player will choose a weapon and each weapon has a certain set of attributes. How do I do that? I haven't done the "choose your gender" code yet but I've read a few posts about it.

2. CLOTHES
Okay so player can also choose a certain set of clothing. And their clothes can effect their HP and defense and stuff.
2.1. How do I increase the maximum HP of the character because of chosen clothing?
So if player has a max of 100 HP and uses a clothing that adds 10HP to the player's max, now the player has a 110HP max.
By "max HP" I'm talking about, if the player takes a first aid kit,

Ex. player has HP: 95 and player uses first aid kit that adds 10 to player life. My current code set (player, "HP", player.HP +10) will automatically add 10 and the HP will be 105

I don't know if my questions made sense, but please help me.
Thank you all in advance!


Is my question confusing? Please let me know so I can rephrase it.
I really need help regarding this matter. Thank you.


(filler for getting my edited post, updated/posted)


I can try to take a stab at this stuff again, but I'm not the best helper/explainer... so you might want to wait for someone else...

(this is asking for a lot of coding help, so just be patient, for someone to have the time to try to attempt with helping on this stuff)

(even the most seemingly simple things, aren't so simple to code, and its hard to explain too, especially how to do it through the GUI/Editor / non-direct-coding way)


you may want to take a look at this abandoned extra website (that Alex had tried doing before he moved on from Quest), it has some good posts, especially on using the Game Book:

http://docs.textadventures.co.uk/ifanswers/ifanswers.com/index.html

http://docs.textadventures.co.uk/ifanswers/ifanswers.com/tag/gamebook.html (here's all of the 'game book' tagged questions)

http://docs.textadventures.co.uk/ifanswers/ifanswers.com/1150/gamebook-how-to-include-a-players-attributes-stats.html
http://docs.textadventures.co.uk/ifanswers/ifanswers.com/1091/using-gamebook-style-game-create-game-wide-variables-track.html
http://docs.textadventures.co.uk/ifanswers/ifanswers.com/1141/online-version-quest-how-change-the-value-status-attributes.html
http://docs.textadventures.co.uk/ifanswers/ifanswers.com/956/quest-gamebook-can-i-allow-players-to-choose-their-own-name.html

(try to learn to navigate it yourself, but if need help, let us know)


the Game Book is more limited than the Text Adventure and how you access the scripting is a bit different, but otherwise, the scripting is the same as in Text Adventures

the most important thing is to learn how to do scripting with the Game Book:

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

once you understand the above, this part here with the scripting, is the same as with the Text Adventure, and the biggest thing to learn is the use of 'Attribute' Scripts/Scripting and the use of the 'if' Script/scripting

once you learn 'Attribute' and 'If' scripting, you can do 90% of everything that you want to do in your game!

next, would be learning to use 'list' and 'dictionary' Attributes, which will bump up everything that you want to do in your game to 95% to 99%

learning even more advanced coding, as can be seen, has very diminishing returns, as you can already do now 95% to 99% of everything that you want to do in your game... but if you need it, learning more advanced coding can help for that %5 to 1% more that you need for your game, lol.

I do have a guide on this stuff (its for a text adventure, but again, the scripting itself is the same for the Game Book, just how you access the scripting is a bit different and you're more limited in what you got to work with), but a lot of people have difficulty with it...

http://textadventures.co.uk/forum/general/topic/ljjm32av4e2t9ot49k478g/help#710be61e-eae1-4af1-8363-520cc718ba1c

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk (specifically this link, you can scroll down past the top part stuff, and start at my bolded part/line of 'the two super scripts' or something like that to the bottom of my post, for the stuff on using Attributes and If scripting)

and this is absolutely vital/necessary to learn:

http://textadventures.co.uk/forum/quest/topic/byqpi4mjueasr-ibxkyrig/some-beginner-questions#453e00b5-2f3b-4f6e-b126-1b622a564bb6 (Data/VARIABLE:_Attribute_or_Variable/Value Types)

if you want to move onto learning the 'list' and 'dictionary' Attributes, I got guides on them:

http://textadventures.co.uk/forum/samples/topic/5137/list-and-dictionary-extensive-guide-by-hk

http://textadventures.co.uk/forum/quest/topic/7ykvyg82ge_1l64r2b_wtw/stringdictionaryitem-error-compiling#01372d5d-9162-488d-af38-553db9fa787d (this is probably a better, more clear - I hope, guide)


here's a step by step guide of mine for doing simple combat:

except... it's for a Text Adventure (you may want to just try doing it to get an understanding of doing combat coding)... and it can be used for the Game Book, but there's some changes that you got to understand/do and how to do this stuff with the Game Book

http://textadventures.co.uk/forum/quest/topic/-yjlbuy1geagzuvwa7ge6w/creating-rpg-stats#16a68305-7193-4b87-9fa9-417551e2b13c


Yeah the 'attributes' and the 'if' is a big thing in the Gamebook. That's why I want to learn it.
I already learned a bit of the attributes but by far I still have more to learn.
I will try to read all these links, see how well these guide links can help me with my dilemma. Thank you.

I will reply here if I have more questions, etc.


WHAT I LEARNED

--> I learned how to add the next page/add page in text processor.
--> I learned how to allow players to choose their own name.

--> This one just said to used the "if" according to the number (stats) that player earned along the way. Which was one of my questions in another thread, on how to do it in a simplified/easy way and not doing it one-by-one.
The "How to use AND OR and NOT inside an "if" command?"
http://docs.textadventures.co.uk/ifanswers/ifanswers.com/945/quest-gamebook-how-to-use-and-or-and-not-inside-an-if-command.html

--> I find this real helpful http://textadventures.co.uk/forum/quest/topic/byqpi4mjueasr-ibxkyrig/some-beginner-questions#453e00b5-2f3b-4f6e-b126-1b622a564bb6 thank you for this.

--> I got curious with flags, I will probably ask about it one day.

QUESTIONS

  1. What is the difference/purpose of player.strength and game.strength? I saw it in one of the links you sent.
    http://docs.textadventures.co.uk/ifanswers/ifanswers.com/1091/using-gamebook-style-game-create-game-wide-variables-track.html
set variable player.strength =  [expression] 100

set variable game.strength = [expression] 100

What is the difference? Do I put the set variable game.strength = [expression] 100 in the GAME -> SCRIPT? and the set variable player.strength = [expression] 100 I should put in the Pages Script?

  1. In my HP/Game Over question, http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk it's related to something like this but instead of player's condition is "Poisoned", etc., the player's HP is indicated with numbers. Like HP = 100 and if it reaches 0, a link or page will appear to say that it's game over with a link to the nearest checkpoint. Can you help me with that?
    http://textadventures.co.uk/forum/quest/topic/-yjlbuy1geagzuvwa7ge6w/creating-rpg-stats#16a68305-7193-4b87-9fa9-417551e2b13c
    This ^ link is related to my question here.

  2. How does the Randomization work? http://textadventures.co.uk/forum/quest/topic/7ykvyg82ge_1l64r2b_wtw/stringdictionaryitem-error-compiling#01372d5d-9162-488d-af38-553db9fa787d I think I need it for the other question I have in another thread.

Please help me. thank you.


What is the difference/purpose of player.strength and game.strength? I saw it in one of the links you sent (karinchan999)

just two different/separate Objects and their Attributes, otherwise no difference, an example (in the Game Book, you can't create a 'cat' Object, unless you create a 'cat' named Page Object):

// creating/adding the Objects:
create ("cat_1")
create ("cat_2")

// setting/creating the Attribute and its Values:
set variable cat_1.fur_color = [EXPRESSION] "white"
set variable cat_2.fur_color = [EXPRESSION] "black"

// displaying the Attribute's Values:
print [EXPRESSION] "Cat 1's fur color: " + cat_1.fur_color
print [EXPRESSION] "Cat 2's fur color: " + cat_2.fur_color

// output/displayment:
Cat 1's fur color: white
Cat 2's fur color: black

but, again, the Game Book only has 3 types of Objects:

  1. the 'player' Player Object
  2. the 'game' Object
  3. the Page Objects

so we'd have to do this instead (some examples):

// setting/creating the Attribute and its Values:
// (creating the illusion/effect of having a 'cat_1' and 'cat_2' Object)
set variable player.cat_1_fur_color = [EXPRESSION] "white"
set variable player.cat_2_fur_color = [EXPRESSION] "black"

// Player Object:
// player
//
// 'player' Player Object's Attributes:
//
// cat_1_fur_color
// cat_2_fur_color
//
// the 'player.cat_1_fur_color' String Attribute's Value:
// "white"
//
// the 'player.cat_2_fur_color' String Attribute's Value:
// "black"

// displaying the Attribute's Values:
print [EXPRESSION] "Cat 1's fur color: " + player.cat_1_fur_color
print [EXPRESSION] "Cat 2's fur color: " + player.cat_2_fur_color

// output/displayment:
Cat 1's fur color: white
Cat 2's fur color: black

// instead of using the 'player' Player Object, we can use the 'game' Object:

// setting/creating the Attribute and its Values:
// (creating the illusion/effect of having a 'cat_1' and 'cat_2' Object)
set variable game.cat_1_fur_color = [EXPRESSION] "white"
set variable game.cat_2_fur_color = [EXPRESSION] "black"

// Object:
// game
//
// 'game' Object's Attributes:
//
// cat_1_fur_color
// cat_2_fur_color
//
// the 'game.cat_1_fur_color' String Attribute's Value:
// "white"
//
// the 'game.cat_2_fur_color' String Attribute's Value:
// "black"

// displaying the Attribute's Values:
print [EXPRESSION] "Cat 1's fur color: " + game.cat_1_fur_color
print [EXPRESSION] "Cat 2's fur color: " + game.cat_2_fur_color

// output/displayment:
Cat 1's fur color: white
Cat 2's fur color: black

// instead of using the 'player' Player Object or the 'game Object, we can use Page Objects:

create/add Page Object:
Page Object's Name: cat_1

create/add Page Object:
Page Object's Name: cat_2

// setting/creating the Attribute and its Values:
set variable cat_1.fur_color = [EXPRESSION] "white"
set variable cat_2.fur_color = [EXPRESSION] "black"

// Page Objects:
// cat_1
// cat_2
//
// Page Object's Attributes:
//
// fur_color
// fur_color
//
// the 'cat_1.fur_color' String Attribute's Value:
// "white"
//
// the 'cat_2.fur_color' String Attribute's Value:
// "black"

// displaying the Attribute's Values:
print [EXPRESSION] "Cat 1's fur color: " + cat_1.fur_color
print [EXPRESSION] "Cat 2's fur color: " + cat_2.fur_color

// output/displayment:
Cat 1's fur color: white
Cat 2's fur color: black

does this make sense?

let's use all of the methods together...

set variable player.cat_1_fur_color = [EXPRESSION] = "white"
set variable player.cat_2_fur_color = [EXPRESSION] = "black"

set variable game.cat_3_fur_color = [EXPRESSION] = "grey"
set variable game.cat_4_fur_color = [EXPRESSION] = "pink"

create ("cat_5") // I think it's still the same with a Game Book (showing it directly in code, as I don't know the GUI/Editor's scripting stuff for adding/creating a 'cat_5' Page Object)

set variable cat_5.fur_color = [EXPRESSION] = "blue"

create ("cat_6") // I think it's still the same with a Game Book (showing it directly in code, as I don't know the GUI/Editor's scripting stuff for adding/creating a 'cat_6' Page Object)

set variable cat_6.fur_color = [EXPRESSION] = "orange"

print [EXPRESSION] "Cat 1's fur color: " + player.cat_1_fur_color
print [EXPRESSION] "Cat 2's fur color: " + player.cat_2_fur_color
print [EXPRESSION] "Cat 3's fur color: " + game.cat_3_fur_color
print [EXPRESSION] "Cat 4's fur color: " + game.cat_4_fur_color
print [EXPRESSION] "Cat 5's fur color: " + cat_5.fur_color
print [EXPRESSION] "Cat 6's fur color: " + cat_6.fur_color

// output/displayment:
Cat 1's fur color: white
Cat 2's fur color: black
Cat 3's fur color: grey
Cat 4's fur color: pink
Cat 5's fur color: blue
Cat 6's fur color: orange

// now, let's change some of the Attributes' Values:
set variable player.cat_1_fur_color = [EXPRESSION] = "purple"
set variable game.cat_3_fur_color = [EXPRESSION] = "brown"
set variable cat_5.fur_color = [EXPRESSION] = "green"

print [EXPRESSION] "Cat 1's fur color: " + player.cat_1_fur_color
print [EXPRESSION] "Cat 2's fur color: " + player.cat_2_fur_color
print [EXPRESSION] "Cat 3's fur color: " + game.cat_3_fur_color
print [EXPRESSION] "Cat 4's fur color: " + game.cat_4_fur_color
print [EXPRESSION] "Cat 5's fur color: " + cat_5.fur_color
print [EXPRESSION] "Cat 6's fur color: " + cat_6.fur_color

// output/displayment:
Cat 1's fur color: purple
Cat 2's fur color: black
Cat 3's fur color: brown
Cat 4's fur color: pink
Cat 5's fur color: green
Cat 6's fur color: orange


What is the difference? Do I put the set variable game.strength = [expression] 100 in the GAME -> SCRIPT? and the set variable player.strength = [expression] 100 I should put in the Pages Script? (karinchan999)

if you put it into the 'game -> script', then this will be the first thing that quest does when you play your game

if you put it elsewhere ( as scripting for whatever Page Object: 'WHATEVER' Page Object -> 'Page' Tab -> Page Type: [script] or [script + text] ), then when you're at that Page, it'll do it there.

for example:

// creating/setting the Objects, their Attributes, and their initial Values:

'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.cat_1_fur_color = [EXPRESSION] "red"

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

set variable player.cat_2_fur_color = [EXPRESSION] "blue"

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

set variable game.cat_3_fur_color = [EXPRESSION] "yellow"

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

set variable game.cat_4_fur_color = [EXPRESSION] "orange"

create ("cat_5") // as again, I don't know the GUI/Editor scripting for creating/adding a Page Object (well, it's probably something like this: add new script -> 'pages / page objects' section/category -> 'create/add page or create/add page object' Script -> Page Name: cat_5)

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

set variable cat_5.fur_color = [EXPRESSION] "purple"

create ("cat_6") // as again, I don't know the GUI/Editor scripting for creating/adding a Page Object (well, it's probably something like this: add new script -> 'pages / page objects' section/category -> 'create/add page or create/add page object' Script -> Page Name: cat_6)

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

set variable cat_6.fur_color = [EXPRESSION] "green"

// then, let's have 'Page2', display these Attributes (you know how to handle moving from one page to another, I don't, as I'm not very familiar with using the Game Book):

create/add Page -> Page Name: Page2

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

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

print [EXPRESSION] "Cat 1's fur color: " + player.cat_1_fur_color

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

print [EXPRESSION] "Cat 2's fur color: " + player.cat_2_fur_color

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

print [EXPRESSION] "Cat 3's fur color: " + game.cat_3_fur_color

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

print [EXPRESSION] "Cat 4's fur color: " + game.cat_4_fur_color

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

print [EXPRESSION] "Cat 5's fur color: " + cat_5.fur_color

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

print [EXPRESSION] "Cat 6's fur color: " + cat_6.fur_color

// then, let's have another Page (Page3), change some of these Attributes (again, you handle the moving from page to page):

create/add Page -> Page Name: Page3

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

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

set variable player.cat_1_fur_color = [EXPRESSION] "white"

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

set variable game.cat_3_fur_color = [EXPRESSION] "black"

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

set variable cat_5_fur_color = [EXPRESSION] "grey"

// lastly, display these Attributes:

you have it set up so you move back to the 'page2' Page, as this is already set up for displaying the Attributes (there's no reason to create another page to do the exact same thing, lol)


if not one else helps with your other questions (and/or try to help more with the 2 first questions that I tried to help with if you need any help or got any questions with them), I will when I have the time, but not right now (got stuff to do)


I got curious with flags, I will probably ask about it one day (karinchan999)

'flags' are just Boolean VARIABLES (see that Data/VARIABLE/VALUE Type link of mine that you said was really useful) in this case (and in general usually) they're interchangeable --- for you using quest: 'flag' and 'boolean' are interchangeable terms/words

(there's a bit more technical subtle/nuanced differences between the two terms, depending on what type of programming you're doing, but that has nothing to do with using quest)

setting/creating a 'flag / Boolean' Attribute, examples:

set variable game.won_the_game = [EXPRESSION] false
set variable game.game_over = [EXPRESSION] false
set variable player.poisoned = [EXPRESSION] true
set variable Page99.visited = [EXPRESSION] true

changing a 'flag / Boolean' Attribute, examples:

set variable game.won_the_game = [EXPRESSION] true
set variable game.game_over = [EXPRESSION] true
set variable player.poisoned = [EXPRESSION] false
set variable Page99.visited = [EXPRESSION] false


What is the difference? Do I put the set variable game.strength = [expression] 100 in the GAME -> SCRIPT? and the set variable player.strength = [expression] 100 I should put in the Pages Script?

The difference is that game.strength and player.strength are different attributes.

In gamebook mode, it really doesn't matter which one you use. Just use one of them and stick to it, is my advice.

I think some people use player for attributes that are something about the player (like strength), and game for everything else. Or use game for everything. But in gamebooks, it doesn't matter so much.

Gamebook's "counter" and "flag" scripts are both shortcuts for attributes of game.

(In text adventures, it makes more of a difference because you might also have things like John.strength and Goblin.strength referring to NPCs; and your script can refer to the strength of whichever object the player is currently fighting. Gamebooks have pages instead of objects, so this isn't so helpful)


  1. Oooh so when I do player.cat and game.cat it's still the same thing?

HK
Oh I see. Okay I will remember that. No need to repeat the same thing when I already coded the attributes in one page. But if I do it in the Game -> Script it's the first thing that Quest will do. Thank you for clarifying that it helps me a lot. Thank you very much!

Can you give me a sample on where/how to use the flag? Maybe I can use it for something like achievements? Or secret cutscenes?

mrangel
Particularly no difference other than they are different attributes? Gotcha. I will take your advice to stick with player when using it for players and game for everything else. Thank you very much!

Can you give me a sample on where/how to use the flag? Maybe I can use it for something like achievements? Or secret cutscenes? I am sorry I am not familiar with the other terms so I may not be aware how to use it or what I could use it for.


here's help on using 'flags' (Boolean) VARIABLES:


http://textadventures.co.uk/forum/quest/topic/2ebaw4u3-umcc-dwrpyrhw/organize-multiple-npc-routes#ae9e8451-e4d4-4595-a34e-154531d24cb4


Setting/Changing a flag's (Boolean's) Attribute's Value in the GUI/Editor:

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

set variable NAME_OF_OBJECT.NAME_OF_FLAG/BOOLEAN_ATTRIBUTE = [EXPRESSION] TRUE/FALSE

for examples:

set variable player.flying = [EXPRESSION] false
// or:
set variable player.flying = [EXPRESSION] true

set variable game.paused = [EXPRESSION] false
// or:
set variable game.paused = [EXPRESSION] true

set variable Page1.visited = [EXPRESSION] false
// or:
set variable Page1.visited = [EXPRESSION] true

// Text Adventure example:

set variable orc.dead = [EXPRESSION] false // (orc is alive)
// or:
set variable orc.dead = [EXPRESSION] true // (orc is dead)

// or:

set variable orc.alive = [EXPRESSION] false // (orc is dead)
// or:
set variable orc.alive = [EXPRESSION] true // (orc is alive)


using the 'if' Script and Boolean Attributes in the GUI/Editor, an example:

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

if [EXPRESSION] NAME_OF_OBJECT.NAME_OF_FLAG/BOOLEAN_ATTRIBUTE
// conceptually: if (NAME_OF_OBJECT.NAME_OF_FLAG/BOOLEAN_ATTRIBUTE = true)
// conceptually: if (TRUE)

else
// the opposite of the 'if' conditional, so...
// conceptually: if (NAME_OF_OBJECT.NAME_OF_FLAG/BOOLEAN_ATTRIBUTE = false)
// conceptually: if (FALSE)

-> add new script -> 'WHATEVER' Script

// ----------
// or:
// ---------

if [EXPRESSION] not NAME_OF_OBJECT.NAME_OF_FLAG/BOOLEAN_ATTRIBUTE
// conceptually: if (not NAME_OF_OBJECT.NAME_OF_FLAG/BOOLEAN_ATTRIBUTE = true)
// conceptually: if (not true)
// conceptually: if (FALSE)

else
// the opposite of the 'if' conditional, so...
// conceptually: if (NAME_OF_OBJECT.NAME_OF_FLAG/BOOLEAN_ATTRIBUTE = true)
// conceptually: if (TRUE)

-> add new script -> 'WHATEVER' Script


example (in code, using Text Adventure example):

if (orc.dead) {

  if (not orc.looted) {

    orc.looted = true

    player.experience = player.experience + orc.experience
    player.currency = player.currency + orc.currency

    msg ("You loot the dead orc's corpse")

  } else {

    msg ("You already looted the orc's corpse")

  }

} else {

  orc.life = orc.life - player.damage

  msg ("You attack the orc")

  if (orc.life > 0) {

    player.life = player.life - orc.damage

    msg ("The orc attacks you")

    if (player.life < 1) {

      msg ("You were killed by the orc")
      msg ("GAME OVER")

      finish

    }

  } else {

    orc.dead = true

    msg ("You killed the orc")

  }

}

ask if you need help with anything


Oh I see. Okay, I will keep note of this. Thank you very much!


think of flags (Booleans) as like a toggle, a physical switch, or a check box

best example is a light switch on a light/lamp or wall in your house:

if the light switch is switched "on" (true), than the: light is on, the light/lamp bulb is on, the room is lit

if the light switch is switched "off" (false), than the: light is off, the light/lamp bulb is off, the room is dark/unlit

lamp.light_switch = true
// or (they're doing the same thing: creating/setting an attribute and its Value):
set (lamp, "light_switch", true)

if (lamp.light_switch = true) {
  msg ("The lamp emits a bright light")
} else if (lamp.light_switch = false) {
  msg ("The lamp is off, there's no light being emitted from the lamp")
}

// output:
// The lamp emits a bright light

// --------------------------------------------

lamp.light_switch = false
// or (they're doing the same thing: creating/setting an attribute and its Value):
set (lamp, "light_switch", false)

if (lamp.light_switch = true) {
  msg ("The lamp emits a bright light")
} else if (lamp.light_switch = false) {
  msg ("The lamp is off, there's no light being emitted from the lamp")
}

// output:
// The lamp is off, there's no light being emitted from the lamp

// ------------------------
// ------------------------
// -----------------------

but the above examples of the 'if' Script are using long-forms, which are NOT needed for 'flags' (Boolean) Attributes, and thus are less-optiminal coding

so, this is what it actually looks like (short-form):

// ----------

lamp.light_switch = true
// or (they're doing the same thing: creating/setting an attribute and its Value):
set (lamp, "light_switch", true)

if (lamp.light_switch) {
  msg ("The lamp emits a bright light")
} else {
  msg ("The lamp is off, there's no light being emitted from the lamp")
}

// output:
// The lamp emits a bright light

// or:

lamp.light_switch = true
// or (they're doing the same thing: creating/setting an attribute and its Value):
set (lamp, "light_switch", true)

if (not lamp.light_switch) {
  msg ("The lamp is off, there's no light being emitted from the lamp")
} else {
  msg ("The lamp emits a bright light")
}

// output:
// The lamp emits a bright light

// --------------

lamp.light_switch = false
// or (they're doing the same thing: creating/setting an attribute and its Value):
set (lamp, "light_switch", false)

if (lamp.light_switch) {
  msg ("The lamp emits a bright light")
} else {
  msg ("The lamp is off, there's no light being emitted from the lamp")
}

// output:
// The lamp is off, there's no light being emitted from the lamp

// or:

lamp.light_switch = false
// or (they're doing the same thing: creating/setting an attribute and its Value):
set (lamp, "light_switch", false)

if (not lamp.light_switch) {
  msg ("The lamp is off, there's no light being emitted from the lamp")
} else {
  msg ("The lamp emits a bright light")
}

// output:
// The lamp is off, there's no light being emitted from the lamp

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

Support

Forums