Obtaining a player's name

laserblue
28 Aug 2017, 21:38

I've been trying to figure out how to script asking for a player's name but the documentation and the automated script GUI is causing me trouble.

GUI
The first time, Run script
Ask question -text- What is your name?
After choosing, Run, script::

Now this is where I have trouble.
I want to have something like this in codeview
msg ("What is your name?")
get input {
player.name = result

I can paste it into codeview but I get an error message.
How do I do it the GUI way?


onimike
28 Aug 2017, 22:17

Make a function and in function go to code view and put this in

msg ("What is your name?")
get input {
  game.pov.alias = result
  Ask ("So your name is " +result+"?") {
    if (result = True) {
      msg ("Hello " +game.pov.alias+".")
    }
    else if (result = False) {
      namingcharacter
    }
  }
}

laserblue
28 Aug 2017, 22:26

I pasted the code into the curly brackets of The first time, Run script and check marked everything and it worked. Now I see what is going on. Thank you very much!


hegemonkhan
29 Aug 2017, 00:58

here's documentation that is (hopefully still) good/accurate:

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


though, learning Attribute and the 'if' Script usage is not easy if you're completely new to coding.


onimike
01 Sept 2017, 00:50

Not a problem, that is how i taught myself was putting code in gui and switching back to gui to see what was going on. Once you do that for a while most basic things will come to you very easy. Happy gaming glad it helped ;)


hegemonkhan
01 Sept 2017, 06:40

if you want to learn Attribute and the 'if' usage, the basics of coding/scripting, here's a guide on it:

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk

these two super scripts enable 90% of everything you want to do within your game