Creating a "check health" command with 'if' statement
Olzme
03 Mar 2014, 18:18Hey,
I'm making a game that won't have the UI windows to the right. I want the player to be able to check his or her health, but I don't want to use the print msg (expression) +player.health and just show a number:
I want to be able to use an "if" statement so that when the player inputs the command "how do I feel", the game will respond in the form of a general statement.
So for example
If: object attribute equals, object - player, attribute - health, = 100
Then: print message "I feel completely fine."
Else If: object attribute equals, object - player, attribute - health, <100 but >90
Then: print message "I don't feel too bad."
Else If: object attribute equals, object - player, attribute - health, =<90 but >80
Then: print message "I feel a bit funny."
Else If: object attribute equals, object - player, attribute - health, =<90 but >80
Then: print message "I'm not feeling that great."
and so on.
The problem is in the GUI all I see is a
" If: object attribute equals, object [], attribute[], =[] "
function. I want to be able to use =>, =<, <, and > but it seems that it only allows me to use the if statement if a certain attribute equals a value. Adding in the "<" and ">" symbols gives me an error message saying it didn't expect the symbol.
Could someone help me with the code so that I can write an if statement that uses "is less than or equals to", "is more than", and "is less than"?
Thanks so much in advance.
I'm making a game that won't have the UI windows to the right. I want the player to be able to check his or her health, but I don't want to use the print msg (expression) +player.health and just show a number:
I want to be able to use an "if" statement so that when the player inputs the command "how do I feel", the game will respond in the form of a general statement.
So for example
If: object attribute equals, object - player, attribute - health, = 100
Then: print message "I feel completely fine."
Else If: object attribute equals, object - player, attribute - health, <100 but >90
Then: print message "I don't feel too bad."
Else If: object attribute equals, object - player, attribute - health, =<90 but >80
Then: print message "I feel a bit funny."
Else If: object attribute equals, object - player, attribute - health, =<90 but >80
Then: print message "I'm not feeling that great."
and so on.
The problem is in the GUI all I see is a
" If: object attribute equals, object [], attribute[], =[] "
function. I want to be able to use =>, =<, <, and > but it seems that it only allows me to use the if statement if a certain attribute equals a value. Adding in the "<" and ">" symbols gives me an error message saying it didn't expect the symbol.
Could someone help me with the code so that I can write an if statement that uses "is less than or equals to", "is more than", and "is less than"?
Thanks so much in advance.

jaynabonne
03 Mar 2014, 21:19Use a pure expression:
if [expression] player.health = 100
else if [expression] player.health > 90
else if [expression] player.health > 80
etc
Note that you don't need half of each of your "if" statements, as shown above, as the previous "if" has already covered it (e.g. if "player.health > 90" is not true, then you know player.health <= 90, so you don't need to check it again). That assumes, of course, that health is <= 100 to begin with.
if [expression] player.health = 100
else if [expression] player.health > 90
else if [expression] player.health > 80
etc
Note that you don't need half of each of your "if" statements, as shown above, as the previous "if" has already covered it (e.g. if "player.health > 90" is not true, then you know player.health <= 90, so you don't need to check it again). That assumes, of course, that health is <= 100 to begin with.
Olzme
04 Mar 2014, 15:47Thanks!
I guess I was making it harder than it had to be.
I guess I was making it harder than it had to be.

Mareus
30 May 2014, 23:21jaynabonne wrote:Use a pure expression:
if [expression] player.health = 100
else if [expression] player.health > 90
else if [expression] player.health > 80
etc
Note that you don't need half of each of your "if" statements, as shown above, as the previous "if" has already covered it (e.g. if "player.health > 90" is not true, then you know player.health <= 90, so you don't need to check it again). That assumes, of course, that health is <= 100 to begin with.
Where do you put these commands in? Is it in game/player? Or just room->player?

jaynabonne
31 May 2014, 00:19I'm not sure of what your asking, due to the way you asked it.
If you mean where do you put the *command* that contains these *statements* as its script, then:
If you want it to be global command, then put it in the global command list under game/commands. If you want it to be specific to a particular room, then add the command under the desired room.
If you mean where do you put the listed *script statements*, then it depends on what you're trying to do. In this case, the OP is intending to add a command to the game called "check health", and it would have those kinds of "if" statements in the script for that command. Someone could also create a turn script it they want the health to be checked after each command, etc.
(And I don't know what you mean by game/player or room->player, so I won't address that.)
I hope I didn't botch that answer too much.
If you mean where do you put the *command* that contains these *statements* as its script, then:
If you want it to be global command, then put it in the global command list under game/commands. If you want it to be specific to a particular room, then add the command under the desired room.
If you mean where do you put the listed *script statements*, then it depends on what you're trying to do. In this case, the OP is intending to add a command to the game called "check health", and it would have those kinds of "if" statements in the script for that command. Someone could also create a turn script it they want the health to be checked after each command, etc.
(And I don't know what you mean by game/player or room->player, so I won't address that.)
I hope I didn't botch that answer too much.

Mareus
31 May 2014, 10:37jaynabonne wrote:I'm not sure of what your asking, due to the way you asked it.
If you mean where do you put the *command* that contains these *statements* as its script, then:
If you want it to be global command, then put it in the global command list under game/commands. If you want it to be specific to a particular room, then add the command under the desired room.
If you mean where do you put the listed *script statements*, then it depends on what you're trying to do. In this case, the OP is intending to add a command to the game called "check health", and it would have those kinds of "if" statements in the script for that command. Someone could also create a turn script it they want the health to be checked after each command, etc.
(And I don't know what you mean by game/player or room->player, so I won't address that.)
I hope I didn't botch that answer too much.
Sorry, I guess I should have been more clear. You see, I am using a script for creating a character that I found here:
http://quest5.net/wiki/Character_Creation
So, I tried using the command examine XXX or look at XXX (XXX- stands for the name you chose in the character creator). When I type this command in the game I always get the reply: "Looking good." This is even when I lose some health in the game. Obviously when you lose health you should not be looking good, so I thought implementing some scripts that would fix this problem.
Now, I did as you suggested with the global commands and it works, but since I wasnt very clear I still have a problem with the program not recognizing the name you choose in the game. So, your solution works if I type the command that applies to generic names like look at; examine; check player, health, status, etc. What I need to know is how to make the program check player's health if one is using a player.alias from the character creator? Or how does one erase or edit the "Looking good" comment. I cant find it anywhere, so I have no idea where it is coming from.
PS. While I am at it, I am also wondering if there is a way to include the description of your custom name (player.alias), gender and class when you look at your player. For example, when I type examine Mareus, I want also to be able to get a description of how you look like based on what you chose in the character creator. So for the script I posted it would be: "You are Mareus, male knight. You are wounded and should seek a healer."
"You are a male knight. You are currently wounded."

jaynabonne
31 May 2014, 10:44Here's how you do it:
1) Click on the Player object in the editor window
2) Click on the resulting Features tab for the player.
3) Check the check box that says "Player: player can become this object".
4) A new "Player" tab should now appear. Click it.
5) You'll find the "look at" description down the page a bit. To make it a script, change its dropdown from "Text" to "Run script", and then you can drop in whatever you like.
Why the Player object doesn't default to actually being a "player" object, I don't know. But that's how you find that "Looking good." text anyway.
(I'm also not sure what the "Player can(not) be a player" dropdown is at the top of that Player page. I suppose I should figure that out at some point.)
1) Click on the Player object in the editor window
2) Click on the resulting Features tab for the player.
3) Check the check box that says "Player: player can become this object".
4) A new "Player" tab should now appear. Click it.
5) You'll find the "look at" description down the page a bit. To make it a script, change its dropdown from "Text" to "Run script", and then you can drop in whatever you like.
Why the Player object doesn't default to actually being a "player" object, I don't know. But that's how you find that "Looking good." text anyway.

(I'm also not sure what the "Player can(not) be a player" dropdown is at the top of that Player page. I suppose I should figure that out at some point.)
Mareus
31 May 2014, 11:09jaynabonne wrote:Here's how you do it:
1) Click on the Player object in the editor window
2) Click on the resulting Features tab for the player.
3) Check the check box that says "Player: player can become this object".
4) A new "Player" tab should now appear. Click it.
5) You'll find the "look at" description down the page a bit. To make it a script, change its dropdown from "Text" to "Run script", and then you can drop in whatever you like.
Why the Player object doesn't default to actually being a "player" object, I don't know. But that's how you find that "Looking good." text anyway.
(I'm also not sure what the "Player can(not) be a player" dropdown is at the top of that Player page. I suppose I should figure that out at some point.)
Thanks it worked. Sorry for being a pain, but reading tutorials is very limiting way to learn how to use the software, so I have one more question which you probably missed because you answered at the same time as I edited my last post.
I am also wondering if there is a way to include the description of your custom name (player.alias), gender and class when you look at your player. For example, when I type examine Mareus, I want also to be able to get a description of how you look like based on what you chose in the character creator. So for the script I posted it would be: "You are Mareus, male knight. You are wounded and should seek a healer." I already fixed the part about health. I am hoping that the other part is equally simple.
PS. I am very grateful for your responses. You saved me days, perhaps even weeks of frustration.

jaynabonne
31 May 2014, 11:31The simple way to do it is to just add a "Print a message (no line-break)" script command in front of the status print out. Set the text to "You are {player.alias}, a {player.gender} {player.class}." (with no quotes). In script:
The text processor makes things like this quite simple (easier than concatenating strings together).
OutputTextNoBr ("You are {player.alias}, a {player.gender} {player.class}.")
The text processor makes things like this quite simple (easier than concatenating strings together).
Mareus
31 May 2014, 13:22jaynabonne wrote:The simple way to do it is to just add a "Print a message (no line-break)" script command in front of the status print out. Set the text to "You are {player.alias}, a {player.gender} {player.class}." (with no quotes). In script:OutputTextNoBr ("You are {player.alias}, a {player.gender} {player.class}.")
The text processor makes things like this quite simple (easier than concatenating strings together).
Sorry for a stupid question, but where can I find the "status print out"? I ve looked through all the tabs three times and I just cant see it? Do I have to activate something to get to it?

jaynabonne
31 May 2014, 13:32Sorry, bad word choice. I'm assuming that you have gotten it working where you have added code to print out the status of the player in your player's "look at", the part you have written as " You are wounded and should seek a healer" in your question. Since you want it to be "You are Mareus, male knight. You are wounded and should seek a healer", I'm saying to add the code I suggested before that health/status print out you already have in place.
HegemonKhan
31 May 2014, 18:53Jay has already answered most of your questions, but I'll comment anyways too, hehe.
0. the two most powerful~useful scripts, which will allow you to do almost anything and everything that you want to do:
in the GUI~Editor:
run as script -> add a script -> scripts -> if... -> [EXPRESSION] -> (type in whatever you want it to do ~ though you'll have to know how to write using quest code of course)
run as script -> add a script -> variables -> set a variable or an attribute -> (set it up)
in code:
if (Object.Attribute = Value_or_Expression) {
-> // script(s)
] else if (Object.Attribute = Value_or_Expression) {
-> // script(s)
} else {
-> // script(s)
}
if (orc.condition = "dead") {
-> msg ("The orc is dead")
}
~OR~
if (orc.condition = "dead") {
-> msg ("The orc is dead")
} else if (orc.condition = "alive") {
-> msg ("the orc kills you")
-> msg ("GAME OVER")
-> finish
}
~OR~
if (orc.condition = "dead") {
-> msg ("The orc is dead")
} else if (orc.condition = "alive") {
-> msg ("the orc kills you")
-> msg ("GAME OVER")
-> finish
} else if (orc.condition = "drunk") {
-> msg ("The orc is drunk")
} else {
-> msg ("The orc is asleep")
}
An Attribute ('savable and loadable' ~ can be used~referenced~called upon within any script in the game, so long as the object still exists of course):
Object.Attribute = Value_or_Expression
A Variable (can only be used~referenced~called upon within that same script it is in):
Attribute = Value_or_Expresion
------------------------
1. this is a bit of an annoyance, that I too (and many other people as well) was confused by, as it's not exactly made-known to people:
Your Player Objects can both be used as Player Objects and as Object Objects (like an npc~townsperson or a table), and thus you've got 2 descriptions and locations of those descriptions in the GUI~Editor (and as Jay mentioned, you may have to also set~check the box, for your Player Object first as 'Can be a Player Object' too). "You look good." is the default description for Object Objects. So, if you got your Player Object's player-object-description set up (typed in), but your Player Object isn't set (or isn't currently being used~controlled as a Player Object during game play), then you'll see the object-object-description of (if still as the default ~ you haven't typed in your own custom message for it) "You are looking good." shown~displayed during game play for your Player Object.
I believe it is the second tab from the left (can't remember what it is called... ?setup?) for an Object, that has the 'description' for your Object as an Object Object.
And, the 'Player' tab, has the player-object-description (you may have to check the box for 'can be a player' first, for you to see the player-object-description box, if your Player Object isn't already set as this), for when your Player Object is being controlled currently as a player object during game play.
2. Character Creation
this is a very good 'next step' after doing the tutorial, though it's quite a step up in difficulty, but that's okay, as it teaches you to understand quest and the coding world designs much better.
(you can see my own progress going from a total noob to quest and to coding, to where I am now, in the thread that I created called 'HK's noob help me thread" ~ do a search for it, hehe)
Objects hold Attributes, so this is your way of 'saving and loading' Attributes for then being able to use them within any script that you want (so long as the Object still exists, aka you don't 'remove' or 'destroy' the object, hehe).
in GUI~Editor:
(whatever) Object -> Attributes (tab) -> Attributes -> Add ->
Object: (whatever)
Attribute Name: (whatever)
Attribute Type: (you decide: string, integer~int~non decimal using number, double~decimal using number, boolean~flag, script~verb, string list, object list, string dictionary, object dictionary, script dictionary, or object)
Attribute Value: (depends upon your Attribute Type, and then it's 'whatever' you type in for it)
Object: player
Attribute Name: strength_integer
Attribute Type: int
Attribute Value: 100
you're 'attaching' the Attribute to the~an Object
in code, it looks like this:
as a creation 'tag':
<object name="whatever">
-> <inherit name="editor_object" />
-> <attr name="whatever" type="you decide">your_typed_in_value</attr>
</object>
(using my own labeling system, hehe)
<object name="player">
-> <inherit name="editor_object" />
-> <inherit name="editor_player" />
-> <alias>HK</alias> // this is a quest-auto done-code-shortened-form-for-Strings-only of: <attr name="alias" type="string">HK</attr>
-> <attr name="strength_integer" type="int">100</attr>
-> <attr name="favorite_color_string" type="string">black</attr> // I could have typed instead (as it's a String): <favorite_color_string>black</favorite_color_string>
-> <attr name="favorite_colors_string_list" type="simplestringlist">black;red</attr>
-> <attr name="flying_boolean" type="boolean">true</attr>
-> <attr name="damage_double" type="double">572.09</attr>
</attr>
as a script (which does both creation~setting up or changing~alterning~re-setting up):
Object.Attribute = Value_or_Expression
Object.Object.Attribute = Value_or_Expression
(the dot~period 'attaches' things, Object to Object and~or Attribute to Object, together)
player.alias = "HK"
player.strength_integer = 100
player.favorite_color_string = "black"
player.sword_weapon_object.damage_double = 537.29
player.flying_boolean = true
player.favorite_colors_string_list = split ("black;red", ";")
player.y = (x + 5) / 2 - 50
orc.fight_verb = (see below)
<object name="orc">
-> <inherit name="editor_object" />
-> <attr name="dead" type="boolean">false</attr>
-> // this below is what a Verb looks like in code:
-> <attr name="fight" type="script">
->-> if (orc.dead = true) {
->->-> msg ("The orc is already dead, silly.")
->-> } else if (orc.dead = false) {
->->-> orc.dead = true
->->-> msg ("You attack and kill the orc.")
->-> }
-> </attr>
-> // this below adds the 'fight' verb's button and hyperlink blue text to the game, during game play:
-> <attr name="displayverbs" type="listextend">Fight</attr>
</object>
--------------
you can also just do 'variables' too:
('Variables' are just Strings~Attributes that are NOT 'attached' to an Object, aka no dot~period)
(and because of this, you can only use them within the script they're within, you can't use them in some other outside script, as they're not 'saved', and thus can't be 'loaded' within that other outside script)
Variable = Value_or_Expression
result = "red"
result = 9
handled = false
value = 9
value = "red"
you_go_first = false
y = x
y = x + 5
---------------
so... for character creation:
game (Object) -> Scripts (Tab) -> Start Script -> Add ->
(the 'game' Game Object's 'start' Script Attribute is the very first thing that the game does, even before displaying the room description, so this is a common place to put your 'character creation' script~function block, but you can add your scripts~functions anywhere too: as~within Objects' Verbs, as~within Commands, as~within other Functions, as~within TurnScripts, as~within Timers, as~within other Scripts, and etc. For an example, using character creation, maybe I want a sci-fi tube machine Object that you discover halfway through game play within the game which will create more Player Objects, as you can switch between, aka control, multiple Player Objects, or even maybe creating non-player Objects, like for~as having team~party members, hehe)
(in code, as it's much quicker for me, lol)
msg ("what is your name?")
get input {
-> // quest's 'get input' function automatically (and hiddenly) sets: result = your_typed_in_input_during_game_play
-> // however, we want to set that to an Attribute (Object.Attribute), aka 'save' it, so that we can use ('load') it anywhere (same as 'calling a function', but we're 'creating and saving, for then calling~referencing~using' an Attribute later in some other script within our game, instead of a Function, hehe):
-> player.alias = result
-> show menu ("What is your gender?", split ("male;female", ";"), false) {
-> -> // quest's 'show menu' function automatically (and hiddenly) sets: result = your_choice from the pop up menu's selection of choices~options
->-> // I use 'gender_string' because I don't want to overwrite the already built-in Grammer 'gender = he, she, or it' Attribute and functionality of quest's core coding
->-> player.gender_string = result
->-> show menu ("What is your race?", split ("human;dwarf;elf", ";"), false) {
->->-> player.race = result
->->-> show menu ("What is your class?", split ("warrior;cleric;mage;thief", ";"), false) {
->->->-> player.class = result
->->->-> msg (player.alias + " is a " + player.gender_string + " " + player.race + " " + player.class + ".")
->->-> }
->-> }
-> }
}
<function name="level_up_function"><![CDATA[
-> if (player.level_up_points > 0) {
->-> if (player.gender_string = "male") {
->->-> player.strength = player.strength + 1
->-> } else if (player.gender_string = "female") {
->->-> player.agility = player.intelligence + 1
->-> }
->-> if (player.race = "human") {
->->-> player.strength = player.strength + 1
->->-> player.intelligence = player.intelligence + 1
->-> } else if (player.race = "dwarf") {
->->-> player.strength = player.strength + 2
->-> } else if (player.race = "elf") {
->->-> player.intelligence = player.intelligence + 2
->-> }
->-> if (player.class = "human") {
->->-> // you get the idea... etc etc etc... lol
->-> }
->-> player.level_up_points = player.level_up_points - 1
->-> level_up_function // (in the GUI~Editor, this is: 'call a function' Script)
-> }
]]></function>
<turnscript name="global_turnscript">
-> <enabled />
-> <script>
->-> level_up_function // (in the GUI~Editor, this is: 'call a function' Script)
->-> game.turns = game.turns + 1
-> </script>
</turnscript>
--------------------
the hardest part of character creation is getting the display (msg~print a message) to work:
in the GUI~Editor: run as script -> add a script -> output -> Print a message -> [EXPRESSION] -> (see below)
you need to break it down into 2 types of 'chunks' to understand how to type it correctly (correct syntax):
The 2 'Chunks':
1. " text "
2. + Object.Attribute +
thus the chunks for:
player.alias = "HK"
player.gender_string = "male"
player.race = "human"
player.class = "warrior"
msg (player.alias + " is a " + player.gender_string + " " + player.race + " " + player.class + ".")
// outputs~returns~displays~shows: HK is a male human warrior.
player.alias +
" is a "
+ player.gender_string +
" (space) "
+ player.race +
" (space) "
+ player.class +
"."
this will help you greatly type it out correctly without errors, but it'll still take a lot of practice and frustration, lol
this took me quite a while to be able to do this, and I still have trouble with it even now, though understanding the '2 chunks' concept really helps a lot.
----------
here's another example:
player.damage = 100
monster.alias = "orc"
monster.hp = 500
(pretend we got a damage script, doing the subtracting: monster.hp = monster.hp - player.damage: 500-100)
(remember that you *MUST* set the 'print a message' to [EXPRESSION], as this enables the use of your 'Object.Attribute' calls~references~loading of your Attributes in the message)
msg ("You do " + player.damage + " damage to the " + monster.alias + ", leaving it with only " + monster.hp + " HP left.")
outputs: You do 100 damage to the orc, leaving it with only 400 HP left.
can you break it down into the correct chunks?
answer:
"You do "
+ player.damage +
" damage to the "
+ monster.alias +
", leaving it with only "
+ monster.hp +
" HP left."
---------------------
"room" (object) -> Room Descriptions (or whatever it is called) (tab) -> Description -> run as script -> add a script -> output -> print a message -> [EXPRESSION] -> (see below, but in code though)
room.alias = "catacombs"
room.light_or_dark = "dark"
room.length = 44
friend.alias = "mike"
friend.condition = "dead"
monster.alias = "man-eating crocodile"
room.walls_conditiion = "blood"
player.condition = "sick"
friend.gender = "him"
msg ("The " + room.alias + " is a " + room.light_or_dark + " maze, that is " + room.length + " miles long, that your best friend, " + friend.alias + ", got lost in, and is now " + friend.condition + ". You hope to be able to find " + friend.gender + " soon, as you don't want to be eaten up by the " + monster.alias + ". The " + room.alias + "' walls are smeared with " + room.walls_condition + ", and you feel " + player.condition + " already. Yada Yada Yada")
outputs: The catacombs is a dark maze, that is 44 miles long, that your best friend, Mike, got lost in, and is now dead. You hope to be able to find him soon, as you don't want to be eaten up by the man-eating crocodile. The catacombs' walls are smeared with blood, and you feel sick already. Yada Yada yada
hehe, ...hopefully I didn't make any mistakes, lol
0. the two most powerful~useful scripts, which will allow you to do almost anything and everything that you want to do:
in the GUI~Editor:
run as script -> add a script -> scripts -> if... -> [EXPRESSION] -> (type in whatever you want it to do ~ though you'll have to know how to write using quest code of course)
run as script -> add a script -> variables -> set a variable or an attribute -> (set it up)
in code:
if (Object.Attribute = Value_or_Expression) {
-> // script(s)
] else if (Object.Attribute = Value_or_Expression) {
-> // script(s)
} else {
-> // script(s)
}
if (orc.condition = "dead") {
-> msg ("The orc is dead")
}
~OR~
if (orc.condition = "dead") {
-> msg ("The orc is dead")
} else if (orc.condition = "alive") {
-> msg ("the orc kills you")
-> msg ("GAME OVER")
-> finish
}
~OR~
if (orc.condition = "dead") {
-> msg ("The orc is dead")
} else if (orc.condition = "alive") {
-> msg ("the orc kills you")
-> msg ("GAME OVER")
-> finish
} else if (orc.condition = "drunk") {
-> msg ("The orc is drunk")
} else {
-> msg ("The orc is asleep")
}
An Attribute ('savable and loadable' ~ can be used~referenced~called upon within any script in the game, so long as the object still exists of course):
Object.Attribute = Value_or_Expression
A Variable (can only be used~referenced~called upon within that same script it is in):
Attribute = Value_or_Expresion
------------------------
1. this is a bit of an annoyance, that I too (and many other people as well) was confused by, as it's not exactly made-known to people:
Your Player Objects can both be used as Player Objects and as Object Objects (like an npc~townsperson or a table), and thus you've got 2 descriptions and locations of those descriptions in the GUI~Editor (and as Jay mentioned, you may have to also set~check the box, for your Player Object first as 'Can be a Player Object' too). "You look good." is the default description for Object Objects. So, if you got your Player Object's player-object-description set up (typed in), but your Player Object isn't set (or isn't currently being used~controlled as a Player Object during game play), then you'll see the object-object-description of (if still as the default ~ you haven't typed in your own custom message for it) "You are looking good." shown~displayed during game play for your Player Object.
I believe it is the second tab from the left (can't remember what it is called... ?setup?) for an Object, that has the 'description' for your Object as an Object Object.
And, the 'Player' tab, has the player-object-description (you may have to check the box for 'can be a player' first, for you to see the player-object-description box, if your Player Object isn't already set as this), for when your Player Object is being controlled currently as a player object during game play.
2. Character Creation
this is a very good 'next step' after doing the tutorial, though it's quite a step up in difficulty, but that's okay, as it teaches you to understand quest and the coding world designs much better.
(you can see my own progress going from a total noob to quest and to coding, to where I am now, in the thread that I created called 'HK's noob help me thread" ~ do a search for it, hehe)
Objects hold Attributes, so this is your way of 'saving and loading' Attributes for then being able to use them within any script that you want (so long as the Object still exists, aka you don't 'remove' or 'destroy' the object, hehe).
in GUI~Editor:
(whatever) Object -> Attributes (tab) -> Attributes -> Add ->
Object: (whatever)
Attribute Name: (whatever)
Attribute Type: (you decide: string, integer~int~non decimal using number, double~decimal using number, boolean~flag, script~verb, string list, object list, string dictionary, object dictionary, script dictionary, or object)
Attribute Value: (depends upon your Attribute Type, and then it's 'whatever' you type in for it)
Object: player
Attribute Name: strength_integer
Attribute Type: int
Attribute Value: 100
you're 'attaching' the Attribute to the~an Object
in code, it looks like this:
as a creation 'tag':
<object name="whatever">
-> <inherit name="editor_object" />
-> <attr name="whatever" type="you decide">your_typed_in_value</attr>
</object>
(using my own labeling system, hehe)
<object name="player">
-> <inherit name="editor_object" />
-> <inherit name="editor_player" />
-> <alias>HK</alias> // this is a quest-auto done-code-shortened-form-for-Strings-only of: <attr name="alias" type="string">HK</attr>
-> <attr name="strength_integer" type="int">100</attr>
-> <attr name="favorite_color_string" type="string">black</attr> // I could have typed instead (as it's a String): <favorite_color_string>black</favorite_color_string>
-> <attr name="favorite_colors_string_list" type="simplestringlist">black;red</attr>
-> <attr name="flying_boolean" type="boolean">true</attr>
-> <attr name="damage_double" type="double">572.09</attr>
</attr>
as a script (which does both creation~setting up or changing~alterning~re-setting up):
Object.Attribute = Value_or_Expression
Object.Object.Attribute = Value_or_Expression
(the dot~period 'attaches' things, Object to Object and~or Attribute to Object, together)
player.alias = "HK"
player.strength_integer = 100
player.favorite_color_string = "black"
player.sword_weapon_object.damage_double = 537.29
player.flying_boolean = true
player.favorite_colors_string_list = split ("black;red", ";")
player.y = (x + 5) / 2 - 50
orc.fight_verb = (see below)
<object name="orc">
-> <inherit name="editor_object" />
-> <attr name="dead" type="boolean">false</attr>
-> // this below is what a Verb looks like in code:
-> <attr name="fight" type="script">
->-> if (orc.dead = true) {
->->-> msg ("The orc is already dead, silly.")
->-> } else if (orc.dead = false) {
->->-> orc.dead = true
->->-> msg ("You attack and kill the orc.")
->-> }
-> </attr>
-> // this below adds the 'fight' verb's button and hyperlink blue text to the game, during game play:
-> <attr name="displayverbs" type="listextend">Fight</attr>
</object>
--------------
you can also just do 'variables' too:
('Variables' are just Strings~Attributes that are NOT 'attached' to an Object, aka no dot~period)
(and because of this, you can only use them within the script they're within, you can't use them in some other outside script, as they're not 'saved', and thus can't be 'loaded' within that other outside script)
Variable = Value_or_Expression
result = "red"
result = 9
handled = false
value = 9
value = "red"
you_go_first = false
y = x
y = x + 5
---------------
so... for character creation:
game (Object) -> Scripts (Tab) -> Start Script -> Add ->
(the 'game' Game Object's 'start' Script Attribute is the very first thing that the game does, even before displaying the room description, so this is a common place to put your 'character creation' script~function block, but you can add your scripts~functions anywhere too: as~within Objects' Verbs, as~within Commands, as~within other Functions, as~within TurnScripts, as~within Timers, as~within other Scripts, and etc. For an example, using character creation, maybe I want a sci-fi tube machine Object that you discover halfway through game play within the game which will create more Player Objects, as you can switch between, aka control, multiple Player Objects, or even maybe creating non-player Objects, like for~as having team~party members, hehe)
(in code, as it's much quicker for me, lol)
msg ("what is your name?")
get input {
-> // quest's 'get input' function automatically (and hiddenly) sets: result = your_typed_in_input_during_game_play
-> // however, we want to set that to an Attribute (Object.Attribute), aka 'save' it, so that we can use ('load') it anywhere (same as 'calling a function', but we're 'creating and saving, for then calling~referencing~using' an Attribute later in some other script within our game, instead of a Function, hehe):
-> player.alias = result
-> show menu ("What is your gender?", split ("male;female", ";"), false) {
-> -> // quest's 'show menu' function automatically (and hiddenly) sets: result = your_choice from the pop up menu's selection of choices~options
->-> // I use 'gender_string' because I don't want to overwrite the already built-in Grammer 'gender = he, she, or it' Attribute and functionality of quest's core coding
->-> player.gender_string = result
->-> show menu ("What is your race?", split ("human;dwarf;elf", ";"), false) {
->->-> player.race = result
->->-> show menu ("What is your class?", split ("warrior;cleric;mage;thief", ";"), false) {
->->->-> player.class = result
->->->-> msg (player.alias + " is a " + player.gender_string + " " + player.race + " " + player.class + ".")
->->-> }
->-> }
-> }
}
<function name="level_up_function"><![CDATA[
-> if (player.level_up_points > 0) {
->-> if (player.gender_string = "male") {
->->-> player.strength = player.strength + 1
->-> } else if (player.gender_string = "female") {
->->-> player.agility = player.intelligence + 1
->-> }
->-> if (player.race = "human") {
->->-> player.strength = player.strength + 1
->->-> player.intelligence = player.intelligence + 1
->-> } else if (player.race = "dwarf") {
->->-> player.strength = player.strength + 2
->-> } else if (player.race = "elf") {
->->-> player.intelligence = player.intelligence + 2
->-> }
->-> if (player.class = "human") {
->->-> // you get the idea... etc etc etc... lol
->-> }
->-> player.level_up_points = player.level_up_points - 1
->-> level_up_function // (in the GUI~Editor, this is: 'call a function' Script)
-> }
]]></function>
<turnscript name="global_turnscript">
-> <enabled />
-> <script>
->-> level_up_function // (in the GUI~Editor, this is: 'call a function' Script)
->-> game.turns = game.turns + 1
-> </script>
</turnscript>
--------------------
the hardest part of character creation is getting the display (msg~print a message) to work:
in the GUI~Editor: run as script -> add a script -> output -> Print a message -> [EXPRESSION] -> (see below)
you need to break it down into 2 types of 'chunks' to understand how to type it correctly (correct syntax):
The 2 'Chunks':
1. " text "
2. + Object.Attribute +
thus the chunks for:
player.alias = "HK"
player.gender_string = "male"
player.race = "human"
player.class = "warrior"
msg (player.alias + " is a " + player.gender_string + " " + player.race + " " + player.class + ".")
// outputs~returns~displays~shows: HK is a male human warrior.
player.alias +
" is a "
+ player.gender_string +
" (space) "
+ player.race +
" (space) "
+ player.class +
"."
this will help you greatly type it out correctly without errors, but it'll still take a lot of practice and frustration, lol
this took me quite a while to be able to do this, and I still have trouble with it even now, though understanding the '2 chunks' concept really helps a lot.
----------
here's another example:
player.damage = 100
monster.alias = "orc"
monster.hp = 500
(pretend we got a damage script, doing the subtracting: monster.hp = monster.hp - player.damage: 500-100)
(remember that you *MUST* set the 'print a message' to [EXPRESSION], as this enables the use of your 'Object.Attribute' calls~references~loading of your Attributes in the message)
msg ("You do " + player.damage + " damage to the " + monster.alias + ", leaving it with only " + monster.hp + " HP left.")
outputs: You do 100 damage to the orc, leaving it with only 400 HP left.
can you break it down into the correct chunks?
answer:
"You do "
+ player.damage +
" damage to the "
+ monster.alias +
", leaving it with only "
+ monster.hp +
" HP left."
---------------------
"room" (object) -> Room Descriptions (or whatever it is called) (tab) -> Description -> run as script -> add a script -> output -> print a message -> [EXPRESSION] -> (see below, but in code though)
room.alias = "catacombs"
room.light_or_dark = "dark"
room.length = 44
friend.alias = "mike"
friend.condition = "dead"
monster.alias = "man-eating crocodile"
room.walls_conditiion = "blood"
player.condition = "sick"
friend.gender = "him"
msg ("The " + room.alias + " is a " + room.light_or_dark + " maze, that is " + room.length + " miles long, that your best friend, " + friend.alias + ", got lost in, and is now " + friend.condition + ". You hope to be able to find " + friend.gender + " soon, as you don't want to be eaten up by the " + monster.alias + ". The " + room.alias + "' walls are smeared with " + room.walls_condition + ", and you feel " + player.condition + " already. Yada Yada Yada")
outputs: The catacombs is a dark maze, that is 44 miles long, that your best friend, Mike, got lost in, and is now dead. You hope to be able to find him soon, as you don't want to be eaten up by the man-eating crocodile. The catacombs' walls are smeared with blood, and you feel sick already. Yada Yada yada
hehe, ...hopefully I didn't make any mistakes, lol
HegemonKhan
31 May 2014, 20:33err, for the player-object-description to be shown, both me and Jay, forgot that you got to ALSO set this too:
"game" (object) -> player (tab) -> game pov (or whatever it is called) -> (choose your Player Object, with the player-object-description)
quest needs to be told who is your 'game.pov' (currently controlled Player Object), as even though your Player Object will be used as your game.pov for game play, it's player-object-description will not be displayed, unless you do this. If you don't tell quest who is your game.pov, it'll still use your non-player-object description, which if still is it's defaulted message, will be "You are looking good", instead of whatever you typed in for your player-object-description.
"game" (object) -> player (tab) -> game pov (or whatever it is called) -> (choose your Player Object, with the player-object-description)
quest needs to be told who is your 'game.pov' (currently controlled Player Object), as even though your Player Object will be used as your game.pov for game play, it's player-object-description will not be displayed, unless you do this. If you don't tell quest who is your game.pov, it'll still use your non-player-object description, which if still is it's defaulted message, will be "You are looking good", instead of whatever you typed in for your player-object-description.

jaynabonne
31 May 2014, 20:49HK, have you tried that? The game.pov defaults to your player object. It even says, on that page you mentioned:
You only need to remember to do that if you wish to use a *different* player object. It's not necessary in the normal case. It worked fine for me, as it should, without going to that page at all. (I tested my answer before I posted it.)
If no player object is specified, Quest will use the object named "player"...
You only need to remember to do that if you wish to use a *different* player object. It's not necessary in the normal case. It worked fine for me, as it should, without going to that page at all. (I tested my answer before I posted it.)
HegemonKhan
31 May 2014, 21:40I hadn't tested it, I was going from memory of it happening to me (and this would be with v540 too), so it was probably when I created~used another Player Object, most likely as you pointed out (or it got corrected in the v550 that you're using).
If it's still not displaying the proper description, it's a thing for them to check on.
If it's still not displaying the proper description, it's a thing for them to check on.