This code to input player's name won't function
Asyranok
14 Feb 2013, 22:48Hey guys, a piece of code is giving me a headache, here.
When I play my game, at the end of this introductory sequence, I ask the player to enter their first name. The text, "It is good to meet you, + name + !" is all that it ever returns.
What am I doing wrong, as I am trying to use input from the player to set that variable's value, and then re-display it to the player, before saving it for later? Thanks!
When I play my game, at the end of this introductory sequence, I ask the player to enter their first name. The text, "It is good to meet you, + name + !" is all that it ever returns.
What am I doing wrong, as I am trying to use input from the player to set that variable's value, and then re-display it to the player, before saving it for later? Thanks!
<start type="script"><![CDATA[
msg ("Your vision is blurry, but things soon come into focus. A sign says, \"Hyper-stasis Room\". The walls are a dull grey. Metal beds with glass canopies lie in two rows, ending at a collapsed wall, where rubble has consumed the rest of the machines.<br/><br/>Suddenly, you notice that you're not alone. Two figures stand nearby, watching you intently. You are not initially sure if your eyes are playing tricks on you, but these creatures are clearly not human. Their deep, black eyes, like two puddles of oil, study your every move. An amphibious complexion displays their vibrant skin colors in shockingly complex patterns, like an octopus in a threat display.<br/>")
msg ("<br/><br/>(Press any key to continue.)")
wait {
ClearScreen
msg ("One of the creatures breaks formation, and approaches you. You raise your arm and slide backwards in your stasis pod, in a feeble attempt to retreat. It raises its arm and begins interacting with a device on its wrist. A beam of light eminating from the object casts a wide net over your body, sliding from your toes to your head. <br/><br/>\"Hello. You can call me 'Duffy',\" the creature says in perfect English. <br/><br/>\"Don't be afraid. We're here to learn; not hurt,\" the second being steps forward and says.\"Ah, my name is Ziggy, by the way. What is yours?\" ")
msg ("<br/>\"I can't really remember my last name, but I think my first name was...\"")
PrintCentered ("<br/>(Enter first name)")
get input {
firstname = result
ClearScreen
msg ("Ziggy says, \"It is good to meet you,\" + firstname + \"!\"")
msg ("<br/>(Press any key to continue)")
wait {
ClearScreen
}
}
}
]]></start>
sonic102
15 Feb 2013, 03:42[quote="Asyranok"] I play my game, at the end of this introductory sequence, I ask the player to enter their first name. The text, "It is good to meet you, + name + !" is all that it ever returns. [quote]
Its supposed to be "It is good to meet you, " + name + "!"
Its supposed to be "It is good to meet you, " + name + "!"
HegemonKhan
15 Feb 2013, 04:11instead of doing:
firstname = result
~this is local (it exists only within the script it is in), to make it be able to be used anywhere, you got to set it to something that exists outside of the script, and since it is for your player's name, that's what you set it to, as the player (as an object) exists outside of your script.
so, if you want to use "firstname", then use this:
player.firstname = result
~OR~
game.pov.firstname = result
~what you've done by this, is to create, "firstname", as an attribute of the player (or game.pov) object, and thus you can call~use~apply this attribute now anywhere you want.
otherwise, do this instead (as "alias" is a pre-set attribute of the player or game.pov already):
player.alias = result
~OR~
game.pov.alias = result
and then change all your other "firstnames" to:
firstname -> player.alias
~OR~
firstname -> game.pov.alias
~OR~
firstname -> player.firstname
~OR~
firstname -> game.pov.firstname
-------
you got a problem with the syntax again (I tell you, syntax is so annoying, lol):
it needs to be changed to this:
you can't have quotes inside of the:
" + code + "
so:
" " + code + " " = doesn't work, [ unless you got them ( " + code + " ) next to each other ]
" \" + code + \" " = doesn't work (this MAYBE might work, but I highly doubt it, lol)
" ' + code + ' " = doesn't work (probably anyways, maybe it does... but I don't think so)
-----------
you got to have the quotes on the outside of the " + code + ", so it looks like this:
" + code + " " + code + " " + code + " = works
\" " + code + " \" = works
' " + code + " ' = works
------------------
unless you want it there, you don't really need your first "clearscreen" (the line below your playername = result).
firstname = result
~this is local (it exists only within the script it is in), to make it be able to be used anywhere, you got to set it to something that exists outside of the script, and since it is for your player's name, that's what you set it to, as the player (as an object) exists outside of your script.
so, if you want to use "firstname", then use this:
player.firstname = result
~OR~
game.pov.firstname = result
~what you've done by this, is to create, "firstname", as an attribute of the player (or game.pov) object, and thus you can call~use~apply this attribute now anywhere you want.
otherwise, do this instead (as "alias" is a pre-set attribute of the player or game.pov already):
player.alias = result
~OR~
game.pov.alias = result
and then change all your other "firstnames" to:
firstname -> player.alias
~OR~
firstname -> game.pov.alias
~OR~
firstname -> player.firstname
~OR~
firstname -> game.pov.firstname
-------
you got a problem with the syntax again (I tell you, syntax is so annoying, lol):
msg ("Ziggy says, \"It is good to meet you,\" + firstname + \"!\"")
it needs to be changed to this:
msg ("Ziggy says, \"It is good to meet you, " + player.alias OR game.pov.alias OR player.firstname OR game.pov.firstname + " ! \" ")
you can't have quotes inside of the:
" + code + "
so:
" " + code + " " = doesn't work, [ unless you got them ( " + code + " ) next to each other ]
" \" + code + \" " = doesn't work (this MAYBE might work, but I highly doubt it, lol)
" ' + code + ' " = doesn't work (probably anyways, maybe it does... but I don't think so)
-----------
you got to have the quotes on the outside of the " + code + ", so it looks like this:
" + code + " " + code + " " + code + " = works
\" " + code + " \" = works
' " + code + " ' = works
------------------
unless you want it there, you don't really need your first "clearscreen" (the line below your playername = result).
Asyranok
15 Feb 2013, 13:43Hegemon, you rock my socks. Thanks! That fixed it.