Player.Alias help.
Richer25
21 Mar 2019, 14:35Alright so I am probably being an idiot about this but I am working on a character creator and when I go to test it I put in a name but when I have the game spit the name back at me it just returns player.alias.
This is what I have so far.
player.alias = result
msg ("\"Hi, \" + player.alias")
The Pixie
21 Mar 2019, 16:44Try:
msg ("\"Hi, \"" + player.alias)
Put these things together in groups, linked by plus signs. Some groups are "literal", and have double quotes at each end (complicated by the \"
in there):
"\"Hi, \""
Other groups are variable, so do not:
player.alias
hegemonkhan
21 Mar 2019, 21:08(filler for getting my edited post, updated/posted)
just adding onto Pixie's post:
anything within double quotes is a String Value
msg ("\"Hi, \" + player.alias")
// msg ("[STRING VALUE: \"Hi,\" + player.alias]")
// output: "Hi," + player.alias
here's some examples:
msg ("Hi")
// output: Hi
string_variable = "Hi"
msg (string_variable)
// output: Hi
string_variable = "Hi"
msg (string_variable + ", how are you?")
// output: Hi, how are you?
string_variable = "Hi"
string_variable_2 = " My name is HK."
msg (string_variable + ", how are you?" + string_variable_2)
// output: Hi, how are you? My name is HK.
string_variable = "Hi"
string_variable_2 = " My name is HK."
msg (string_variable + ", how are you?" + string_variable_2 + " What is your name?")
// output: Hi, how are you? My name is HK. What is your name?
it's very easy to mess up the syntax (the double quotes and etc stuff), just have to be really careful
I actually had trouble understanding this stuff too when I started, and Pixie helped with it, and here's my own version of his help:
player.alias = "HK"
player.age_string = "adult"
player.age_integer = 18 // pretending
player.sex = "male"
player.class = "warrior"
player.race = "human"
msg (player.alias + " is an " + player.age_integer + " year old " + player.age_string + " " + player.sex + " " + player.race + " " + player.class + ".")
// output: HK is an 18 year old adult male human warrior.
Pixie's secret trick: break it up into "chunks"
Important: the '[SPACE]' is a character/symbol just as are the 'a', '1', and '&' characters/symbols
the chunks and connectors:
player.alias
+
" is an "
+
player.age_integer
+
" year old "
+
player.age_string
+
" "
+
player.sex
+
" "
+
player.race
+
" "
+
player.class
+
"."
// or just to condense it:
player.alias +
" is an "
+ player.age_integer +
" year old "
+ player.age_string +
" "
+ player.sex +
" "
+ player.race +
" "
+ player.class +
"."
------------
the 'msg' Script can have 3 different forms:
1. msg ("TEXT_ONLY")
2. msg (VARIABLE_ONLY)
3A. msg ("TEXT" + VARIABLE)
3B. msg (VARIABLE + "TEXT")
3(C to infinity). etc etc etc infinite combinations (and length of combinations) of use of: "TEXT" and VARIABLE, for some examples:
msg ("TEXT" + "TEXT" + "TEXT")
msg (VARIABLE + VARIABLE + VARIABLE)
msg ("TEXT" + VARIABLE + "TEXT" + VARIABLE)
msg (VARIABLE + "TEXT" + VARIABLE + "TEXT")
msg ("TEXT" + "TEXT" + "TEXT" + VARIABLE + VARIABLE + VARIABLE)
msg (VARIABLE + VARIABLE + VARIABLE + "TEXT" + "TEXT" + "TEXT")
msg ("TEXT" + VARIABLE + "TEXT" + "TEXT" + VARIABLE + VARIABLE)
msg (VARIABLE + "TEXT" + VARIABLE + VARIABLE + "TEXT" + "TEXT")
the Escape Character/Command:
is a special programming command, that either sets whatever immediately follows (NO SPACE) the escape character (a backslash) as a string (text) or does some special action (usually they are typewriter actions: tab, carriage return / new line, backspace, vertical tab / form feed, etc etc etc):
escape character: \
escape command: \CHARACTER_OR_SYMBOL
-------
for examples:
\" ---> causes the double quote to be a string (text), meaning it gets outputted/shown:
msg ("hi") // msg ( " [ hi ] " )
// output: hi
// VS:
msg ("\"hi\"") // msg ( " [ {\"} hi {\"} ] " )
// output: "hi"
\t ---> does the action of a [TAB] --- just as if you hit the [TAB] key on your keyboard
https://en.wikipedia.org/wiki/Escape_character
https://docs.python.org/2.0/ref/strings.html
https://docs.oracle.com/javase/tutorial/java/data/characters.html
https://en.cppreference.com/w/cpp/language/escape
Richer25
22 Mar 2019, 12:43Alright I managed to get that fixed up. Thanks a lot. I have another issue but since its not related to this I will just post a new thread about it.