Player names

Ok, noob at coding here, so I've recently made like sort of a character creation thing, I am trying to get the player to type in whatever name they want,
and keep that name for the duration of the game, unfortunately the simple one they tell you to use in the tutorials, only work as a
one time thing. I searched the forms and changed the coding, but it still has errors. Here's what I have:

msg ("What's your name darling?")
get input {
player.name
=> {
msg ("Ah I knew somebody named player.name")
msg ("So, player.name I have a few things to explain to you.")
wait {
msg ("I'm the game master. ")
wait {
msg ("Because you see player.name Nobody escapes here without
me choosing for you to. ")
wait {
msg ("No one. ")
wait {
msg ("Have a nice Friday!")
wait {
SetBackgroundColour ("White")
SetForegroundColour ("Black")
ClearScreen
PrintCentered ("DAY 2")
ChangePOV (female2)
}
}
}
}
}
}
}


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


get input {

  // quest, for the 'get input' Script/Function, automatically (hidden from you) stores your input (a String Value) into the 'result' Variable VARIABLE, like/as so:

  // result = "YOUR_TYPED_IN_INPUT" // (remember this is not shown to you)

  // you then want to store it into a permanent and global-scope VARIABLE (which is an Attribute VARIABLE) such as the built-in 'alias' Attribute VARIABLE contained within the 'player' Player Object, like/as so:

  // (you can NOT change the 'name' String Attribute's Value, as it's the ID for Quest's OBJECTS)
  // (quest's 'alias' String Attribute is for this very purpose: to act as the name for the things in your game)

  player.alias = result // essentially you're doing this: player.alias <=== result <=== "YOUR_TYPED_IN_INPUT"

  // now that you got it stored into an Attribute VARIABLE, you can use that Attribute VARIABLE whenever/where-ever and as many times, as you wish (as an Attribute VARIABLE is global in scope and is "permanent" --- so long as the Object containing the Attribute, exists or still exists, and also as long as the Attribute exists or still exists), using two different syntax methods:

  // syntax method 1: using the 'text processor commands' way:

  msg ("Ah I knew somebody named {player.alias}.")

  // syntax method 2: the 'concatenation' way:

  msg ("Ah I knew somebody named " + player.alias + ".")

}

let's use the real world to understand these programming concepts:

the 'human_1' Object:

and its Attributes:

name: "human_1" // think of this as being this organism's 'DNA' (which is its ID)
alias: "john doe"
kingdom: "animalia"
phylum: "chordata"
class: "mammalia"
order: "primate"
family: "greater ape"
genus: "homo"
species: "human"
race: "european"
sex: "male"
age_integer: 18
age_string: "adult"
height_double: 6.0
height_string: "tall"
weight_integer: 220
weight_string: "average"
favorite_food_stringlist: (1) hamburger, (2) pizza, and (3) ice cream


the 'human_2' Object:

and its Attributes:

name: "human_2" // think of this as being this organism's 'DNA' (which is its ID)
alias: "jane doe"
kingdom: "animalia"
phylum: "chordata"
class: "mammalia"
order: "primate"
family: "greater ape"
genus: "homo"
species: "human"
race: "australian"
sex: "female"
age_integer: 8
age_string: "child"
height_double: 4.0
height_string: "average"
weight_integer: 90
weight_string: "average"
favorite_food_stringlist: (1) salad, (2) almonds, and (3) yogurt


I can refer to whatever Attribute of Whatever Object, so long as that Object (and its Attribute) exists or still exists:

msg (human_1.alias + " is " + human_1.age_integer + " years old")
msg (human_2.alias + " is " + human_2.age_integer + " years old")

I can even change the Values of those Attributes as well (EXCEPT for the 'name' Attribute):

(for example if 10 years have gone by, then obviously their ages have changed)

human_1.age_integer = 28 // it was '18'

human_2.age_integer = 18 // it was '8'
human_2.age_string = "adult" // it was 'child'


now let's just say that we got this:

name = "sam smith"
age_integer = 18

and ten years go by (different time scope):

age_integer = 28

msg (name + "'s age is " + age_integer + " years old")

ERROR: who's or what's age is now 28?

the 'name' only existed in the 10 years ago scope
so it doesn't exist in the 10 years later scope
hence the error

whereas for example:

the 'human_1.age_integer' exists within the "scope" of the 'human_1' Object

and the 'human_1' Object still exists (as it wasn't deleted from existence)

and the 'human_1.age_integer' Attribute still exists (as it wasn't deleted from existence)


Is this the tutorial you found? It is a bit buried, so might not be.

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

Looks like it should work fine (same as HK is saying above). Note that you need to set the "alias" attribute; the "name" attribute cannot be changed during play as Quest uses that to track each object.


@ Pixie:
and
@ btt:

he got some syntax mistakes that need to be fixed up:

get input {

  player.name // here

  => { // here

   msg ("Ah I knew somebody named player.name") // here

   msg ("So, player.name I have a few things to explain to you.") // here

   // (a few waits+msgs: and then the below line nested line):

   msg ("Because you see player.name Nobody escapes here without me choosing for you to. ") // here

  } // here (the ending tag of the syntax mistake of using the '=> {' script variable operator)

}

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


@ btt:

here's it fixed up for you:

msg ("What's your name darling?")

get input {

  player.alias = result

  msg ("Ah I knew somebody named {player.alias}")

  msg ("So, {player.alias} I have a few things to explain to you.")

  wait {

    msg ("I'm the game master. ")

    wait {

      msg ("Because you see {player.alias} nobody escapes here without me choosing for you to. ")

      wait {

        msg ("No one. ")

        wait {

          msg ("Have a nice Friday!")

          wait {

            SetBackgroundColour ("White")

            SetForegroundColour ("Black")

            ClearScreen

            PrintCentered ("DAY 2")

            ChangePOV (female2)

          }

        }

      }

    }

  }

}

if you don't want the line spacing (it was just to make it easier for you to read the code):

msg ("What's your name darling?")
get input {
  player.alias = result
  msg ("Ah I knew somebody named {player.alias}")
  msg ("So, {player.alias} I have a few things to explain to you.")
  wait {
    msg ("I'm the game master. ")
    wait {
      msg ("Because you see {player.alias} nobody escapes here without me choosing for you to. ")
      wait {
        msg ("No one. ")
        wait {
          msg ("Have a nice Friday!")
          wait {
            SetBackgroundColour ("White")
            SetForegroundColour ("Black")
            ClearScreen
            PrintCentered ("DAY 2")
            ChangePOV (female2)
          }
        }
      }
    }
  }
}

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

Support

Forums