Name field?

twin_centaurs
11 Sept 2016, 20:08

I'm just curious: is there a way to ask the player to enter their name and have that name show up throughout? Example:

What is your name?

(Input goes here)

Thank you, (typed-in name)

I know how to do it with regular javascript (could do it in Squiffy with no problem), but I was wondering if there was a specific way to do it in Quest without going into code mode.


onimike
11 Sept 2016, 21:53

Hey there yes its pretty simple here is basic code to add to game start script.

msg ("Whats your name?")
get input {
  set (player, "Alias", result)
}

Then when you want to check or show name just use this code you could make it a function or command for easy use.

msg ("Your name is "+player.Alias+".")

Mike


hegemonkhan
11 Sept 2016, 22:44

specific link help for your thread (see below, the 'character creation' link):

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

some guides:

http://docs.textadventures.co.uk/quest/guides/
http://textadventures.co.uk/forum/samples (more guides: libraries and code samples forum link)

my guide on Attributes and the 'if' Script (explanatory guide of quest's basic usage syntax):

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

since you know JS, you should be able to learn quest's code syntax quickly:

http://docs.textadventures.co.uk/quest/

the syntax is pretty simple, in code:

// Attribute scripting usage:

NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION
// example: player.strength = 100 // quest can parse what ATTRIBUTE/DATA TYPE it is, in this case, it's an 'int' (integer)

Function (calling) scripting usage:

NAME_OF_FUNCTION (ARGUMENT_1, ARGUMENT_2, ETC)
// example: set (player, "strength", 100)

creation/definition of Objects/Classes (similar to XML/HTML), as what I call 'creation' tags:

(Quest's 'Elements' are its user-level OBJECTS/CLASSES)

<NAME_OF_ELEMENT name="whatever">
  // content/body: Attributes and/or scripting (depends on the Element)
</NAME_OF_ELEMENT>

// example:

<object name="room">
  // content/body: Attributes (the 'Script' Type ATTRIBUTE/DATA allows for scripting, it's almost the same as the 'Verb' in the GUI~Editor) and/or other Objects
</object>

Attributes, as what I call 'creation' tags:

// (Attributes MUST BE INSIDE of an Element)

<attr name="NAME_OF_ATTRIBUTE" type="TYPE_OF_ATTRIBUTE/DATA">VALUE/CONTENT</attr> // horizontal form

// example:

<object name="player">
  <attr name="alias" type="string">HK</attr>
  <attr name="strength" type="int">100</attr>
</object>

The Pixie
12 Sept 2016, 07:26

onimike, use alias rather than Alias. Quest is expecting things to have an attribute called alias, and will use that in the panes on the right for example.


onimike
12 Sept 2016, 13:22

@The Pixie I tried alias and it gave me errors it couldn't find variable type then after using Alias it worked that's the only reason I posted it as I tested it in the online editor first. Is that not normal lol

Mike


The Pixie
12 Sept 2016, 14:30

I just tried your code, but with "alias", in the on-line editor and it worked fine for me.


onimike
12 Sept 2016, 18:43

@ThePixie Funny I can't get either working now lol