Custom player name

New to the Quest program. I'm trying to make an RPG and I want the player to be able to create a name for themselves at the beginning. Is there a simple way to implement this?


Io

Yes.

Use the GetInput code. In psuedocode, it'll look like this:

print("Enter your name!")
GetInput{
Player.Name=result
}

Much appreciated.


In actual code, the attribute you want to set is probably called alias.

An object's alias is the name the player sees for it. But the attribute name is what you refer to it by in the code, and can't be changed.

In theory you could use Name like any other attribute, because Name and name are different; but that could be confusing, and is likely to lead to mistakes.


Io

Whoops, yeah, what mrangel said. I put Name as a typo instead of alias.


How do you make a custom name for gamebook?
Edit: I am a noob so certain coding terms may be a bit beyond me for now, sorry if I don't understand.


the scripting is the exact same, be it for a Text Adventure or Gamebook, but for a Gamebook, you just got to do this to enable the scripting:

'WHATEVER' Page -> 'setup (or whatever it is)' Tab -> Page Type: [script] or [text + script] -> (whatever scripting / add new script)


for doing basic RPG character creation stuff:

https://docs.textadventures.co.uk/quest/character_creation.html

I can't remember, but Gamebook may not have the popup menu functionality: the 'show menu (XXX)' Function


Ah thank you, I did figured the Text+Script but I didn't know how to implement it.


got it (the scripting/implementing) now, or still need help?


thanks for letting us know happy wheels online


Well in case, do I have to apply a code or script to ensure the custom name is used or will it apply no matter?


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


conceptual basics of programming/coding/scripting:

it's just VARIABLE usage, so if you know algebra in math, you can do programming/coding/scripting


in math:

x = 5 // the Integer Value of '5' is STORED WITHIN ("assigned to") the 'x' Variable VARIABLE

unfortunately, in math, they usually don't teach that this is actually an Assignment Operation, you're "assigning" the VALUE_OR_EXPRESSION (in this case, the '5' Integer Value) on the right side of the Assignment Operator (the '=' sign) to the VARIABLE (in this case, the 'x' Variable VARIABLE) on the left side of the Assignment Operator (the '=' sign):

Assignment Operation:

VARIABLE = VALUE_OR_EXPRESSION

VARIABLE: x
VALUE_OR_EXPRESSION: 5

so, thus, if we then did/had this:

x + 3 = ???

the '???' would equal: 8

[x = 5]
x + 3 = ???
[x] + 3 = ???
[x = 5] + 3 = ???
[5] + 3 = 8

now, in algebra, you got problems to solve, where you're actually using the 'Comparison' Operation instead (again, usually not taught/explained about it in math, unfortunately) in order to solve for the values of the variables:

using the '???' instead of 'n' (or 'x' or whatever alphabet letter/character for variables in math) to not confuse it with how programming's VARIABLES work

??? + 3 = 8

what is '???' so that the left and right sides' VALUES_OR_EXPRESSIONS of the Comparison Operator (usually its a '==' sign, but quest has it as a '=' sign, as it can tell/understand/parse the scripting to know whether its an Assignment Operation or a Comparison Operation) are, EQUAL TO (comparison) each other?

Comparison Operation:

is [LEFT_VALUE_OR_EXPRESSION = RIGHT_VALUE_OR_EXPRESSION] true?

LEFT_VALUE_OR_EXPRESSION: ??? + 3
RIGHT_VALUE_OR_EXPRESSION: 8

is [??? + 3 = 8] true?

pretending you didn't know what value the '???' is, you solve for the '???', like this in-for algebra:

??? + 3 = 8
??? + 3 [-3] = 8 [-3]
??? = 5

and to verify that '5' is the value of '???':

is [5 + 3 = 8] true?
is [8 = 8] true?

yes, the VALUE_OR_EXPRESSION on the left side of the Comparison Operator (for quest, the '=' sign) is EQUAL TO the VALUE_OR_EXPRESSION on the right side of the Comparison Operator (for quest, the '=' sign)

so yes, it's TRUE!

algebra, thus: '5' is indeed the correct value for the '???'


Data Types:

Quantity Data Types (able to do arithmetic on/with them):

  1. Integers (non-decimal / non-fractional numbers: ..., -100, 0, 100, ...)

  2. Doubles/Floats/Floating-Points (Decimal/Fractional numbers: ..., -100.123, 0.0, 100.9, ...)

Non-Quantity Data Types (NOT able to do arithmetic on/with them):

  1. Strings (a collection of alphabet, numeral, and/or some other characters/symbols, except for any special/reserved values: "a", "abc", "1", "123", "abc_123", "hi", "hi, how are you? My name is HK, what is your name?")

any Value with the double quotes, is a String Value, including numeral characters/symbols:

"1" is a STRING Value (NON-quantity Value: NOT able to do arithmetic), and NOT an integer value (quantity value: able to do arithmetic)

whereas

'1' is an INTEGER Value

  1. Booleans (special/reserved values of 'true' and 'false')

and more Non-Quanty Data Types, but they more advanced so leaving them out from here


now, in programming, we can also use non-quantity Data Types:

Assignment Operation:

x = "hi" // the "hi" String Value is STORED WITHIN ("assigned") the 'x' Variable VARIABLE

and if we then did this (a built-in quest Function) as the next operation within the same scripting: msg (x)

it would display/output: hi

in programming, we can't switch the scripting around with an Assignment Operation:

"hi" = x // ERROR!
5 = x // ERROR!

because the VARIABLE has to be on the left side and the VALUE_OR_EXPRESSION on the right side of the '=' sign (Assignment Operator)

whereas, since math isn't programming, we can switch it around:

x = 5 // NO error
5 = x // NO error

but if doing a Comparison Operation in programming, then we can switch it around of course (see the 'if (5 = x) {' line below):

// Assignment Operation:

x = GetRandomInt (1,10) // this, 'GetRandomInt (MIN,MAX)', built-in Randomization Function will randomly (inclusively) select a number from 1 to 10 (so: 1, 2, 3, 4, 5, 6, 7, 8, 9, or 10), which then gets STORED WITHIN ("assigned to") the 'x' Variable VARIABLE

// Comparison Operation (using the 'if' Script/Function, usually comparison operations use/require the 'if' Script/Function):

if (5 = x) {
  // 10% of this happening (1/10 chance/odds of it randomly selecting '5' for the value of 'x')
  msg ("TRUE")
} else {
  // 90% of this happening (9/10 chance/odds of it randomly selecting a number that is NOT '5' for the value of 'x')
  msg ("FALSE")
}

anyways...

back to using String Data Types, an example of more complex usage of it (we're using the Concatenation Operation, when using the '+' symbol with String Values):

x = "Hi"
msg (x)
x = x + ", how are you?"
msg (x)
x = x + " My name is HK."
msg (x)
x = x + " What is your name?"
msg (x)

----------

displayment/output:

Hi
Hi, how are you?
Hi, how are you? My name is HK.
Hi, how are you? My name is HK. What is your name?

Arithmetic VS Concatenation

Arithmetic:

5 + 5 = 10
55 + 55 = 110

Concatenation:

"5" + "5" = "55"
"55" + "55" = "5555"
"mama" + "mia" = "mamamia"
"mama" + "5" = "mama5"
"mama" + "5" + "mia" = "mama5mia"
"mama" + "_" + "mia" = "mama_mia"

also, the 'SPACE/WHITE-SPACE' is a String character/numeral/symbol just like "a" and "1" and "_", (see below)

"mama" + " " + "mia" = "mama mia"
"mama " + "mia" = "mama mia"
"mama" + " mia" = "mama mia"


anyways, finally back to your question...

if you set: player.alias = "HK"

then, anytime/any-where you use the 'player.alias' Attribute, it'll use/be the 'HK'

// example in code:

msg ("Name?")
get input {
  // pretend we typed in: HK
  // result = "HK"
  player.alias = result
  // player.alias = "HK"
}

// anywhere or whenever else in the game (so long as the 'player' Player Object exists/still exists), an example:

msg ("My name is " + player.alias + "! Don't you ever forget it!)

// output/displayment:

My name is HK! Don't you ever forget it!

lastly, in programming, we got Objects which can HOLD (have STORED WITHIN it) Attribute VARIABLES, whereas math/algebra only has Variable VARIABLES:

VARIABLE types in programming:

1. Variables:

examples

x = 5
p = 5
a = 5
example_integer_variable = 5
abcdefghijklmnopqrstuvwxyz = 5
foo = 5

x = 3.7
x = "hi"
x = "a"
x = "1"
x = "abc_123"
x = "hi, how are you? my name is HK, what is your name?"
x = true
x = false

2. Attributes:

examples:

// by default (and required too) 'player' and 'game' are already built-in (existing) Objects

player.x = 5
game.x = 5

create ("orc") // creates an 'orc' Object
orc.x = 5

player.alias = "HK"

game.introduction = "blah blah blah"

create ("orc_1") // creates an 'orc_1' Object
orc_1.alias = "orc"
orc_1.damage = 5
orc_1.dead = false

create ("club_1") // creates a 'club' Object
club_1.alias = "club"
club_1.damage = 10

orc_1.weapon = club_1

orc_1.damage = orc_1.weapon

3. Parameters: these are special VARIABLES for Functions, Commands, and etc, but, not going to try to explain them here

Using the GUI/Editor, it would roughly look like this, an example:

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

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

print [MESSAGE] Name?

add new script -> 'output' (or whatever) section/category -> 'get input' Script

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

set variable player.alias = [EXPRESSION] result

// this below can be done anywhere/when-ever in your game, but I'm going to have it still using the 'game.start' Script Attribute location ('game' Object -> 'Scripts' Tab -> 'start' Script), so continuing from above:

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

print [EXPRESSION] "My name is " + player.alias + "! Don't you ever forget it!

the '[MESSAGE]' option allows for TEXT ONLY:

print [MESSAGE] hi, how are you?
// NO error

x = "hi"
print [MESSAGE] x + ", how are you?"
// ERROR!


whereas...

the '[EXPRESSION]' option allows for you to directly type in whatever coding expression you want:

you can do any of these with it, examples:

TEXT ONLY:

print [EXPRESSION] "hi, how are you?"
// NO error

VARIABLE ONLY:

x = "hi, how are you?"
print [EXPRESSION] x
// NO error

both TEXT and VARIABLE:

x = "Hi"
print [EXPRESSION] x + ", how are you?"
// NO error


PS

forgot to explain this...

for non-coders, you'll want/need to use Attribute VARIABLES, as they're global and permanent (so long as the Object actually exists or still exists, of course)

Attribute VARIABLES:

NAME_OF_OBJECT.NAME_OF_ATTRIBUTE
// and
NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION

examples (in code):

player.alias = "HK"
player.strength = 100

player.flying = true
// or
player.flying = false

game.introduction = "blah blah blah"

create ("orc_1")
orc_1.alias = "orc"
orc_1.strength = 50
orc_1.dead = false // as usually you want a monster to start in an 'alive / not dead' state, lol

in the GUI/Editor, for setting/creating/changing Attributes: 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

for example:

player.alias = "HK"

using the GUI/Editor, would be this:

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

set variable player.alias = [EXPRESSION] "HK"

// NAME_OF_OBJECT: player
// NAME_OF_ATTRIBUTE: alias
// VALUE_OR_EXPRESSION: "HK"


you need to understand programming/coding, in order to be able to use Variable VARIABLES correctly, so that's why non-coders should/need-to use Attribute VARIABLES instead, as they're global and permanent, making their use much easier for you

(understanding 'scope' isn't easy for non-coders, which involves Variable VARIABLES, whereas using Attribute VARIABLES bypasses/ignores the issues of scope, making it much easier for non-coder, who don't understand scope)


Log in to post a reply.

Support

Forums