How do you make when you choose a name then to use it in later text?

I want the player to choose a name out of some choices, then use that name in a description on the next page. How do I do that in my quest game?

For example, someone might pick "Christian" and then on the next page, the description will say "Christian opens the creaky door to find a rust, silver key lying on the ground. "Christian, look out!" his sister shouts.".


here (doing an 'alias' and more!):

(technically the 'name' String Attribute is the ID for quest's OBJECTS, so it can't be changed: the 'name' is permanent and unique)

(but there's an 'alias' String Attribute that is made for doing the names of things for people playing the game)

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

and here's more links to help you with learning quest and its coding:

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

(to understand about "Attribute and the 'if' Script usage", see that link of mine, if you can learn to use Attributes and the 'if' Script, you can do 90% of everything that you want to do in/for your game!)


ask if you need help with anything or are confused by anything!


Erm, sorry I don't get what you really mean, I'm doing a gamebook. I thought it would be like this:

What is your name?

Link 1: Jack
Link 2: Sarah
Link 2: Sam

.<name.> walks into the house and picks up the wallet. "What are you doing .


you could do it like that (via selecting Page Links), but you can do the same thing with coding/scripting (you have to use coding/scripting at least for your name usage any ways, so might as well just do it all as coding/scripting, instead of using the Page Links, as if you got a lot of options/choices... that's going to be a fkn ton of Pages you got to create... which is NOT good!) as in those links I provided:

the only difference with using the Game Book (vs the Text Adventure), is the way you access the scripting/coding:

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

add new script -> (etc etc etc, follow the links' instructions)


if you need help, let us know...

(I'll post a step by step walkthrough instruction demo game for you, to follow, to learn how to do it, if you can't figure it out on your own)


if you just want to use the Page Link method...

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

add new script -> (whatever the GUI/Editor's script options for creating the Page Links, an example below)

  1. Joe
  2. John
  3. Jeff

create/add page -> Page Name: joe

'joe' Page -> '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.alias = [EXPRESSION] "joe"

create/add page -> Page Name: john

'john' Page -> '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.alias = [EXPRESSION] "john"

create/add page -> Page Name: jeff

'jeff' Page -> '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.alias = [EXPRESSION] "jeff"

and to use the 'player.alias', an example:

'WHATEVER 2' Page -> 'Page' Tab -> Page Type: [script] or [script + text] -> (see below, an example)

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

print [EXPRESSION] "Player Name: " + player.alias

// output/display:
// (let's say you chose the 'john' Page Link)
// Player Name: john


you can also use the 'text processor command', which will probably be easier for you:

{player.alias}

for examples:

(you may be able to use the '[MESSAGE]' script option with the text processor commands)

(the [MESSAGE] is for TEXT only, the text does NOT need the double parenthesis when using the [MESSAGE], and if you do use double parenthesis, then it gets displayed, meaning like if you want to show that someone is actually speaking during game play, but it may work with the text processor commands, even though it otherwise is only for TEXT)

(the [EXPRESSION] is for anything: "TEXT" only, +VARIABLE+ only, or "TEXT" and +VARIABLE+ usage together)

print [EXPRESSION] "Player Name: {player.alias}"

// output/display:
// (let's say you chose the 'john' Page Link)
// Player Name: john

print [EXPRESSION] "Hi, my name is {player.alias}, what is your name?"

// output/display:
// (let's say you chose the 'john' Page Link)
// Hi, my name is john, what is your name?


vs doing it the "normal" way:

print [EXPRESSION] "Hi, my name is " + player.alias + ", what is your name?"

// output/display:
// (let's say you chose the 'john' Page Link)
// Hi, my name is john, what is your name?


the concept is using VARIABLES, just like with algebra in math:

N = 10

N x 2 = ???
// 20

in programming:

(Unlike in Math, which only has the 'comparison: equal to' operation: '=' sign, there's ALSO the Assignment Operation: '=' sign, which is STORING the final Value on the right side of the '=' sign, into the VARIABLE on the left side of the '=' sign)

n = 10 // the '10' Value is STORED into the 'n' Variable VARIABLE

m = n * 2
// m = 20 // the '20' final Value (after the expression is done: n * 2 = n:10 * 2 = 10 * 2) is STORED into the 'm' Variable VARIABLE

n = "hegemonkhan"
msg ("My name is " + n + ".")
// output:
// My name is hegemonkhan.

now, with quest, you want to mostly/usually use the Attribute VARIABLES:

player.n = "hegemonkhan"
msg ("My name is " + player.n + ".")

// now, 'n' is not very descriptive... so let's use something more descriptive (like the built-in 'alias' String Attribute), which has the features/handling we want for its usage already built-in for us):

player.alias = "hegemonkhan"
msg ("My name is " + player.alias + ".")

as, unlike a Variable VARIABLE (like our 'n' example), Attribute VARIABLES (like our 'player.n' or 'player.alias' examples) persist and can be used anywhere (global scope), so long as the Object containing them, exists or still exists, of course:

// in-code, as scripting:

player.alias = "hegemonkhan"
player.n = "hegemonkhan"
player.strength = 100
player.dead = false

// in code, as "xml creation tags":

<object name="player">

  <attr name="alias" type="string">hegemonkhan</attr>

  <attr name="n" type="string">hegemonkhan</attr>

  <attr name="strength" type="int">100</attr>

  <attr name="dead" type="boolean">false</attr>

</object>

there's 3 types of VARIABLES (keeping this simple)

VARIABLES:

  1. Variable: a local VARIABLE: local scope (can only be used within its parent scripting), temporary
  2. Attribute: a global VARIABLE: global scope (can be used anywhere), "permanent" (so long as the Object containing it exists or still exists)
  3. Parameters: used by Commands and Functions

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

the Variable VARIABLE's general syntax:

NAME_OF_Variable = VALUE_OR_EXPRESSION
or
NAME_OF_Variable

examples:

n = 10
n = "hk"
n = false
n = true
n = "welcome to my game, I hope you enjoy it!"

number = 10
text = "hk"
dead = false
dead = true
flying = false
flying = true
poisoned = false
poisoned = true
intro = "welcome to my game, I hope you enjoy it!"

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

the Attribute VARIABLE's general syntax:

NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION
or
NAME_OF_OBJECT.NAME_OF_ATTRIBUTE

examples:

player.n = 10
player.n = "hk"
player.n = false
player.n = true
player.n = "welcome to my game, I hope you enjoy it!"

player.number = 10
player.text = "hk"
player.dead = false
player.dead = true
player.flying = false
player.flying = true
player.poisoned = false
player.poisoned = true
player.intro = "welcome to my game, I hope you enjoy it!"

game.n = 10
game.n = "hk"
game.n = false
game.n = true
player.n = "welcome to my game, I hope you enjoy it!"

game.number = 10
game.text = "hk"
game.dead = false
game.dead = true
game.flying = false
game.flying = true
game.poisoned = false
game.poisoned = true
game.intro = "welcome to my game, I hope you enjoy it!"

// if using the Text Adventure (able to create custom Objects, not limited to 'player' Player Object, 'game' Game Settings and Pulbishing Info special Object, and the various Page Objects, like when using the Game Book):

orc.n = 10
orc.n = "hk"
orc.n = false
orc.n = true
orc.n = "welcome to my game, I hope you enjoy it!"

orc.number = 10
orc.text = "hk"
orc.dead = false
orc.dead = true
orc.flying = false
orc.flying = true
orc.poisoned = false
orc.poisoned = true
orc.intro = "welcome to my game, I hope you enjoy it!"

// for effectively having custom Objects in the Game Book, you can do this "trick", like so:

game.orc_n = 10
game.orc_n = "hk"
game.orc_n = false
game.orc_n = true
game.orc_n = "welcome to my game, I hope you enjoy it!"

game.orc_number = 10
game.orc_text = "hk"
game.orc_dead = false
game.orc_dead = true
game.orc_flying = false
game.orc_flying = true
game.orc_poisoned = false
game.orc_poisoned = true
game.orc_intro = "welcome to my game, I hope you enjoy it!"

game.ogre_n = 10
game.ogre_n = "hk"
game.ogre_n = false
game.ogre_n = true
game.ogre_n = "welcome to my game, I hope you enjoy it!"

game.ogre_number = 10
game.ogre_text = "hk"
game.ogre_dead = false
game.ogre_dead = true
game.ogre_flying = false
game.ogre_flying = true
game.ogre_poisoned = false
game.ogre_poisoned = true
game.ogre_intro = "welcome to my game, I hope you enjoy it!"


Log in to post a reply.

Support

Forums