Displaying Attributes in the status bar

Rainbow Dash
Okay, so I have set some custom attributes and I would like to display them in the status section of the GUI while the player is playing. How do I go about that?

jaynabonne
See if this page helps: http://quest5.net/wiki/Status_Attributes

If not, ask for more. :)

Rainbow Dash
Yeah, no, that isnt working. I keep trying to add it to a string dictionary how it says, but instead its just changing the value of the integer.

In all seriousness, this is confusing just to add an integer and display it in a container on the gui.

HegemonKhan
Either, remove the "!" mark, or have the text that you want with the "!" mark.

Attribute:

Object: player
Name: strength
Type: int (Integer)
Value: 100

Status Attribute:

Object: player
Name: strength
Value: (see below)

name = value ---> what the game engine displays

strength = (leave blank) ---> Strength 100

strength = ! ---> 100

strength = STR: ! ---> STR: 100

strength = ! STR ---> 100 STR

strength = Your STR is ! ---> Your STR is 100

OR

Global Turnscript:

player.hit_points = "HP:" + player.current_hit_points + "/" + player.maximum_hit_points
player.turns = player.turns + 1

Attributes:

Object: player
Name: turns
Type: int
Value: 0

Object: player
Name: hit_points
Type: string
Value: 0/0

Object: player
Name: current_hit_points
Type: int
Value: 999

Object: player
Name: maximum_hit_points
Type: int
Value: 999

Status Attributes:

Object: player
Name: turns
Value: !

Object: player
Name: hit_points
Value: !

game engine display:

initially:

Turns 0
HP: 0/0

then, after a turn:

Turns 1
HP: 999/999

---------------

Are you working with the GUI~Editor, or can you also work with the code?

Quest v5.4 changed the coding for it:

http://quest5.net/wiki/Upgrade_Notes
http://quest5.net/wiki/Stringdictionary

Quest v5.3 syntax+format:

<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<strength type="int">100</strength>
<endurance type="int">100</endurance>
<statusattributes type="stringdictionary">strength =;endurance =</statusattributes>
</object>


Quest v5.4 syntax+format:

<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<strength type="int">100</strength>
<endurance type="int">100</endurance>
<statusattributes type="simplestringdictionary">strength =;endurance =</statusattributes>
</object>


OR

// this might ~probably is~ be a bit incorrect, as I've haven't used it this way yet.

<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<strength type="int">100</strength>
<endurance type="int">100</endurance>
<statusattributes type="stringdictionary">
<item>
<key>strength</key>
<value></value>
</item>
<item>
<key>endurance</key>
<value></value>
</item>
</statusattributes>
</object>


and then, if you want a string with it:

<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<strength type="int">100</strength>
<endurance type="int">100</endurance>
<hit_points type="string">0/0</hit_points>
<current_hit_points type="int">999</current_hit_points>
<maximum_hit_points type="int">999</maximum_hit_points>
<statusattributes type="simplestringdictionary">strength = STR: !;endurance = END: !;hit_points =!</statusattributes>
</object>

<turnscript name="status_attributes_turnscript>
player.hit_points = "HP:" + player.current_hit_points + "/" + player.maximum_hit_points
</turnscript>

// OR

[code]<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<strength type="int">100</strength>
<endurance type="int">100</endurance>
<hit_points type="string">0/0</hit_points>
<current_hit_points type="int">999</current_hit_points>
<maximum_hit_points type="int">999</maximum_hit_points>
<statusattributes type="stringdictionary">
<item>
<key>strength</key>
<value>STR: !</value>
</item>
<item>
<key>endurance</key>
<value>END: !</value>
</item>
<item>
<key>hit_points</key>
<value>!</value>
</item>
</statusattributes>
</object>

<turnscript name="status_attributes_turnscript>
player.hit_points = "HP:" + player.current_hit_points + "/" + player.maximum_hit_points
</turnscript>

Rainbow Dash
Also didnt help. Pretend you are talking to someone that hasnt done anything remotely close to coding....ever. Because I havent.

From what you have put there, it looks like the ! outputs the value of the stat. If its a custom stat, is that even gonna work?

HegemonKhan
it does work, we just need to figure out what you're doing wrong... could you copy and paste your game code here, or add your game file as an attachment to your post here, for us to see what you're doing wrong?

attaching your game file to a post here, shouldn't need an explanation on how to do it (the "upload an attachment" button is at the bottom of your post editing screen).

there's two ways to see your game code:

1. open up your game like you normally do, and within the GUI~Editor, at the very top is a bar with buttons on it, find the notepaper like button (it's between the "Play" and "?~Help" buttons). This notepaper button is a toggle button to switch between the GUI~Editor mode and the Code View (in-code) mode. So, just press this button to switch to the Code View mode.

2. just open up your game file with notepad, wordpad, or notepad++

now that you can see your game's coding, just highlight (ctrl+A) all of it and copy it (ctrl+C).

then just paste (ctrl+V) it into your post here, within this coding:

[code.] (your pasted game code) [/code.]

but without the dots in the [ code ] segments, it should look like this:

 (your pasted game code) 


---------------

(the top of my previous post is for doing it in~with the GUI~Editor, the long bottom part is how it should look in code)

if you follow this guide, it should be working for you, and if you don't understand it, let me know, so I can explain it better


----------------

and, "strength", "endurance", "hit_points", "turns", "current_hit_points", and "maximum_hit_points" are all custom attributes

so, yes, custom attributes work, just fine.

-----------------

1. you're working with the offline version of quest, and with the GUI~Editor, right?
2. you've made (Added) the Attributes for the same Object as you made (Added) the Status Attributes for, correct?
3. "Status Attributes" ONLY WORK~EXIST for the Player Objects (such as the default "player" Player Object) and the Game Object (called "Game").
4. your Attributes' NAME Attribute and Status Attributes' NAME Attribute are typed exactly the same, correct?

-----------------

here's a working game code for you to see for yourself:

<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<turns type="int">0</turns>
<statusattributes type="simplestringdictionary">turns =</statusattributes>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<curhp type="int">250</curhp>
<maxhp type="int">500</maxhp>
<current_hit_points type="int">999</current_hit_points>
<maximum_hit_points type="int">999</maximum_hit_points>
<maxhp type="int">500</maxhp>
<hp type="string">0/0</hp>
<strength type="int">100</strength>
<endurance type="int">100</endurance>
<agility type="int">100</agility>
<hit_points type="string">0/0</hit_points>
<statusattributes type="simplestringdictionary">hp = ;hit_points =!;strength =;endurance = !;agility = Your agility is !</statusattributes>
</object>
</object>
<turnscript name="turns_turnscript">
<enabled />
<script>
player.hp = player.curhp + "/" + player.maxhp
player.hit_points = "HP: " + player.current_hit_points + "/" + player.maximum_hit_points
game.turns = game.turns + 1
</script>
</turnscript>
</asl>


just click the "select all" button on this post to highlight it, copy (ctrl+C) it, create and start up a new game, go into the Code View mode, highlight (ctrl+A) all of its code, delete it, paste (ctrl+V) my game code into it, save your game file, and then play it out.

Or, just can just download it as an attachment too, below:

HegemonKhan
ooo... maybe you're asking about this issue, instead:

the Status Attribute will display that Attribute's CURRENT Value, how it (or what) is displayed can be manipulated, as I've shown in my two previous posts already, but the Attribute's Value itself is merely what you CURRENTLY have it set as being.

Do, you want to know how to change (increase~decrease~multiply~divide) that Attribute's Value amount per time (such as on each turn or every X turns) ???

---------------

What are your Attributes' Types that you're using?

String, Boolean, Int (Integer), Double, Script, String List, Object List, String Dictionary, Object Dictionary, or Script Dictionary?

"player" (Player Object) -> Attributes (Tab) -> Attributes -> Add ->

Object: player
Name: strength
Type: int // there's a little box that allows you to choose~switch your Attribute's Type
Value: 50 // yes this little box (for Attribute Type: int), only changes the number amount = "I keep trying to add it to a string dictionary how it says, but instead its just changing the value of the integer (Rainbow Dash)"

"player" (Player Object) -> Attributes (Tab) -> Status Attributes -> Add ->

Object: player
Name: strength
Type: stringdictionary (hence its Value as a "String" = Format String)
Format String (Value): (leave blank or not) // this is what you want to change for how it gets displayed.

an "!" mark in the Status Attribute's Value (Format String), displays the Attribute's Value (which in this example is: 50), if you only have an "!" mark for the Status Attribute's Value (Format String) then it literally only displays that "50". If you leave it blank, then it displays the Attribute's Name and its Value: "strength 50".

-----------------

Attribute Types:

String: This is just a bunch of characters (not all characters are allowed though), for examples:

a
4 *(yes, the character "4" can be either a String Type or an Integer Type, depending on what Attribute Type you assign to it)*
hit_points
dead
ahs83nd93_jdsdniwei3834ndj
hi, how are you?

Integer (Int): this is just non-decimal numbers~amounts (can be positive, zero, or negative)

... , -100, -1, 0, 1, 4*, 100, ...

Double: this is just decimal numbers~amounts (can be positive, zero, or negative)

..., -100.5, -1.5, -0.9, 0.0, 0.3333, 1.5, 100.7, ...

etc etc Types... ask if you want the other Attribute Types to be explained (as they're off-topic for this subject)

-------------------

so, for example:

"player" (Player Object) -> Attributes (Tab) -> Attributes -> Add ->

Object: player
Name: strength
Type: int
Value: 50

"!" mark (when used in the Status Attribute's Value~Format String) = 50

"player" (Player Object) -> Attributes (Tab) -> Status Attributes -> Add ->

Object: player
Name: strength
Type: stringdictionary

Format String (Value): Your strength is !
Return Value (what is displayed): Your strength is 50

Format String (Value): (leave blank)
Return Value (what is displayed): Strength 50

Format String (Value): !
Return Value (what is displayed): 50

but, now let's look at if we have a String Type (instead of an Integer Type) for our Attribute:

"player" (Player Object) -> Attributes (Tab) -> Attributes -> Add ->

Object: player
Name: strength
Type: string
Value: strong

"!" mark (when used in the Status Attribute's Value~Format String) = strong

"player" (Player Object) -> Attributes (Tab) -> Status Attributes -> Add ->

Object: player
Name: strength
Type: stringdictionary

Format String (Value): Your strength is !
Return Value (what is displayed): Your strength is strong

Format String (Value): (leave blank)
Return Value (what is displayed): Strength strong

Format String (Value): !
Return Value (what is displayed): strong

~OR~

"player" (Player Object) -> Attributes (Tab) -> Attributes -> Add ->

Object: player
Name: strength
Type: string
Value: weak

"!" mark (when used in the Status Attribute's Value~Format String) = weak

"player" (Player Object) -> Attributes (Tab) -> Status Attributes -> Add ->

Object: player
Name: strength
Type: stringdictionary

Format String (Value): Your strength is !
Return Value (what is displayed): Your strength is weak

Format String (Value): (leave blank)
Return Value (what is displayed): Strength weak

Format String (Value): !
Return Value (what is displayed): weak

Rainbow Dash
OKay, so I think I am starting to understand this coding language. Is it Java?

Anyway, Im not actually new to coding. I said treat me as if I am new because I get confused and overwhelmed when you throw code at me and I dont understand what the various functions do. Ive done coding in GWBasic, Basic, Pascal and C++ and C#.

So, here is what I have so far. Correct me if I am wrong.

<asl version="540">

<include ref="English.aslx"/>
<include ref="Core.aslx"/>

<game name="Daring Do and the Crystal Caves">
<gameid>648a8422-7e07-4900-b693-2fec17451fd9</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
</game>

<object name="room">
<inherit name="editor_room" />

<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<hits type="int">10</hits>
<strength type="int">1</strength>
<constitution type="int">1</constitution>
<agility type="int">1</agility>
<wits type="int">1</wits>
<intelligence type="int">1</intelligencee>
<personality type="int">1</personality>
</object>
</object>

</asl>


So from my understanding, this line: <constitution type="int">1</constitution>

This line is used to set variable in the programming language. I change the type of variable by changing the "int" to "string" if I want to add to the string library right? And the name at the beginning of that line is the name of said variable, right?

Rainbow Dash
Okay, I think that I have got this. Take a look and let me know what you think:

<!--Saved by Quest 5.4.4873.16527-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Daring Do and the Crystal Caves">
<gameid>648a8422-7e07-4900-b693-2fec17451fd9</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<hits type="int">10</hits>
<strength type="int">1</strength>
<constitution type="int">1</constitution>
<agility type="int">1</agility>
<wits type="int">1</wits>
<intelligence type="int">1</intelligence>
<personality type="int">1</personality>
<exp type="int">0</exp>
<statusattributes type="stringdictionary">
<item>
<key>strength</key>
<value>Strength: !</value>
</item>
<item>
<key>constitution</key>
<value>Constitution: !</value>
</item>
<item>
<key>agility</key>
<value>Agility: !</value>
</item>
<item>
<key>wits</key>
<value>Wits: !</value>
</item>
<item>
<key>intelligence</key>
<value>Intelligence: !</value>
</item>
<item>
<key>personality</key>
<value>Personality: !</value>
</item>
<item>
<key>hits</key>
<value>Hit Points: !</value>
</item>
</statusattributes>
</object>
</object>
</asl>

Rainbow Dash
Okay, so, I think I have come a long way since yesterday. I wanted to show you where I was up to now since getting some sleep:

<!--Saved by Quest 5.4.4873.16527-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="MLP Ascendancy">
<gameid>cf52fea4-bb48-43e0-b3d5-d328d519c521</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<start type="script">
startmenu = NewStringList()
list add (startmenu, "New Game")
list add (startmenu, "Load Game")
list add (startmenu, "Background")
ShowMenu ("START MENU", startmenu, false) {
if (result="New Game") {
ClearScreen
msg ("Please tell me your name.")
get input {
player.alias = result
msg ("Okay, your name is "+player.alias +".")
wait {
gendermenu = NewStringList()
list add (gendermenu, "male")
list add (gendermenu, "female")
ShowMenu ("Are you Male or Female", gendermenu, false) {
player.gender = result
msg ("Okay, you are a "+player.gender +".")
wait {
ClearScreen
msg ("Okay, so, your name is "+player.alias +" and you are a human "+player.gender +".")
classmenu = NewStringList()
list add (classmenu, "Mercenary")
list add (classmenu, "Rouge")
list add (classmenu, "Gadgeteer")
ShowMenu ("What class would you like to be?", classmenu, false) {
player.class = result
msg ("Excellent. You are a "+player.class+".")
if (result="Mercenary") {
player.strength = 3
player.stamina = 3
player.agility = 2
player.intellect = 1
player.wits = 1
player.personality = 1
}
}
}
}
}
}
}
}
</start>
</game>
<object name="Choose an option">
<inherit name="editor_object" />
<dark />
<darkroomdescription type="string"></darkroomdescription>
<descprefix type="string"></descprefix>
<objectslistprefix type="string"></objectslistprefix>
<visible type="boolean">false</visible>
<usedefaultprefix type="boolean">false</usedefaultprefix>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<statusattributes type="stringdictionary">
<item>
<key>player.alias</key>
<value>Name: </value>
</item>
<item>
<key>player.gender</key>
<value>Sex: </value>
</item>
<item>
<key>player.class</key>
<value>Class: </value>
</item>
</statusattributes>
</object>
</object>
</asl>


I have a problem though, why arent the attributes showing up in the status box when they are changed?

jaynabonne
In the statusattributes dictionary:

1) Remove "player." from the keys. It should just be "alias", not "player.alias".
2) Put "!" where you want the value to be displayed. For example, "Name: !", not just "Name: ".

You will want to initialize the values as well. "player.alias" defaults to "me", and "player.gender" defaults (for some reason) to "you". But you'll see that once the status variables start to show. :)

(An unrelated thing: it's "rogue", I think. Unless you're able to be a cosmetic or a bit red...)

Rainbow Dash
jaynabonne wrote:In the statusattributes dictionary:

1) Remove "player." from the keys. It should just be "alias", not "player.alias".
2) Put "!" where you want the value to be displayed. For example, "Name: !", not just "Name: ".

You will want to initialize the values as well. "player.alias" defaults to "me", and "player.gender" defaults (for some reason) to "you". But you'll see that once the status variables start to show. :)

(An unrelated thing: it's "rogue", I think. Unless you're able to be a cosmetic or a bit red...)


Yes, I corrected that speeling mistake. >.> XD

How do I initialize a attribute?

jaynabonne
Add this to your start script:

player.alias = ""
player.gender = ""


Normally, you can just create attributes on the object to initialize them, but there are certain pre-defined attributes on the player that seem to ignore your overrides, for reasons I haven't researched yet.

Rainbow Dash
jaynabonne wrote:Add this to your start script:

player.alias = ""
player.gender = ""


Normally, you can just create attributes on the object to initialize them, but there are certain pre-defined attributes on the player that seem to ignore your overrides, for reasons I haven't researched yet.


I think I goofed. XD

Error running script: Error compiling expression '"Okay, so, your name is "+alias +" and you are a human "+gender +"."': Unknown object or variable 'alias'


FIXED IT! Thank you. Im sure I will have more questions. Ill keep posting them in the same thread if they are related of course. This might be a good thing to add to the wiki too.

Rainbow Dash
So, is there a way to increase the size of the status box so that the stats arent scrolling?

Also, lets say I want one of my options in my menu to loop back to the menu...how do I do that?

For example, I have a background option. I want the players to be able to read the background and when they are done, go back to the menu without having to restart the game. Is there a way to get that done?

HegemonKhan
Rainbow Dash wrote:OKay, so I think I am starting to understand this coding language. Is it Java?


No. It's Alex~Quest 's own unique coding language, though when~if you use notepad++, you set the language to "XML", and it is also able to use some other languages for more features~abilities that it can't do itself. However, unlike you, I don't know any other coding languages, I've been learning a bit of coding simply from slowly learning Quest's coding, hehe. I have been doing some coding in~with~through the computer's command prompt and ".bat" files, but that's my entire knowledge of coding, lol.

Rainbow Dash wrote:So from my understanding, this line: <constitution type="int">1</constitution>

This line is used to set variable in the programming language. I change the type of variable by changing the "int" to "string" if I want to add to the string library right? And the name at the beginning of that line is the name of said variable, right?


there's two types of coding syntaxes:

1. "As Objects+Misc" (the use of the "<" and ">" as beginnings and endings for the "blocks" and individual Attribute lines too)

<object name="fire_orc_1">
<inherit name="editor_object" />
<inherit name="fire_type" />
<alias>orc</alias>
<strength type="int">50</strength>
// etc etc etc
</object>
<function name="fight_function">
// blah scripting
</function>
<type name="fire_type">
<fire_damage type="int">100</fire_damage>
<fire_resistance type="int">100</fire_resistance>
</type>
<command name="fight_command">
// blah blah blah
</command>
<verb name="fight_verb">
// blah blah blah
</verb>


2. scripting (scripts)

enemy_damage = orc.strength - player.endurance + orc.fire_damage

if (enemy_damage >= player.hit_points) {
msg ("The " + enemy.alias + " kills you.")
msg ("GAME OVER")
finish
} else {
// blah blah blah
}


see the differences?

1. <object name="orc">
<strength type="int">50</strength>
</object>

2. orc.strength = 50 // this needs the attribute to be actually set~added~given to an Object ("orc"), to then be able to use this script line, as well as also in telling the game engine what TYPE of ATTRIBUTE is the "50", is it an Integer (Int) or is it a String? This is all done by #1, as this #2 is just the scripting form of it's (required) actual existence~creation~setting~adding via #1

---------

VARIABLE vs ATTRIBUTE:

Attributes:

<object name="orc">
-> <strength type="int">50</strength>
</object>

object.attribute=value

object.name=orc
orc.strength=50

Variables:

you_go_first = false or true

<function name="fight_function">
-> you_go_first = false
-> if (player.speed > orc.speed) {
->-> you_go_first = true
-> }
-> on ready {
->-> if (you_go_first = true) {
->->-> msg ("You get to go first!")
->->-> orc.hit_points = orc.hit_points - player.damage
->->-> msg ("You do " + player.damage + " damage to the orc, and now it only has " + orc.hit_points + "HP remaining!"
->->-> msg ("The orc now attacks you too!")
->->-> player.hit_points = player.hit_points - orc.damage
->->-> msg ("The orc does " + orc.damage + " damage to you, and now you only have " + player.hit_points + "HP remaining!"
->-> } else if (you_go_first = false) {
->->-> msg ("The orc gets to go first!")
->->-> player.hit_points = player.hit_points - orc.damage
->->-> msg ("The orc does " + orc.damage + " damage to you, and now you only have " + player.hit_points + "HP remaining!"
->->-> msg ("You now get to attack the orc!")
->->-> orc.hit_points = orc.hit_points - player.damage
->->-> msg ("You do " + player.damage + " damage to the orc, and now it only has " + orc.hit_points + "HP remaining!"
->-> }
-> }
</function>

~OR~

enemy = GetObject (orc)

Variable: enemy

-----------

there's no "string library", the "Format String" (ie make~write~type_in a STRING) is just a String Type Attribute FOR THE STATUS ATTRIBUTE. So...

the "player" Player Object's (custom ~ mine, HK's created~added) *ATTRIBUTES*:

Name: strength
Type: int
Value: 100
"!" = 100

Name: current_hit_points
Type: int
Value: 999

Name: maximum_hit_points
Type: int
Value: 999

Name: hit_points
Type: string
Value: "Your HP is 0/0"
"!" = Your HP is 0/0

and also we create a turnscript:

<turnscript name="global_turns_turnscript">
-> player.hit_points = player.current_hit_points +"/"+ player.maximum_hit_points
-> game.turns = game.turns + 1
</turnscript>

this will replace the "0/0" Value of the "String" Attribute Type of the "player" to "999/999" (or whatever the current values of "player.current_hit_points" and "player.maximum_hit_points" are at, at the beginning of each new turn)

"!" = player.current_hit_points +"/"+ player.maximum_hit_points
"!" = 999/999

the "player" Player Object's (custom ~ mine, HK's created~added) *STATUS ATTRIBUTES*:

Name: strength
Type: String
Format String (Value): Your strength is !

the displayed String Attribute of the "player" Player Object's Status Attribute "strength": Your strength is 100

Name: hit_points
Type: String
Format String (Value): Your HP is !

initially, the displayed String Attribute of the "player" Player Object's Status Attribute "strength": Your HP is 0/0
afterwards, the displayed String Attribute of the "player" Player Object's Status Attribute "strength": Your HP is 999/999

if we have a script that changes the values, such as:

msg ("The orc attacks for you damage!")
player.current_hit_points = player.current_hit_points - orc.damage // let's say: orc.damage = 500

"!" = (999 - 500) / 999

so, on the next turn, it'll now display this: Your HP is 499/999

-------------------

there's no "string library", so I'm assuming you're refering to the STATUS ATTRIBUTE'S "Format String", though let me use this opportunity to talk about something else, the difference between these two Attribute Types:

"string" vs "stringlist"

string: (1) redblueyellow -> 1 single "collection or series of characters"

stringlist: (1) red (2) blue (3) yellow -> 3 separate "items~choices", from which to choose from

it's a bit confusing, lol. Just remember that if you want choices to choose from, you want to use stringlists or use the "split" coding

or, maybe this will help:

string -> breaking the thing apart into pieces -> stringlist // or think of it like this: a stringlist breaks apart a string

stringlist -> putting the pieces back together to create the thing -> string // or think of it like this: a string puts back together a stringlist


so, stringlists are used in the: add a~new script -> Output -> "show menu" script, or the quicker way (though only temporary): using the "split" coding: split ("red;blue;yellow",";")

the reverse of going from a stringlist (individual~separated~choice_of "words") to a string is a very rare occurance, at least I don't even understand why~when you'd ever do so, lol. The short way of doing it, is via the "join" coding.

----------------------------

Player Object('s Name attribute): "player"
<constitution type="int">1</constitution>

constitution = the "Name" (ID; no two things can have the same "Name" Attribute, if you know about some coding, you should understand why this is so = like our government in the real world requiring that no two people have the same finger print, ID card #, SS#, and etc identifiers of you or it'll be confused, so too does the quest engine require that no two things have the same "Name" Attributes) attribute of this specific attribute (ie: "constitution") of the "player" Player Object.

constitution = Name of Attribute = Attribute Name

int = Type of Attribute = Attribute Type

1 = Value of Attribute = Attribute Value

Rainbow Dash
Okay, its making more sense to me now. Let me show you what I have got so far. Im working on the basic system right now for combat, inventory and leveling. If you see anything that you have questions about or think wont work, let me know. Also, is there a way to have a looping menu, so when one option is finished, it will loop back to the original list of options?

<!--Saved by Quest 5.4.4873.16527-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<include ref="StackLibrary.aslx" />
<include ref="wearables.aslx" />
<game name="MLP Ascendancy: Book 1">
<gameid>cf52fea4-bb48-43e0-b3d5-d328d519c521</gameid>
<version>0.1</version>
<firstpublished>2013</firstpublished>
<povstatusattributes type="stringdictionary" />
<defaultwebfont>Oswald</defaultwebfont>
<defaultfontsize type="int">12</defaultfontsize>
<defaultbackground>Black</defaultbackground>
<defaultforeground>OrangeRed</defaultforeground>
<attr name="autodescription_youcansee" type="int">0</attr>
<attr name="autodescription_youcango" type="int">0</attr>
<attr name="autodescription_description" type="int">2</attr>
<autodescription_youarein_newline />
<autodescription_youcango_newline />
<autodescription_youcansee_newline />
<autodescription_description_newline />
<category>RPG</category>
<defaultlinkforeground>Orange</defaultlinkforeground>
<pov type="object">player</pov>
<start type="script"><![CDATA[
// This section governs all aspects of the main menu and the character creation process.
startmenu = NewStringList()
list add (startmenu, "New Game")
list add (startmenu, "Background")
list add (startmenu, "Instructions")
list add (startmenu, "A Note from the Author")
ShowMenu ("START MENU", startmenu, false) {
if (result="New Game") {
ClearScreen
msg ("Please tell me your name.")
get input {
player.alias = result
msg ("Okay, your name is "+player.alias +".")
wait {
gendermenu = NewStringList()
list add (gendermenu, "male")
list add (gendermenu, "female")
ShowMenu ("Are you Male or Female", gendermenu, false) {
player.gender = result
msg ("Okay, you are a "+player.gender +".")
wait {
ClearScreen
msg ("Okay, so, your name is "+player.alias +" and you are a human "+player.gender +".")
classmenu = NewStringList()
list add (classmenu, "Mercenary")
list add (classmenu, "Rogue")
list add (classmenu, "Gadgeteer")
ShowMenu ("What class would you like to be?", classmenu, false) {
player.class = result
msg ("Excellent. You are a "+player.class+".")
if (result="Mercenary") {
player.strength = 3
player.stamina = 3
player.agility = 2
player.intellect = 1
player.wits = 2
player.personality = 1
player.exp = 0
player.credits = 100
player.level = 1
}
else if (result="Rogue") {
player.strength = 1
player.stamina = 2
player.agility = 3
player.intellect = 1
player.wits = 3
player.personality = 2
player.exp = 0
player.credits = 100
player.level = 1
}
else if (result="Gadgeteer") {
player.strength = 1
player.stamina = 1
player.agility = 2
player.intellect = 3
player.wits = 2
player.personality = 3
player.exp = 0
player.credits = 100
player.level = 1
}
wait {
ClearScreen
msg ("It's dark. There is nothing but the cold blackness and your own heartbeat. There are no walls, floor or even a ceiling, you are simply floating in the void.<br/><br/>\"Hello?\" You speak out, almost afraid of your own voice. \"Is anyone there?\"<br/><br/>The darkness is suddenly broken by a blinding white light infront of you. You raise your hands to shield your eyes, trying to peer into the light through the cracks in your fingers. You think that you can make out a figure in the light, but you cant make out the form.<br/><br/>\"Hello? Whos there!?\" You yell in the direction of the figure, not sure of where you are or what is happening. You hear a soft, female voice reach out from the light to caress your ears.<br/><br/>\"Dont be afraid, its all about to change.\"<br/><br/>You are about to respond, when you are suddenly falling through the void. You fall for what seems like mere moments before you hit something solid.")
wait {
ClearScreen
MoveObject (player, Bed Room)
player.modifiedstrength = ""
player.modifiedstamina = ""
player.modifiedagility = ""
player.ac = 0
player.maxhits = player.hits + player.stamina
player.hits = 5
player.hp = player.hits + player.stamina
player.relationrd = ""
player.relationrarity = ""
player.relationaj = ""
player.relationpp = ""
player.relationfs = ""
player.relationts = ""
}
}
}
}
}
}
}
}
else if (result="Background") {
ClearScreen
msg ("Humans had such potential and for a time, it looked as though they might actually live up to that potential. For a time, they spread peacefully, settling a few worlds outside of their own. But, they still didn’t learn how to look after those worlds. Slowly, their world became worse and worse. It grew hotter and hotter and it became apparent that it was being subject to a runaway greenhouse effect. The air was becoming more and more noxious, but humans still cling on there today. During the time of this expansion the humans encountered a nearby race called the Xetic. The Xetic were, in all fairness, an aggressive and hostile race. They declared war on the Humans and pushed them straight back to their homeworld. Bombing the planet from orbit, the Xetic hoped to eradicate the humans without any further fight. They didn’t account for the fact that the humans can dig in and fight like animals when they are cornered.<br/><br/> The humans took massive losses. Billions of them died and nearly a half dozen worlds were burned. But, the humans got the upper hand. During the course of the war they developed various technologies that allowed them to become…powerful. Powerful enough, even outnumbered to start pushing the Xetic back. They were just enough to give them an advantage for the short space of time they needed. Launching a single mission, they launched an attack on a nearby Xetic system and using a newly developed weapon, they sent its sun nova. Billions of Xetic died in a heartbeat and the galaxy at large suddenly paid attention.<br/><br/> Before this point, the Xetic and Humans weren’t aware of other races in the galaxy, but they began to intervene. They didn’t want to get involved militarily, so they started trying to find a diplomatic solutions. But, the humans were angry and desperate. Every week, another Xetic star was destroyed. And all the while the galaxy dithered, trying to find a political solution, the humans got closer and closer, until one day, the Xetic star vanished, taking the last of the Xetic with it. For a few months, the galaxy was at a loss, stunned by the total extermination of a sentient species. The humans were of course, completely unapologetic. Having been close to being wiped out themselves, they claimed self-defence. They also cited the hypocrisy of the other races.<br/><br/> Words got heated between the humans and the rest of the galaxy, nothing like this had happened before. The galaxy took its time, studying the behaviour of the humans, what they were doing to themselves, what they were doing to their world. And finally, a consensus was reached. It was decided that the humans…were incapable and too immature to look after themselves. The galaxy ordered the humans to surrender and submit to governance by the rest of the galaxy. The humans of course, refused.<br/><br/> Standing against the Xetic was one thing, standing against over a dozen races united, was something else entirely. It happened quickly, the plan had been thought over for a long time. And it was deceptively simple. Cut off the head and the rest will die. In one surprise attack, the galaxy eliminated the human military command and its governments worldwide. A few short months later, the human race collapsed and surrendered. Humans, from that point on were rendered to second class citizens, barely above a slave class. They were forbidden to govern themselves and to form any sort of military or police force again.<br/><br/> The humans were permitted to keep their world and system for their own uses, but forbidden to expand further into the galaxy. The human race is subject to galactic law, but not the whole law. They are, by vote in the council, entitled to far less. Their rights have all but been stripped. They are looked on as savages and barbarians and are treated as such. Some races even keep them as slaves, though this is frowned on by the other races, but the crimes of the human race seem to temper attempts to prevent the slavery of humans.<br/><br/> But this is where you find yourself now, in the last city on Earth, New York. The only place that survived the war, populated by a race that is oppressed by the rest of the galaxy ‘for their own good’. <br/>")
wait {
ClearScreen
}
}
}
]]></start>
</game>
<object name="Choose an option">
<inherit name="editor_object" />
<dark />
<darkroomdescription type="string"></darkroomdescription>
<descprefix type="string"></descprefix>
<objectslistprefix type="string"></objectslistprefix>
<visible type="boolean">false</visible>
<usedefaultprefix type="boolean">false</usedefaultprefix>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<inherit name="defaultplayer" />
<status>-</status>
<statusattributes type="stringdictionary">
<item>
<key>alias</key>
<value>Name: !</value>
</item>
<item>
<key>gender</key>
<value>Gender: !</value>
</item>
<item>
<key>class</key>
<value>Class: !</value>
</item>
<item>
<key>level</key>
<value>Level: !</value>
</item>
<item>
<key>hp</key>
<value>Hit Points: !</value>
</item>
<item>
<key>strength</key>
<value>Strength: !</value>
</item>
<item>
<key>stamina</key>
<value>Stamina: !</value>
</item>
<item>
<key>agility</key>
<value>Agility: !</value>
</item>
<item>
<key>intellect</key>
<value>Intellect: !</value>
</item>
<item>
<key>wits</key>
<value>Wits: !</value>
</item>
<item>
<key>personality</key>
<value>Personality: !</value>
</item>
<item>
<key>exp</key>
<value>Exp: !</value>
</item>
<item>
<key>credits</key>
<value>Credits: !</value>
</item>
</statusattributes>
</object>
</object>
<object name="Bed Room">
<inherit name="editor_room" />
</object>
<object name="Health Pack">
<inherit name="editor_object" />
<inherit name="childstack_object" />
<take />
<look>This is a standard issue Health Pack, common all over the slums. It restores 5 hit points.</look>
<stackparent type="object">Health Pack</stackparent>
<use type="script"><![CDATA[
if (player.hp <> player.maxhits and < player.maxhits) {
player.hp = player.hp + 5
if (player.hp > player.maxhits) {
player.hp = player.maxhits
}
}
else if (player.hp > or = player.maxhits) {
AddToInventory (Health Pack)
msg ("You do not need healing.")
}
]]></use>
</object>
<object name="Bolt Pistol">
<inherit name="editor_object" />
<inherit name="wearable" />
<attr name="wear_layer" type="int">1</attr>
<wear_slots type="stringlist">
<value>Weapon</value>
</wear_slots>
<look>This is a crappy gunpoweder pistol from just before humanswere oppressed. Its better than a knife, but not as good as some of the energy weapons available. Its adds +3 to your strength in combat.</look>
<onafterwear type="script">
player.modifiedstrength = player.strength + 3
</onafterwear>
<onafterremove type="script">
player.modifiedstrength = player.strength - 3
</onafterremove>
</object>
<object name="Flak Vest">
<inherit name="editor_object" />
<inherit name="wearable" />
<attr name="wear_layer" type="int">1</attr>
<wear_slots type="stringlist">
<value>Armour</value>
</wear_slots>
<onafterwear type="script">
player.ac = +1
</onafterwear>
<onafterremove type="script">
player.ac = -1
</onafterremove>
<look>While a little more advanced than the Flak Vest of the 20 and 21st centuries, this still provideds little protection. But its better than nothing. +1 AC.</look>
</object>
</asl>

HegemonKhan
I have a habit to edit my posts a bit, so refresh and read over my old posts, as I've probably added or corrected some stuff in them. I have already edited some of my previous posts, which you probably hadn't thus read that new or changed stuff within them.

--------------------

rainbow dash wrote:I have a problem though, why arent the attributes showing up in the status box when they are changed?


I think in the GUI~Editor, there's a choice for your attributes to create a "changed script" for it, and I think you can use this to do what you want. I didn't know about exactly what this "changed script" in the GUI~Editor's Attribute (Tab)'s "window".

Otherwise, the way I'm familiar with, is in using the turnscript, to update your status attribute's values. I think there's also a code~script line (it is normally used internally by the quest engine) that you can add into some scripting, to do this as well too.

I've shown you already how to do this (via the turnscript method) in my previous posts.

Rainbow Dash
HegemonKhan wrote:I have a habit to edit my posts a bit, so refresh and read over my old posts, as I've probably added or corrected some stuff in them. I have already edited some of my previous posts, which you probably hadn't thus read that new or changed stuff within them.

--------------------

"rainbow dash"

I have a problem though, why arent the attributes showing up in the status box when they are changed?



I think in the GUI~Editor, there's a choice for your attributes to create a "changed script" for it, and I think you can use this to do what you want. I didn't know about exactly what this "changed script" in the GUI~Editor's Attribute (Tab)'s "window".

Otherwise, the way I'm familiar with, is in using the turnscript, to update your status attribute's values. I think there's also a code~script line (it is normally used internally by the quest engine) that you can add into some scripting, to do this as well too.

I've shown you already how to do this (via the turnscript method) in my previous posts.

---------------

(one sec)



Figured that one out. I was using the player. in the keys and it didnt like that.

HegemonKhan
jaynabonne wrote:Add this to your start script:

player.alias = ""
player.gender = ""


Normally, you can just create attributes on the object to initialize them, but there are certain pre-defined attributes on the player that seem to ignore your overrides, for reasons I haven't researched yet.


You can also create a "character creation" scripting too:

http://quest5.net/wiki/Character_Creation

though, you may want to not use "alias" nor "gender", as this will override the default~internal~core coding that Alex had made for~with using "alias" and "gender", such as a simple change (as I like to do for my style): "alias_x" and "gender_x"

but, I don't think it's too big of a deal if you do override the default "alias" and "gender" coding, as it doesn't seem to effect anything for the "alias", and for the "gender", you can still use the "name_of_your_object.article" to get~use the "he, she, it, and~or etc", and your use of "name_of_your_object.gender" will be set as: "male" or "female", too for you to use as well.

---------------

rainbow dash wrote:Figured that one out. I was using the player. in the keys and it didnt like that.


an Attribute (in coding) must be attached to an Object (in the GUI~Editor it forces you to do this, via "adding" the attribute to that selected Object's window via that Object's Attribute Tab window. Only when using "Print [EXPRESSION]", as this is script writing itself, can you mess up in the GUI~Editor ~ I think, anyways, lol):

object.attribute
name_of_your_object.name_of_your_attribute

for examples:

player.strength
HK.strength
orc.strength

a Variable, does NOT require this attachment to an Object.

you_go_first = false
enemy = GetObject (orc)

HOWEVER, being attached to an Object (ie Attributes), make them "permanent~global", they can be used anywhere (so long as that Object remains existing=permanent, lol).

Whereas, not being attached to an Object (ie Variables), make them "temporary~local", thus they can *ONLY* be used by *THAT* script block that you put them in *(and~or in the script blocks that your use of "parameters" carry them over to as well, though I'll wait for you to ask about this, as it's a bit complicated and thus difficult to explain briefly, lol)*.

Rainbow Dash
Why wont these work?

               player.relationrd = player.agility + player.strength
player.relationrarity = player.wits + player.personality
player.relationaj = player.strength + player.stamina
player.relationpp = player.personality + player.stamina
player.relationfs = player.intellect + player.personality
player.relationts = player.intellext + player.wits


Okay, just read your post, do I need to have these in an object in order for them to work?

HegemonKhan
Rainbow Dash wrote:So, is there a way to increase the size of the status box so that the stats arent scrolling?

Also, lets say I want one of my options in my menu to loop back to the menu...how do I do that?

For example, I have a background option. I want the players to be able to read the background and when they are done, go back to the menu without having to restart the game. Is there a way to get that done?


1. So, is there a way to increase the size of the status box so that the stats arent scrolling?

the left side~pane~panel 's "tree of stuff" (using a new game default coding for an example):

(I'm going off of memory... lol)

Object
-> Game (the Game Object)
->-> Verbs
->-> Commands
-> "room" (your default Room Object)
->-> "player" (your default Player Object)
Functions
Timers
Advanced
-> Libraries
->-> Core.aslx (the game engine coding)
->-> English.aslx (makes the coding and quest itself for~of~in the "english" font~language, for us english speakers)
-> Types (Object Types; ie create a GROUP of~for having~holding many attributes)
-> Java Script
V
V
V
Filter (at the very bottom; ie the bottom left corner of the GUI~Editor screen)


click on the Filter button, and with maybe some difficulty, the "Show Library Elements" should appear, click on this too (you want it to have a check mark in its box).

this causes the hidden core (game engine) coding to become visable in the "tree of stuff" as light grey text. click on what you want, to highlight it, then on the right upper side, click on the "copy" button. This protects Alex' code code from actually being altered, while letting you alter it (well, alter a copy of it, lol). So, it protects you from messing up quest, and having to re-DL and~or re-install it again.

You'll have to figure out where to find (what to click on in the "tree of stuff") the coding on the right boxes' size during game play... lol

------

or... if it's not available through the GUI~Editor....

you can... also simply go into the Quest program folder, and open up the actual files (with notepad, wordpad, or notepad++), until you find the file that has the code settings for what you want... but don't change these files... as these are the actual files... unless you fully know what you're doing (extremely good coder and~or you make a copy~backup before you change it), as this can cause quest to no longer work at all. So, use the GUI~Editor's: Filter -> Show Library Elements -> "copy" button, to be safe, lol.

-----------------------------------

2. Also, lets say I want one of my options in my menu to loop back to the menu...how do I do that?

there's several (or at least 2) ways to do this...

"Calling" Functions and~or "Invoking" Scripts

the "invoking a script" is a bit more complicated to explain, as it involves~requires you to make a "data object" so that you can attach it to it, making it permanent~global, so you can invoke the script whenever~wherever you want.

so, let me show you with functions, instead:

Create a Function, such as this (in code ~ its faster than trying to write it out step by step in the GUI~Editor, lol ~ ARGH):

(you'd need to of course actually make~add these attributes, "experience" and "level", to your "player" Player Object too)

<turnscript name="global_events_turnscript">
leveling_function // every turn, quest will do the leveling function, which starts by "checking" if you've current got enough experience to increase in level
game.turns = game.turns + 1
</turnscript>

<function name="leveling_function"><![CDATA[
if (player.experience >= player.level * 100 + 100) {
player.experience = player.experience - (player.level * 100 + 100)
player.level = player.level + 1
leveling_function // this starts the "leveling function" all over again; ie the loop code line
}
]]></function>


now, in code, simply typing the name of the function, is the "Call function"; ie the loop code line. So, simple and quick, lol.

in GUI~Editor, all you do is this:

Add a~new script -> Scripts -> Call function ->

Name: (just type in the name of your function)
Parameters box -> (Add button) -> (leave blank ~ don't click on the Add button, unless you're using, and thus know how to use, parameters, lol)

------------

and, you can have functions within functions, for example:

<turnscript name="global_events_turnscript">
leveling_function // every turn, quest will do the leveling function, which starts by "checking" if you've current got enough experience to increase in level
game.turns = game.turns + 1
</turnscript>

<function name="leveling_function"><![CDATA[
if (player.experience >= player.level * 100 + 100) {
player.experience = player.experience - (player.level * 100 + 100)
level_plus_one_adder_function
on ready {
leveling_function // this starts the "leveling function" all over again; ie the loop code line
}
}
]]></function>

<function name="level_plus_one_adder_function"><![CDATA[
if (player.alias = HK and player.level < 99) { // HK grins toothily~evilly, muwahaha!
player.level = player.level + 1 // err, this is going to be a lot of loopings, +98 of them, lol. HK grins toothily~evilly, muwahaha!
level_plus_one_adder_function // HK grins toothily~evilly, muwahaha!
} else if (player.alias = "Rainbow Dash") {
player.level = player.level + 1
}
]]></function>


So, as hopefully you can see, this is a way to have loopings within loopings.

---------------------

3. For example, I have a background option. I want the players to be able to read the background and when they are done, go back to the menu without having to restart the game. Is there a way to get that done?

See #2

hehe :D

HegemonKhan
Rainbow Dash wrote:Why wont these work?

               player.relationrd = player.agility + player.strength
player.relationrarity = player.wits + player.personality
player.relationaj = player.strength + player.stamina
player.relationpp = player.personality + player.stamina
player.relationfs = player.intellect + player.personality
player.relationts = player.intellext + player.wits


Okay, just read your post, do I need to have these in an object in order for them to work?


chuckles (when I made my combat code, I used abrevs too, no one knew what they meant, but me), so if you want help, try to get in the habbit of writing out things... so there's no mistake at what you mean, lol

I used to do this:

player.hp // not mysterious but you get the idea
player.pd // very mysterious, what is "pd" ???

now I do this, lol:

player.hit_points
player.physical_damage

so everyone actually knows that I mean "hit points", lol.

Also, I've learned that I myself forget what I mean, and just in general with coding, you need to have lots of notes for yourself too, as it's hard to remember what you're doing and~or what~how your code blocks work, lol.

-----------------

anyways, back on-topic, lol:

you need to actually create (add) these attributes (on~for your Player Object: "player"), as right now they don't actually exist, nor do you have assigned what is their Type of Attribute (which also can only be done via the "player" Player Object in the GUI~Editor, or the "player" Player Object Code Block via In-Code: <object name="player">(blah coding~attributes)</object>)

Rainbow Dash
Nope, that confused the hell out of me. Let me see if I can figure it out. In the fuction that I create, do I use the scripts to make my menu system?

Rainbow Dash
HegemonKhan wrote:

"Rainbow Dash"

Why wont these work?

               player.relationrd = player.agility + player.strength
player.relationrarity = player.wits + player.personality
player.relationaj = player.strength + player.stamina
player.relationpp = player.personality + player.stamina
player.relationfs = player.intellect + player.personality
player.relationts = player.intellext + player.wits


Okay, just read your post, do I need to have these in an object in order for them to work?


chuckles (when I made my combat code, I used abrevs too, no one knew what they meant, but me), so if you want help, try to get in the habbit of writing out things... so there's no mistake at what you mean, lol

I used to do this:

player.hp // not mysterious but you get the idea
player.pd // very mysterious, what is "pd" ???

now I do this, lol:

player.hit_points
player.physical_damage

so everyone actually knows that I mean "hit points", lol.

Also, I've learned that I myself forget what I mean, and just in general with coding, you need to have lots of notes for yourself too, as it's hard to remember what you're doing and~or what~how your code blocks work, lol.

-----------------

anyways, back on-topic, lol:

you need to actually create (add) these attributes (on~for your Player Object: "player"), as right now they don't actually exist, nor do you have assigned what is their Type of Attribute (which also can only be done via the "player" Player Object in the GUI~Editor, or the "player" Player Object Code Block via In-Code: <object name="player">(blah coding~attributes)</object>)



You might think Im a little man baby if I was to type them all out, but okay, I guess my name gives it away.

HegemonKhan
Rainbow Dash wrote:Okay, its making more sense to me now. Let me show you what I have got so far. Im working on the basic system right now for combat, inventory and leveling. If you see anything that you have questions about or think wont work, let me know.


if you don't mind sharing your code, I'd love to see yours on these RPG aspects, lol. I'm also trying to build up coding of the RPG aspects, though it's slow for me, as I'm still a noob with coding... slowly learning it... lol.

I've got a combat code done (it's turn-based, and all credit goes to Pertex' and his Combat Library, as I used his code structure)

I've just posted my own leveling code for you in my previous post(s), hehe.

Though, I'd love to see your inventory system once you've got that done, I've made a very "poor-man's-coding" of one: a root container full of many child subdivision container objects and coding to put the stuff into the right container object ~ though it's only done for "spells", lol. If, you're interested, let me know.

Also, Sora and his~her Stackable Library, does just that, puts multiple same type of objects "together", and then removes them as well too.

Sora's Stackable Library: viewtopic.php?f=18&t=3515

and here's some other useful links:

The libraries: viewforum.php?f=18

The Wiki's pages:

http://quest5.net/wiki/Main_Page
http://quest5.net/wiki/Tutorial
http://quest5.net/wiki/How_to

and the "Quest Coding Bible" wiki pages:

http://quest5.net/wiki/Category:All_Fun ... t_Commands (page 1, range: A-S)
http://quest5.net/w/index.php?title=Cat ... h#mw-pages (page 2, range: S-Z)

enjoy :D

Rainbow Dash
HegemonKhan wrote:

"Rainbow Dash"

Okay, its making more sense to me now. Let me show you what I have got so far. Im working on the basic system right now for combat, inventory and leveling. If you see anything that you have questions about or think wont work, let me know.



if you don't mind sharing your code, I'd love to see yours on these RPG aspects, lol. I'm also trying to build up coding of the RPG aspects, though it's slow for me, as I'm still a noob with coding... slowly learning it... lol.

I've got a combat code done (it's turn-based, and all credit goes to Pertex' and his Combat Library, as I used his code structure)

I've just posted my own leveling code for you in my previous post(s), hehe.

Though, I'd love to see your inventory system once you've got that done, I've made a very "poor-man's-coding" of one: a root container full of many child subdivision container objects and coding to put the stuff into the right container object ~ though it's only done for "spells", lol. If, you're interested, let me know.

Also, Sora and his~her Stackable Library, does just that, puts multiple same type of objects "together", and then removes them as well too.

Sora's Stackable Library: viewtopic.php?f=18&t=3515

and here's some other useful links:

The libraries: viewforum.php?f=18

The Wiki's pages:

http://quest5.net/wiki/Main_Page
http://quest5.net/wiki/Tutorial
http://quest5.net/wiki/How_to

and the "Quest Coding Bible" wiki pages:

http://quest5.net/wiki/Category:All_Fun ... t_Commands (page 1, range: A-S)
http://quest5.net/w/index.php?title=Cat ... h#mw-pages (page 2, range: S-Z)

enjoy :D



Thank you for your continued help. I keep fiddling, restarting and applying what I have learned, then restarting again. I will share what I have when I have it. At the moment, I have gone back and redone the way my player object is organized. In the last iteration, it was all a mess, so here I have neatened it all up and initialized all the attributes and attribute scripts. Here it is so far.

<!--Saved by Quest 5.4.4873.16527-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<include ref="StackLibrary.aslx" />
<include ref="wearables.aslx" />
<include ref="combat_lib.aslx" />
<game name="Ascendancy: MLP">
<gameid>104eec08-3128-4e94-9323-9266bda65982</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<strength type="int">0</strength>
<agility type="int">0</agility>
<stamina type="int">0</stamina>
<intellect type="int">0</intellect>
<wits type="int">0</wits>
<personality type="int">0</personality>
<hits type="int">0</hits>
<attr name="modified_strength" type="int">0</attr>
<attr name="modified_stamina" type="int">0</attr>
<attr name="modified_agility" type="int">0</attr>
<attr name="amour_class" type="int">0</attr>
<status>-</status>
<attr name="max_hits" type="script">
max_hits = hits + stamina
</attr>
<attr name="current_hits" type="script">
current_hits = hits + stamina
</attr>
<attr name="rainbow_dash_relation" type="script">
raibow_dash_relation = strength + agility
</attr>
<attr name="rarity_relation" type="script">
rarity_relation = personality + intellect
</attr>
<attr name="pinkie_pie_relation" type="script">
pinkie_pie_relation = personality + stamina
</attr>
<attr name="apple_jack_relation" type="script">
apple_jack_relation = strength + stamina
</attr>
<attr name="fluttershy_relation" type="script">
fluttershy_relation = personality + strength
</attr>
<attr name="twilight_sparkle_relation" type="script">
twilight_sparkle_relation = intellect + wits
</attr>
</object>
</object>
<function name="start_menu">
</function>
</asl>


As you can see...much neater already. I am using stackables, wearables and the combat libraries.

HegemonKhan
Rainbow Dash wrote:Nope, that confused the hell out of me. Let me see if I can figure it out. In the fuction that I create, do I use the scripts to make my menu system?


yes

Add a~new script -> Output -> show menu -> (fill it in)*

*(this is for in-code though, you can figure out how to do it in the GUI~Editor) you either have to make a new string list (and then write in to its place, its: your_name_of_object.your_name_of_string_list):

http://quest5.net/wiki/Using_Lists
http://quest5.net/wiki/List_add
http://quest5.net/wiki/List_remove
http://quest5.net/wiki/ListCombine
http://quest5.net/wiki/ListContains
http://quest5.net/wiki/ListCount
http://quest5.net/wiki/ListExclude
http://quest5.net/wiki/ListItem

or the wonderful:

"Split" ( http://quest5.net/wiki/Split ) // I'm not sure if this is in the GUI~Editor's "add a~new script" button's choices or not
"Switch" ( http://quest5.net/wiki/Switch ) // this is in the GUI~Editor's "add a~new script" button's choices

it's roughly like this (my format+syntax may not be correct due to the changes in v5.4):

(NOT using "split", thus you create a permanent~global list, that you can reuse anywhere)

<object name="King_Stupid">
<alias>The King</alias>
<chat type="script">
game.conversation_menu_list_1 = NewStringList ()
list add (conversation_menu_list_1, "princess")
list add (conversation_menu_list_1, "legendary_dragon_slayer_sword")
list add (conversation_menu_list_1, "evil_dragon_king")
show menu ("What do you want to know about?", game.conversation_menu_list_1, false) {
your_selection = result
switch (your_selection) {
case ("princess") {
msg ("She needs to get married, rescue her, and she's all yours and along with my kingdom and wealth!")
}
case ("legendary_dragon_slayer_sword") {
msg ("You need this to kill the dragon, dummy!")
}
case ("evil_dragon_king") {
msg ("He has stolen my daughter, kill it, and save your princess!")
}
}
}
</chat>
<displayverbs type="simplestringlist">Chat</displayverbs>
</obejct>


or, with using "split", instead:

(using "split", thus you create a temprory~local list, that you can NOT reuse anywhere else)

<object name="King_Stupid">
<alias>The King</alias>
<chat type="script">
show menu ("What do you want to know about?", split ("princess;legendary_dragon_slayer_sword;evil_dragon_king",";"), false) {
your_selection = result
switch (your_selection) {
case ("princess") {
msg ("She needs to get married, rescue her, and she's all yours and along with my kingdom and wealth!")
}
case ("legendary_dragon_slayer_sword") {
msg ("You need this to kill the dragon, dummy!")
}
case ("evil_dragon_king") {
msg ("He has stolen my daughter, kill it, and save your princess!")
}
}
</chat>
<displayverbs type="simplestringlist">Chat</displayverbs>
</obejct>

HegemonKhan
Rainbow Dash wrote:Thank you for your continued help. I keep fiddling, restarting and applying what I have learned, then restarting again. I will share what I have when I have it. At the moment, I have gone back and redone the way my player object is organized. In the last iteration, it was all a mess, so here I have neatened it all up and initialized all the attributes and attribute scripts. Here it is so far.

<!--Saved by Quest 5.4.4873.16527-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<include ref="StackLibrary.aslx" />
<include ref="wearables.aslx" />
<include ref="combat_lib.aslx" />
<game name="Ascendancy: MLP">
<gameid>104eec08-3128-4e94-9323-9266bda65982</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<strength type="int">0</strength>
<agility type="int">0</agility>
<stamina type="int">0</stamina>
<intellect type="int">0</intellect>
<wits type="int">0</wits>
<personality type="int">0</personality>
<hits type="int">0</hits>
<attr name="modified_strength" type="int">0</attr>
<attr name="modified_stamina" type="int">0</attr>
<attr name="modified_agility" type="int">0</attr>
<attr name="amour_class" type="int">0</attr>
<status>-</status>
<attr name="max_hits" type="script">
max_hits = hits + stamina
</attr>
<attr name="current_hits" type="script">
current_hits = hits + stamina
</attr>
<attr name="rainbow_dash_relation" type="script">
raibow_dash_relation = strength + agility
</attr>
<attr name="rarity_relation" type="script">
rarity_relation = personality + intellect
</attr>
<attr name="pinkie_pie_relation" type="script">
pinkie_pie_relation = personality + stamina
</attr>
<attr name="apple_jack_relation" type="script">
apple_jack_relation = strength + stamina
</attr>
<attr name="fluttershy_relation" type="script">
fluttershy_relation = personality + strength
</attr>
<attr name="twilight_sparkle_relation" type="script">
twilight_sparkle_relation = intellect + wits
</attr>
</object>
</object>
<function name="start_menu">
</function>
</asl>


As you can see...much neater already. I am using stackables, wearables and the combat libraries.


looks good to me (though I haven't worked with the <attr></attr> stuff yet, so I don't know if you got that set up correctly, but I'm sure you can figure it out, if it's not working as you want it to for you). Do you get any errors when (1) trying to start~load up the game (into the Editor~Gui), and (2) while actually playing your game?

-----------

P.S.

you got "armor" mispelled~typo'ed:

"amour" ( =love, I think, lol) -> armor or armour (meh stupid grammer~spelling and~or difference between U.K. English and U.S. English, or just my own or us americans' laziness ~ too tired to type in the "u", lol)

unfortunately, coding can't have any typo'es, as precise spelling~format~syntax is required to the computer~quest software to understand what you're telling it to do, lol.

Rainbow Dash
HegemonKhan wrote:

"Rainbow Dash"

Thank you for your continued help. I keep fiddling, restarting and applying what I have learned, then restarting again. I will share what I have when I have it. At the moment, I have gone back and redone the way my player object is organized. In the last iteration, it was all a mess, so here I have neatened it all up and initialized all the attributes and attribute scripts. Here it is so far.

<!--Saved by Quest 5.4.4873.16527-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<include ref="StackLibrary.aslx" />
<include ref="wearables.aslx" />
<include ref="combat_lib.aslx" />
<game name="Ascendancy: MLP">
<gameid>104eec08-3128-4e94-9323-9266bda65982</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<strength type="int">0</strength>
<agility type="int">0</agility>
<stamina type="int">0</stamina>
<intellect type="int">0</intellect>
<wits type="int">0</wits>
<personality type="int">0</personality>
<hits type="int">0</hits>
<attr name="modified_strength" type="int">0</attr>
<attr name="modified_stamina" type="int">0</attr>
<attr name="modified_agility" type="int">0</attr>
<attr name="amour_class" type="int">0</attr>
<status>-</status>
<attr name="max_hits" type="script">
max_hits = hits + stamina
</attr>
<attr name="current_hits" type="script">
current_hits = hits + stamina
</attr>
<attr name="rainbow_dash_relation" type="script">
raibow_dash_relation = strength + agility
</attr>
<attr name="rarity_relation" type="script">
rarity_relation = personality + intellect
</attr>
<attr name="pinkie_pie_relation" type="script">
pinkie_pie_relation = personality + stamina
</attr>
<attr name="apple_jack_relation" type="script">
apple_jack_relation = strength + stamina
</attr>
<attr name="fluttershy_relation" type="script">
fluttershy_relation = personality + strength
</attr>
<attr name="twilight_sparkle_relation" type="script">
twilight_sparkle_relation = intellect + wits
</attr>
</object>
</object>
<function name="start_menu">
</function>
</asl>


As you can see...much neater already. I am using stackables, wearables and the combat libraries.


looks good to me (though I haven't worked with the <attr></attr> stuff yet, so I don't know if you got that set up correctly, but I'm sure you can figure it out, if it's not working as you want it to for you). Do you get any errors when (1) trying to start~load up the game (into the Editor~Gui), and (2) while actually playing your game?



No errors thus far no. And I am working in a combination of GUI and code now. I use the GUI to get the syntax correct and then use that as a template for coding.

Rainbow Dash
Okay, I have hit a snag with the new code. I cant get the current_hits value to display in the status window. I throws up a really strange error. Here is the code I have so far:

<!--Saved by Quest 5.4.4873.16527-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<include ref="StackLibrary.aslx" />
<include ref="wearables.aslx" />
<include ref="combat_lib.aslx" />
<game name="Ascendancy: MLP">
<gameid>104eec08-3128-4e94-9323-9266bda65982</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<start type="script">
start_menu
</start>
</game>
<object name="Please choose an option">
<inherit name="editor_room" />
<usedefaultprefix type="boolean">false</usedefaultprefix>
<dark />
<darkroomdescription type="string"></darkroomdescription>
<descprefix type="string"></descprefix>
<objectslistprefix type="string"></objectslistprefix>
<description type="script">
</description>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<strength type="int">0</strength>
<agility type="int">0</agility>
<stamina type="int">0</stamina>
<intellect type="int">0</intellect>
<wits type="int">0</wits>
<personality type="int">0</personality>
<level type="int">1</level>
<class type="string"></class>
<experience type="int">0</experience>
<hits type="int">5</hits>
<attr name="modified_strength" type="int">0</attr>
<attr name="modified_stamina" type="int">0</attr>
<attr name="modified_agility" type="int">0</attr>
<attr name="amour_class" type="int">0</attr>
<status>-</status>
<statusattributes type="stringdictionary">
<item>
<key>alias</key>
<value>Name: !</value>
</item>
<item>
<key>class</key>
<value>Class: !</value>
</item>
<item>
<key>level</key>
<value>Level: !</value>
</item>
<item>
<key>experience</key>
<value>EXP: !</value>
</item>
</statusattributes>
<attr name="max_hits" type="script">
max_hits = hits + stamina
</attr>
<attr name="current_hits" type="script">
current_hits = hits + stamina
</attr>
<attr name="rainbow_dash_relation" type="script">
raibow_dash_relation = strength + agility
</attr>
<attr name="rarity_relation" type="script">
rarity_relation = personality + intellect
</attr>
<attr name="pinkie_pie_relation" type="script">
pinkie_pie_relation = personality + stamina
</attr>
<attr name="apple_jack_relation" type="script">
apple_jack_relation = strength + stamina
</attr>
<attr name="fluttershy_relation" type="script">
fluttershy_relation = personality + strength
</attr>
<attr name="twilight_sparkle_relation" type="script">
twilight_sparkle_relation = intellect + wits
</attr>
</object>
</object>
<function name="start_menu">
start_options = NewStringList()
list add (start_options, "New Game")
list add (start_options, "Instructions")
list add (start_options, "Background")
list add (start_options, "Note from the Author")
ShowMenu ("START MENU", start_options, false) {
}
</function>
</asl>


And here is the error:

Error running script: Error compiling expression 'Replace(format, "!", value)': FunctionCallElement: Could find not function 'Replace(String, String, LazyLoadScript)'
Please choose an option.
Error running script: Error compiling expression 'Replace(format, "!", value)': FunctionCallElement: Could find not function 'Replace(String, String, LazyLoadScript)'
Error running script: Error compiling expression 'Replace(format, "!", value)': FunctionCallElement: Could find not function 'Replace(String, String, LazyLoadScript)'

HegemonKhan
I got to go to bed, so I haven't yet loaded up your game to test fixes, but just from looking at it, here's some guesses at it:

All of those Status Attributes, need you to create (add) those actual Attributes!

player -> Attributes (Tab) -> Attributes -> Add ->

Name: alias
Type: string
Value: (whatever you want it to be, what you want to be called or it to be called, lol)

Name: class
Type: stringlist (is better as you can then use a menu to choose from a selection that you create for it, but you can do~use a string too)
Value (for example): warrior, cleric, mage, thief

level... experience...

etc... (all those new attributes in your Status Attributes, must actually be made, you need to make~add those attributes as attributes to your "player" !!!)

--------------

player (or whatever Object) -> Attributes (Tab) -> Attributes -> Add ->

*THIS CREATES THE ATTRIBUTES, IF YOU DON'T CREATE ATTRIBUTES, YOU DON'T HAVE ANY ATTRIBUTES!*

player (this however is ONLY for~of a Player Object or the Game Object) -> Attributes (Tab) -> Status Attributes -> Add ->

this is merely what you THEN want to do (in terms of how they get displayed and~or changed) with the attributes that you already created (or will create to get rid of the errors! ~ hopefully, lol) created !!!

-------------

if you still got the errors, I'll look at it tomarrow after class... if someone else hasn't helped you yet.

----------------------

if I myself understand the Error correctly:

Could find not function -> and thus could NOT -> run script: compiling expression: 'Replace (format, "!", value)'

there's no attribute for the core~built-in~internal function to work

you need to create (add) the ATTRIBUTE itself too, not just the Status Attribute (FUNCTION) for~of the (MISSING) Attribute.

Rainbow Dash
HegemonKhan wrote:I got to go to bed, so I haven't yet loaded up your game to test fixes, but just from looking at it, here's some guesses at it:

All of those Status Attributes, need you to create (add) those actual Attributes!

player -> Attributes (Tab) -> Attributes -> Add ->

Name: alias
Type: string
Value: (whatever you want it to be, what you want to be called or it to be called, lol)

Name: class
Type: stringlist (is better as you can then use a menu to choose from a selection that you create for it, but you can do~use a string too)
Value (for example): warrior, cleric, mage, thief

level... experience...

etc... (all those new attributes in your Status Attributes, must actually be made, you need to make~add those attributes as attributes to your "player" !!!)

--------------

player (or whatever Object) -> Attributes (Tab) -> Attributes -> Add ->

*THIS CREATES THE ATTRIBUTES, IF YOU DON'T CREATE ATTRIBUTES, YOU DON'T HAVE ANY ATTRIBUTES!*

player (this however is ONLY for~of a Player Object or the Game Object) -> Attributes (Tab) -> Status Attributes -> Add ->

this is merely what you THEN want to do (in terms of how they get displayed and~or changed) with the attributes that you already created (or will create to get rid of the errors! ~ hopefully, lol) created !!!

-------------

if you still got the errors, I'll look at it tomarrow after class... if someone else hasn't helped you yet.


Yeah, I created them all there, still getting errors.

HegemonKhan
Capitol letters vs Lower-Case letters matter, exact typing~matching for the ID stuff (Name Attributes).

you either have to have (for the Name Attributes):

"Level" (Attribute) and "Level" (Status Attribute)
~OR~
"level" (Attribute) and "level" (Status Attribute)

~NOT~
"level" (Attribute) and "Level" (Status Attribute)
~NOR~
"Level" (Attribute) and "level" (Status Attribute)

-----------------------------

if this doesn't still get rid of the errors, then there's just probably incorrect format~syntax for the Status Attribute stuff~code lines (maybe the "Values" need to have quatation marks enclosing the text: <value>"Class: !"</value> OR <value>"Class: " + !</value>, meh), or I'm completely off the mark, and it's some other different part of your code, lol.

You can also just try leaving the values blank: <value></value>

---------------------

don't worry though, 99% of the time the ERRORS are extremely small~simple mistakes~typo'es, lol. It's just a matter of finding it~them, lol.

-------------------

welcome to the "trouble shooting" process... lol

you can always try, removing code section~segment one at a time, to see where the issue(s) is(are)... :D

trouble shooting my combat code was ... a challenge... but wow... when you are successful at trouble shooting, you know you're definately learning to code, alright, lol :D

-----------------

maybe it's your <attr> stuff...

you might need the Objects with it:

player.attribute_? = player.strength + player.wits // (or whatever your scripts are, lol)

jaynabonne
You have this:

<attr name="current_hits" type="script">
current_hits = hits + stamina
</attr>


You have a *script* called current_hits, and within that, it's manipulating both current_hits and hits. If you actually do run "current_hits", it will replace itself with an integer!

It looks like you changed variable names mid-stream. I think you need to change the above to:

<attr name="current_hits" type="script">
hits = hits + stamina
</attr>


and then add "hits" to your status. If you do want the status attribute to be current_hits, then you need to change more things than that to make it all consistent.

Rainbow Dash
jaynabonne wrote:You have this:

<attr name="current_hits" type="script">
current_hits = hits + stamina
</attr>


You have a *script* called current_hits, and within that, it's manipulating both current_hits and hits. If you actually do run "current_hits", it will replace itself with an integer!

It looks like you changed variable names mid-stream. I think you need to change the above to:

<attr name="current_hits" type="script">
hits = hits + stamina
</attr>


and then add "hits" to your status. If you do want the status attribute to be current_hits, then you need to change more things than that to make it all consistent.


As the Fonz would say, ,hey!!! That fixed it. I changed the name of the scripts rather than the variable and it worked perfectly. Thank you very much. :)

Rainbow Dash
Okay, this is starting to annoy me now...why wont this

<playermaxhits type="int">playerbasehits + playerstamina</playermaxhits>

Work!?

jaynabonne
Assuming you want something like:

playermaxhits = playerbasehits + playerstamina


as an initialization value, you'll need to put such expression into a script, perhaps the start script for the game. You can't initialize an attribute to an expression.

Rainbow Dash
jaynabonne wrote:Assuming you want something like:

playermaxhits = playerbasehits + playerstamina


as an initialization value, you'll need to put such expression into a script, perhaps the start script for the game. You can't initialize an attribute to an expression.


Okay, so, that would mean putting it as an attribute into the game attributes area?

Like this?

  <game name="Ascendancy: MLP">
<gameid>675d0491-f241-46ec-bc70-d9875255241a</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<playmaxhits type="script">
playermaxhits = playerbasehits + playerstamina
</playmaxhits>
</game>

jaynabonne
Put it in a start script like this:

  <game name="Ascendancy: MLP">
<gameid>675d0491-f241-46ec-bc70-d9875255241a</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<start type="script">
playermaxhits = playerbasehits + playerstamina
</start>
</game>

You don't need to define the attribute ahead of time if you assign it before you use it. The attribute will be created at the time you assign it. The "start" script is run automatically by Quest when the game starts. But you *can* define it if you want:

  <playermaxhits type="int">0</playermaxhits>

Rainbow Dash
<!--Saved by Quest 5.4.4873.16527-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Ascendancy: MLP">
<gameid>675d0491-f241-46ec-bc70-d9875255241a</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<start type="script">
start_menu
playermaxhits = playerbasehits + playerstamina
playercurrenthits = playerbasehits + playerstamina
playerattack = playeragility
playerdefense = playeragility
</start>


Like that? Because I get an error with it like that:

Error running script: Error compiling expression 'playerbasehits + playerstamina': Unknown object or variable 'playerbasehits'

jaynabonne
Sorry. My mistake. :) The variables belong to the game object so:

game.playermaxhits = game.playerbasehits + game.playerstamina


Since you're in a script running on the game object, you could also use "this" instead of "game", as "this" will refer to the game object.

Rainbow Dash
jaynabonne wrote:Sorry. My mistake. :) The variables belong to the game object so:

game.playermaxhits = game.playerbasehits + game.playerstamina


Since you're in a script running on the game object, you could also use "this" instead of "game", as "this" will refer to the game object.


Ahhhh...I understand more now. So, the 'player.', 'game.' and 'this.' they all apply a variable/attribute to a object, in this case the name before the dot.

and that didnt work, its throws up this error:

Error running script: Error compiling expression 'game.playerbasehits + game.playerstamina': ArithmeticElement: Operation 'Add' is not defined for types 'Object' and 'Object'

jaynabonne
I guess I had assumed that you would have those attributes defined already, either as attribute definitions or as script lines. I was never really sure where they came from... Here's an example:

  <game name="Ascendancy: MLP">
<gameid>675d0491-f241-46ec-bc70-d9875255241a</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<playerbasehits type="int">5</playerbasehits>
<playerstamina type="int">3</playerstamina>
<playeragility type="int">6</playeragility>
<start type="script">
start_menu
game.playermaxhits = game.playerbasehits + game.playerstamina
game.playercurrenthits = game.playerbasehits + game.playerstamina
game.playerattack = game.playeragility
game.playerdefense = game.playeragility
</start>
</game>


I just typed that in here. I hope it's all right. :)

Edit: You *could* have attributes on the player called "maxhits", "stamina", etc. and then use "player.maxhits", "player.stamina", etc instead of game.playermaxhits, game.playerstamina, etc. Just a design thought.

Rainbow Dash
jaynabonne wrote:I guess I had assumed that you would have those attributes defined already, either as attribute definitions or as script lines. I was never really sure where they came from... Here's an example:

  <game name="Ascendancy: MLP">
<gameid>675d0491-f241-46ec-bc70-d9875255241a</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<playerbasehits type="int">5</playerbasehits>
<playerstamina type="int">3</playerstamina>
<playeragility type="int">6</playeragility>
<start type="script">
start_menu
game.playermaxhits = game.playerbasehits + game.playerstamina
game.playercurrenthits = game.playerbasehits + game.playerstamina
game.playerattack = game.playeragility
game.playerdefense = game.playeragility
</start>
</game>


I just typed that in here. I hope it's all right. :)

Edit: You *could* have attributes on the player called "maxhits", "stamina", etc. and then use "player.maxhits", "player.stamina", etc instead of game.playermaxhits, game.playerstamina, etc. Just a design thought.


Thanks for that. Okay, so I have now moved all my variable up into the game. area so that they are initialized with the game for use later on. Though, Will these attributes will be useable on the player or are they now tied to the game?

<!--Saved by Quest 5.4.4873.16527-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Ascendancy: MLP">
<gameid>675d0491-f241-46ec-bc70-d9875255241a</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<playerclass type="string"></playerclass>
<playerlevel type="int">1</playerlevel>
<playerexp type="int">0</playerexp>
<playerstrength type="int">0</playerstrength>
<playeragility type="int">0</playeragility>
<playerstamina type="int">0</playerstamina>
<playerintellect type="int">0</playerintellect>
<playerwits type="int">0</playerwits>
<playerpersonality type="int">0</playerpersonality>
<playerbasehits type="int">0</playerbasehits>
<start type="script">
start_menu
game.playermaxhits = game.playerbasehits + game.playerstamina
game.playercurrenthits = game.playerbasehits + game.playerstamina
game.playerattack = game.playeragility
game.playerdefense = game.playeragility
</start>


Okay, this is REALLY annoying. Working with variables in this engine is stupidly complicated and needlessly so. Why cant I just add two variable together to get another variable? We have been able to do that since basic.

These are meant to be player stats, not game stats. I have to be able to apply these to a player AND be able to manipulate them, add them together to get new variables for use later down the line, etc, etc. It seems this program cannot do that.

HegemonKhan
Attributes are permanent "stats", which can thus be used anywhere:

the correct "CREATION OF ATTRIBUTE" format is this:

GUI~Editor: "blah" (Object) -> Attribute (Tab) -> Attributes -> Add -> (make your Attribute: Name, Type, and Value)

Code:

<object name="your_object_name">
<name_of_your_attribute type="your_choosen_attribute_type">your_Attribute_Value</name_of_your_attribute>
</object>

for example:

<object name="orc">
<strength type="int">50</strength>
</object>


the correct SCRIPTING (USING OF YOUR ATTRIBUTE) format is this, in Code:

Object.Attribute // only for String, Stringlist, and Boolean=True Attribute Types
~OR~
Object.Attribute=Value

so, for example:

player.warrior // a Stringlist choice for your "class" Attribute, (I think) it's the same as: player.class="warrior")
~OR~
player.strength=100

------------------------------------------

........V
Object . Attribute = Value (no spaces though, just doing this to make the dot~period more visable hopefully, lol)
........^

you need that period~dot! it is the "attach'er", the code equivalent of: "blah" (Object) -> Attributes (Tab) -> Attributes -> Add

and for an (example) expression, the correct format is this:

Object.Attribute = Object.Attribute (and must be same Attribute Type) + Object.Attribute (and must be same Attribute Type)

SOO......

I think you want this (if I'm correct, Jayna was misunderstanding you, not realizing that the "player" was your Attributes' Objects, it seems like Jayna thought your "playermaxhits" was simply the name of your Attribute, not realizing you were just forgetting~not knowing~ to put in the dot~period to separate, ie attach, the Object and Attribute words~labels~"names"):

Player Object: player.maxhits = player.basehits + player.stamina // you ALSO need to actually CREATE (ADD) these Attributes IN the "player" Player Object !!!

~OR~

Game Object: game.maxhits = game.basehits + game.stamina // you ALSO need to actually CREATE (ADD) these Attributes IN the Game Object !!!

~OR~

as Jayna thought that "player" was just part of your Attribute's Name Attribute, hehe:

Player Object: player.playermaxhits = player.playerbasehits + player.playerstamina // you ALSO need to actually CREATE (ADD) these Attributes IN the "player" Player Object !!!

~OR~

Game Object: game.playermaxhits = game.playerbasehits + game.playerstamina // you need to actually CREATE (ADD) these Attributes IN the Game Object !!! (jayna choose to ATTACH your attribute for the Game Object: "game.name_of_Attribute", as you didn't have it attached to anything, you had no period in it, separating~attaching Object from~to its Attribute!).

-----------------------------

Also...

for "Object.Attribute", the Object and Attribute can be whatever you want:

Object: Player Objects (examples: "player", "HK", "Rainbow Dash"), Normal~Object Objects (examples: "orc", "book", "global_event_data_object"), Room Objects (examples: "room", "wasteland"), and the Game Object ("game")

Attribute: no need to explain what you already know, lol.

HOWEVER...

for what is displayed on the right side (STATUS ATTRIBUTES) while playing the game, it's ONLY for these Objects:

the Player Objects and the Game Object

------------------------------------------------

so, by the way:

the Game Object:

GUI~Editor: Game (Object) -> 6 Tabs: Setup ~ Script ~ Room Descriptions ~ Player ~ Display ~ Attributes

Code, for Creation:

<game name="blah">
</game>

Default Game Object and its Attributes from a new game:

<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
</game>


Code, for SCRIPTING (USING):

game.Attribute
~OR~
game.Attribute=Value

--------------------------------------------------

The Player Object:

1. the default is: "player"
2. you can have many player objects, and can switch between (your control of) them.
3. GUI~Editor: Game -> Player (Tab) -> Player Object box -> choose or leave blank
~AND~
"blah" (Object) -> Setup (Tab) -> Object Type box: OBJECT
"blah" (Object) -> Options (Tab) -> Player box -> CAN BE PLAYER
4. http://quest5.net/wiki/Changing_the_player_object

Code, for CREATION:

example only:

<object name="HK">
<inherit name="editor_player" />
<strength type="int">100</strength>
</object>


Code, for SCRIPTING:

example only:

HK.strength=100

----------------------------

last thing:

game.pov

game.pov represents whoever is your CURRENTLY CONTROLLED Player Object

so let's say we've got 3 Player Objects:

Default: "player"
Created #1: "HK"
Created #2: "RD" // Rainbow Dash

player.strength=0
HK.strength=100
RD.strength=50

"game.pov.strength" is the same as "player.strength"
"game.pov.strength" is the same as "HK.strength"
"game.pov.strength" is the same as "RD.strength"

IF you only have a single Player Object in your game

however, if you do have multiple Player Objects in your game:

then you got to be careful... with using "game.pov", because...

it'll be applied to whoever is your currently controlled Player Object

so, for an example:

"player" is an archer who gets: +2 dexterity at level ups
"HK" is a warrior who gets: +2 strength at level ups
"RD" is a mage who gets: +2 intelligence at level ups

if you were to use:

game.pov.dex = game.pov.dex + 2

then, if your currently controlled player object is "HK" when you receive a level up, would get the +2 dex

so, if you got specific scripts for specific Player Objects, then use (for examples): player.Attribute OR HK.Attribute OR RD.Attribute

however, some scripts you intentionally want+make them to be applied to all of your Player Objects, such as this example:

receiving experience from a monster after killing it:

game.pov.experience = game.pov.experience + name_of_monster_object.experience // this will correctly give that experience amount to the Player Object that killed the monster, whoever that Player Object is (in the moment that you kill the monster)

as you don't want to do script it three times, lol:

player.experience = player.experience + name_of_monster_object.experience
HK.experience = HK.experience + name_of_monster_object.experience
RD.pov.experience = RD.pov.experience + name_of_monster_object.experience

Rainbow Dash
HegemonKhan wrote:Attributes are permanent "stats", which can thus be used anywhere:

the correct "CREATION OF ATTRIBUTE" format is this:

GUI~Editor: "blah" (Object) -> Attribute (Tab) -> Attributes -> Add -> (make your Attribute: Name, Type, and Value)

Code:

<object name="your_object_name">
<name_of_your_attribute type="your_choosen_attribute_type">your_Attribute_Value</name_of_your_attribute>
</object>

for example:

<object name="orc">
<strength type="int">50</strength>
</object>


the correct SCRIPTING (USING OF YOUR ATTRIBUTE) format is this, in Code:

Object.Attribute // only for String, Stringlist, and Boolean=True Attribute Types
~OR~
Object.Attribute=Value

so, for example:

player.warrior // a Stringlist choice for your "class" Attribute, (I think) it's the same as: player.class="warrior")
~OR~
player.strength=100

------------------------------------------

........V
Object . Attribute = Value (no spaces though, just doing this to make the dot~period more visable hopefully, lol)
........^

you need that period~dot! it is the "attach'er", the code equivalent of: "blah" (Object) -> Attributes (Tab) -> Attributes -> Add

and for an (example) expression, the correct format is this:

Object.Attribute = Object.Attribute (and must be same Attribute Type) + Object.Attribute (and must be same Attribute Type)

SOO......

I think you want this (if I'm correct, Jayna was misunderstanding you, not realizing that the "player" was your Attributes' Objects, it seems like Jayna thought your "playermaxhits" was simply the name of your Attribute, not realizing you were just forgetting~not knowing~ to put in the dot~period to separate, ie attach, the Object and Attribute words~labels~"names"):

player.maxhits = player.basehits + player.stamina

-----------------------------

Also...

for "Object.Attribute", the Object and Attribute can be whatever you want:

Object: Player Objects (examples: "player", "HK", "Rainbow Dash"), Normal~Object Objects (examples: "orc", "book", "global_event_data_object"), Room Objects (examples: "room", "wasteland"), and the Game Object

Attribute: no need to explain what you already know, lol.

HOWEVER...

for what is displayed on the right side (STATUS ATTRIBUTES) while playing the game, it's ONLY for these Objects:

the Player Objects and the Game Object

------------------------------------------------

so, by the way:

the Game Object:

GUI~Editor: Game (Object) -> 6 Tabs: Setup ~ Script ~ Room Descriptions ~ Player ~ Display ~ Attributes

Code, for Creation:

<game name="blah">
</game>

Default Game Object and its Attributes from a new game:

<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
</game>


Code, for SCRIPTING (USING):

game.Attribute
~OR~
game.Attribute=Value

--------------------------------------------------

The Player Object:

1. the default is: "player"
2. you can have many player objects, and can switch between (your control of) them.
3. GUI~Editor: Game -> Player (Tab) -> Player Object box -> choose or leave blank
~AND~
"blah" (Object) -> Setup (Tab) -> Object Type box: OBJECT
"blah" (Object) -> Options (Tab) -> Player box -> CAN BE PLAYER
4. http://quest5.net/wiki/Changing_the_player_object

Code, for CREATION:

example only:

<object name="HK">
<inherit name="editor_player" />
<strength type="int">100</strength>
</object>


Code, for SCRIPTING:

example only:

HK.strength=100

----------------------------

last thing:

game.pov

game.pov represents whoever is your CURRENTLY CONTROLLED Player Object

so let's say we've got 3 Player Objects:

Default: "player"
Created #1: "HK"
Created #2: "RD" // Rainbow Dash

player.strength=0
HK.strength=100
RD.strength=50

"game.pov.strength" is the same as "player.strength"
"game.pov.strength" is the same as "HK.strength"
"game.pov.strength" is the same as "RD.strength"

IF you only have a single Player Object in your game

however, if you do have multiple Player Objects in your game:

then you got to be careful... with using "game.pov", because...

it'll be applied to whoever is your currently controlled Player Object

so, for an example:

"player" is an archer who gets: +2 dexterity at level ups
"HK" is a warrior who gets: +2 strength at level ups
"RD" is a mage who gets: +2 intelligence at level ups

if you were to use:

game.pov.dex = game.pov.dex + 2

then, if your currently controlled player object is "HK" when you receive a level up, would get the +2 dex

so, if you got specific scripts for specific Player Objects, then use (for examples): player.Attribute OR HK.Attribute OR RD.Attribute

however, some scripts you intentionally want+make them to be applied to all of your Player Objects, such as this example:

receiving experience from a monster after killing it:

game.pov.experience = game.pov.experience + name_of_monster_object.experience // this will correctly give that experience amount to the Player Object that killed the monster, whoever that Player Object is (in the moment that you kill the monster)

as you don't want to do script it three times, lol:

player.experience = player.experience + name_of_monster_object.experience
HK.experience = HK.experience + name_of_monster_object.experience
RD.pov.experience = RD.pov.experience + name_of_monster_object.experience


OKay, I understand, I got most of that. It doesnt help me to understand how to create a variable the way I need it to be.

I need to have a set of statistics as follows:

Strength - "Set by the players choice of class"
Agility - "Set by class"
Stamina - "Set by class"
Intellect - "Set by class"
Wits - "Set by class"
Personality - "Set by class"
Base Hits - "Set by class"

All of these need to be tied to the player object.

THEN I need a set of variables that can be freely altered in a number of ways, such as:

Attack - This is the sum of the characters Strength and Agility stat. So, I need to be able to add the strength and agility together to get this stat...but it also needs to be on the player object. Do you understand now what I need?

Sorry if I sound like I am getting short. This program is making a pigs-ear out of something that should be really bloody simple.

Rainbow Dash
Rainbow Dash wrote:

"HegemonKhan"

Stuff was said here.



OKay, I understand, I got most of that. It doesnt help me to understand how to create a variable the way I need it to be.

I need to have a set of statistics as follows:

Strength - "Set by the players choice of class"
Agility - "Set by class"
Stamina - "Set by class"
Intellect - "Set by class"
Wits - "Set by class"
Personality - "Set by class"
Base Hits - "Set by class"

All of these need to be tied to the player object.

THEN I need a set of variables that can be freely altered in a number of ways, such as:

Attack - This is the sum of the characters Strength and Agility stat. So, I need to be able to add the strength and agility together to get this stat...but it also needs to be on the player object. Do you understand now what I need?

Sorry if I sound like I am getting short. This program is making a pigs-ear out of something that should be really bloody simple.


HegemonKhan
Variables:

these are just temporary~local "placeholders" for within a specific script:

in SCRIPTING:

for example, the "get input" and "show menu" creates and sets your selected choice to the Variable: "result"

get input ("What is your name?") {
-> // this is done automatically~internally~hiddenly (you don't get to see this happen): result = "HK"
-> msg ("Your name is " + result) // this is displayed during game play: Your name is HK
}

show menu ("what gender are you?", split ("male;female",":"), false) {
-> // this is done automatically~internally~hiddenly (you don't get to see this happen): result = "male"
-> switch (result) {
->-> case ("male") {
->->-> HK.strength = HK.strength + 2
->->-> msg (player.alias + "gets +2 strength")
->-> }
->-> case ("female") {
->->-> HK.dexterity = HK.dexterity + 2
->->-> msg (player.alias + "gets +2 dexterity")
->-> }
-> }
}
// this gets displayed during game play (as I'm male, thus I'd choose male, lol): HK gets +2 strength

notice how a Variable's syntax~format is:

Variable = (blah whatever~coding)

compared to an Attribute:

Object.Attribute = (blah whatever~coding)

see, the difference? "Object._____" vs "_____"

"Object.Attribute=______" = a "stat" that you can use anywhere. As a stat is "of something", an Object.

"Variable=_____" = merely a placeholder for ONLY the script it is within

do you realize that a "Variable" becomes (this is NOT creation though of) an "Attribute", by just adding the "Object." to it?

HK.strength <---> an Attribute
endurance <---> a Variable
RD.endurance <----> an Attribute

Attributes require that you actually CREATE (ADD) it ALSO:

GUI~Editor: "blah" (Object) -> Attributes (Tab) -> Attributes -> Add -> (Name, Type, Value)
Code: <name_of_attribute type="type_of_attribute">value_of_attribute</name_of_attribute>

Variables do NOT have any creation for them, they're just local~temporary "placeholding" words for the script that they're in.

here's an example of a Variable being used:

<function name="battle_sequence_function" parameters="self,enemy"><![CDATA[
if (enemy.dead=false or self.escaped=false) {
you_go_first=false
if (GetInt (self,"speed") > GetInt (enemy,"speed") {
you_go_first=true
} else if (GetInt (self,"speed") = GetInt (enemy,"speed") and RandomChance (50)=true) {
you_go_first=true
}
if (you_go_first=true) {
msg ("You get to go first for this round")
self_battle_turn_function (self,enemy)
on ready {
if (not enemy.dead=true or not self.escaped=true){
enemy_battle_turn_function (self,enemy)
}
}
} else {
msg (enemy.alias + " gets to go first for this round.")
enemy_battle_turn_function (self,enemy)
on ready {
if (not enemy.dead=true or not self.escaped=true){
msg ("It is now your turn.")
self_battle_turn_function (self,enemy)
}
}
}
on ready {
msg ("The round has ended.")
battle_sequence_function (self,enemy)
}
} else {
msg ("The battle is over.")
}
]]></function>


can you name~find~tell me what is the variable? (Hint: find "text~words~strings" with NO dots~periods, lol)

can you tell me what are some of the Attributes? (Hint: find the dots~periods, lol)

--------------------------------

here's an example of changing a Variable into an Attribute:

<game name="blah">
// blah coding
<you_go_first type="boolean">false</you_go_first>
// blah coding
</game>

<function name="battle_sequence_function" parameters="self,enemy"><![CDATA[
if (enemy.dead=false or self.escaped=false) {
game.you_go_first=false
if (GetInt (self,"speed") > GetInt (enemy,"speed") {
game.you_go_first=true
} else if (GetInt (self,"speed") = GetInt (enemy,"speed") and RandomChance (50)=true) {
game.you_go_first=true
}
if (game.you_go_first=true) {
msg ("You get to go first for this round")
self_battle_turn_function (self,enemy)
on ready {
if (not enemy.dead=true or not self.escaped=true){
enemy_battle_turn_function (self,enemy)
}
}
} else {
msg (enemy.alias + " gets to go first for this round.")
enemy_battle_turn_function (self,enemy)
on ready {
if (not enemy.dead=true or not self.escaped=true){
msg ("It is now your turn.")
self_battle_turn_function (self,enemy)
}
}
}
on ready {
msg ("The round has ended.")
battle_sequence_function (self,enemy)
}
} else {
msg ("The battle is over.")
}
]]></function>


and here's how you can switch from a Variable to an Attribute:

get input ("What is your name?") {
-> // this is done automatically~internally~hiddenly (you don't get to see this happen): result = "HK"
-> player.alias = result
-> msg ("Your name is " + player.alias) // this is displayed during game play: Your name is HK

HegemonKhan
my apologizes, but could you read my two previous posts above this post, as I've editted in a lot more stuff to both of them.

they should hopefully make everything clear to you!

HegemonKhan
Rainbow Dash wrote:OKay, I understand, I got most of that. It doesnt help me to understand how to create a variable the way I need it to be.

I need to have a set of statistics as follows:

Strength - "Set by the players choice of class"
Agility - "Set by class"
Stamina - "Set by class"
Intellect - "Set by class"
Wits - "Set by class"
Personality - "Set by class"
Base Hits - "Set by class"

All of these need to be tied to the player object.

THEN I need a set of variables that can be freely altered in a number of ways, such as:

Attack - This is the sum of the characters Strength and Agility stat. So, I need to be able to add the strength and agility together to get this stat...but it also needs to be on the player object. Do you understand now what I need?

Sorry if I sound like I am getting short. This program is making a pigs-ear out of something that should be really bloody simple.


here's one of my own codings, for you (you can use it to see how its done, and adjust it as you need for what you want):

(it's not exactly how you want it, but it shows how to do everything that you want done)

(click on the "Select All" button right below on this post to highlight it, then copy it: ctrl+C, create a new game, delete all of its code, paste in my code that you copied from here: ctrl+V, save your game file, and then start it up and play~test it out, hehe)

<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<start type="script">
msg ("What is your name?")
get input {
msg (" - " + result)
player.alias_x = result
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender_x = result
show menu ("What is your race?", split ("human;elf;dwarf" , ";"), false) {
player.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
player.class = result
msg (player.alias_x + " is a " + " " + player.gender_x + " " + player.race + " " + player.class + ".")
}
}
}
}
</start>
<turns type="int">0</turns>
<statusattributes type="simplestringdictionary">turns = </statusattributes>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_player" />
<inherit name="editor_object" />
<alias_x type="string"></alias_x>
<gender_x type="string"></gender_x>
<strength type="int">10</strength>
<endurance type="int">20</endurance>
<intelligence type="int">30</intelligence>
<spirituality type="int">40</spirituality>
<agility type="int">50</agility>
<statusattributes type="simplestringdictionary">alias_x = Name: !;gender_x = Gender: !;strength = ;endurance = ;intelligence = ;spirituality = ;agility = ;level = ;experience = ;physical_damage = PD: !;magical_damage = MD: !</statusattributes>
<level type="int">0</level>
<experience type="int">0</experience>
<physical_damage type="int">0</physical_damage>
<magical_damage type="int">0</magical_damage>
</object>
<object name="potion100">
<inherit name="editor_object" />
<alias>potexp100</alias>
<take />
<displayverbs type="simplestringlist">Look at; Take; Drink</displayverbs>
<inventoryverbs type="simplestringlist">Look at; Use; Drop; Drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 100 experience.")
player.experience = player.experience + 100
</drink>
</object>
<object name="potion300">
<inherit name="editor_object" />
<alias>potexp300</alias>
<take />
<displayverbs type="simplestringlist">Look at; Take; Drink</displayverbs>
<inventoryverbs type="simplestringlist">Look at; Use; Drop; Drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 300 experience.")
player.experience = player.experience + 300
</drink>
</object>
</object>
<turnscript name="global_events_turnscript">
<enabled />
<script>
leveling_function
player.physical_damage = player.strength + player.endurance
player.magical_damage = player.intelligence + player.spirituality
game.turns = game.turns + 1
</script>
</turnscript>
<function name="leveling_function"><![CDATA[
if (player.experience >= player.level * 100 + 100) {
player.experience = player.experience - (player.level * 100 + 100)
player.level = player.level + 1
switch (player.gender_x) {
case ("male") {
player.strength = player.strength + 1
}
case ("female") {
player.agility = player.agility + 1
}
}
switch (player.race) {
case ("dwarf") {
player.strength = player.strength + 2
player.endurance = player.endurance + 2
}
case ("elf") {
player.intelligence = player.intelligence + 2
player.spirituality = player.spirituality + 2
}
case ("human") {
player.strength = player.strength + 1
player.endurance = player.endurance + 1
player.agility = player.agility + 1
player.spirituality = player.spirituality + 1
}
}
switch (player.class) {
case ("warrior") {
player.strength = player.strength + 2
}
case ("cleric") {
player.intelligence = player.intelligence + 1
player.agility = player.agility + 1
}
case ("mage") {
player.intelligence = player.intelligence + 2
}
case ("thief") {
player.strength = player.strength + 1
player.agility = player.agility + 1
}
}
leveling_function
}
]]></function>
</asl>


I use the turnscript, but feel free to use the <attr> (altered~changed Attribute) stuff too, just look at how it's done in my turnscript. Also, you can move my code lines~blocks stuff around too, such as the stat bonuses in my leveling function to, for example, the "start" script in the Game Object.

--------------------------

while on the subject of Attributes, here's some of my Combat Code's Game Mechanics (what you can do with Attributes):

(don't try this in a game, as I'm sure it's dependant upon the rest of my combat coding)

<function name="self_battle_turn_function" parameters="self,enemy"><![CDATA[
msg (self.alias + " has " + self.current_health_points + " HP left.")
msg (enemy.alias + " has " + enemy.current_health_points + " HP left.")
wait {
show menu ("What is your battle choice?", split ("Attack;Defend;Cast;Item;Run", ";"), false) {
switch (result) {
case ("Attack") {
self_attack_failed = false
if (RandomChance (GetInt (enemy,"agility") - GetInt (self,"speed")) = true) {
msg (enemy.alias + "evaded your attack!")
self_attack_failed = true
self.defending = false
} else if (RandomChance (GetInt (enemy,"dexterity") - GetInt (self,"agility")) = true) {
msg (enemy.alias + "parried your attack!")
self_attack_failed = true
self.defending = false
} else if (RandomChance (GetInt (enemy,"agility") - GetInt (self,"dexterity")) = true) {
msg (enemy.alias + "blocked your attack!")
self_attack_failed = true
self.defending = false
} else if (RandomChance (GetInt (self,"dexterity") - GetInt (enemy,"speed")) = false) {
msg ("Your attack missed " + enemy.alias +"!")
self_attack_failed = true
self.defending = false
} else if (RandomChance (GetInt (enemy,"armor_class") - GetInt (self,"attack_rating")) = true) {
msg ("Your attack failed to penetrate " + enemy.alias +"!")
self_attack_failed = true
self.defending = false
} else if (self_attack_failed = false) {
if (self.defending = true and enemy.defending = true) {
enemy.current_health_points = enemy.current_health_points - (critical_hit_function (self) * 2 * GetInt (self,"physical_damage") / 2 + GetInt (self,"physical_damage") * (GetInt (self,"strength") - GetInt (enemy,"endurance")) / 100)
msg (enemy.alias + " has " + enemy.current_health_points + " HP left.")
self.defending = false
} else if (self.defending = true and enemy.defending = false) {
enemy.current_health_points = enemy.current_health_points - (critical_hit_function (self) * 2 * GetInt (self,"physical_damage") + GetInt (self,"physical_damage") * (GetInt (self,"strength") - GetInt (enemy,"endurance")) / 100)
msg (enemy.alias + " has " + enemy.current_health_points + " HP left.")
self.defending = false
} else if (self.defending = false and enemy.defending = true) {
enemy.current_health_points = enemy.current_health_points - (critical_hit_function (self) * GetInt (self,"physical_damage") / 2 + GetInt (self,"physical_damage") * (GetInt (self,"strength") - GetInt (enemy,"endurance")) / 100)
msg (enemy.alias + " has " + enemy.current_health_points + " HP left.")
} else if (self.defending = false and enemy.defending = false) {
enemy.current_health_points = enemy.current_health_points - (critical_hit_function (self) * GetInt (self,"physical_damage") + GetInt (self,"physical_damage") * (GetInt (self,"strength") - GetInt (enemy,"endurance")) / 100)
msg (enemy.alias + " has " + enemy.current_health_points + " HP left.")
}
}
}
case ("Defend") {
msg ("You defend yourself against " + enemy.alias)
self.defending = true
}
case ("Cast") {
self.defending = false
}
case ("Item") {
self.defending = false
}
case ("Run") {
self.defending = false
self.escaping = true
}
}
if (GetInt (enemy,"current_health_points") > 0) {
if ( RandomChance (GetInt (self,"speed") - GetInt (enemy,"speed"))= true) {
msg ("You get an extra battle turn!")
self_battle_turn (self,enemy)
} else {
msg ("Your battle turn is over.")
}
} else if (GetInt (enemy,"current_health_points") <= 0) {
msg (enemy.alias + " is dead.")
msg ("You have won the battle!")
self.defending = false
self.escaping = false
enemy.defending = false
enemy.dead = true
}
}
}
]]></function>


-----------------------

P.S.

if you're interested in trying out my combat coding, download my attachment file below:

HegemonKhan
I should probably clarify this too (forgot to do so):

CREATING (Adding) Attributes:

GUI~Editor:

"blah" (Object) -> Attribute (Tab) -> Attributes -> Add -> (Name, Type, Value)

Code:

<object name="blah">
-> // an example:
-> <strength type="int">50</strength>
</object>

notice how (in both Code and GUI~Editor) we're placing~attaching along with creating the Attribute, within an Object. Attributes must be a "child" of an Object. An Object is a "parent" of an Attribute.

notice how, in Code, in CREATING ATTRIBUTES, we use the "<object><attribute></attribute></object>" format.

------------------

"Scripting" (Using an Attribute):

scripting has many forms:

as~within Scripts (a Type of Attribute)
as~within Verbs
as~within Commands
as~within Turnscripts
as~within Functions
etc...

so, go to ~use these "places" (Object->Verb Tab, Functions, Commands, Object->Attribute Tab -> Attributes -> Add -> Script Type Attribute, Turnscripts, etc) in the GUI~Editor, and then the "Add a~new script" buttons, this is very different from adding attributes into objects.

now, in Code, it looks like this:

the scripting (this just USES the attributes, and you can NOT use an attribute that you never CREATED, lol) does NOT use the <blah> format~syntax, it uses the: "Object.Attribute=Value" format~syntax ..mostly..

(notice the DOT~PERIOD, again our Attributes MUST be attached~within~a child of~ to an Object, which is done via the: "name_of_object.then_our_name_of_attribute" syntax~format, in Code)

it makes sense, look at this example:

Player Objects:

HK.strength=100
RD.strength=50

NPC~Monster Object:

orc.endurance=25

you are~were wrongly doing this (for an pretend example):

playerdamage = playerstrength - playerendurance

okay... who's strength do you mean? (quest requires the DOT~PERIOD so it knows what is the Object and what is the Attribute)

is it?: damage = 100 - 25 = 75
or, is it?: damage = 50 - 25 = 25

and then, does the resulting damage suppose to be belonging to an object or is it just a variable?

An Attribute, MUST BE "OF SOMETHING", which is an Object

"strong" and "weak" doesn't exist by themselves: WHAT is "strong" and "weak" ???

game.damage = HK.strength - orc.endurance
game.damage = RD.strength - orc.endurance
game.damage = game.pov.strength - orc.endurance
HK.damage = HK.strength - orc.endurance
RD.damage = RD.strength - orc.endurance
global_attributes_data_object.damage = game.pov.strength - orc.endurance

<function name="character_creation_function">
-> msg ("What is your name")
-> get input {
->-> player.alias_x=result
->-> show menu ("What is your gender?", split ("male;female",";"), false) {
->->-> player.gender_x=result
->->-> show menu ("What is your race?", split ("human;dwarf;elf",";"), false) {
->->->-> player.race=result
->->-> }
->-> }
-> }
</function>

~or~

<game name="blah">
-> <start type="script">
->-> msg ("What is your name")
->-> get input {
->->-> player.alias_x=result
->->-> show menu ("What is your gender?", split ("male;female",";"), false) {
->->->-> player.gender_x=result
->->->-> show menu ("What is your race?", split ("human;dwarf;elf",";"), false) {
->->->->-> player.race=result
->->->-> }
->->-> }
->-> }
-> </start>
</game>

or

<command name="blah">
-> // etc coding lines
-> <script>
->-> msg ("What is your name")
->-> get input {
->->-> player.alias_x=result
->->-> show menu ("What is your gender?", split ("male;female",";"), false) {
->->->-> player.gender_x=result
->->->-> show menu ("What is your race?", split ("human;dwarf;elf",";"), false) {
->->->->-> player.race=result
->->->-> }
->->-> }
->-> }
-> </script>
</command>

OR

<verb name="blah">
-> // etc coding lines
-> <script>
->-> msg ("What is your name")
->-> get input {
->->-> player.alias_x=result
->->-> show menu ("What is your gender?", split ("male;female",";"), false) {
->->->-> player.gender_x=result
->->->-> show menu ("What is your race?", split ("human;dwarf;elf",";"), false) {
->->->->-> player.race=result
->->->-> }
->->-> }
->-> }
-> </script>
</verb>

or

<turnscript name="blah">
-> // etc coding lines
-> <script type="script">
->-> msg ("What is your name")
->-> get input {
->->-> player.alias_x=result
->->-> show menu ("What is your gender?", split ("male;female",";"), false) {
->->->-> player.gender_x=result
->->->-> show menu ("What is your race?", split ("human;dwarf;elf",";"), false) {
->->->->-> player.race=result
->->->-> }
->->-> }
->-> }
-> </script>
</turnscript>

or

<object name="blah">
-> <character_creation_script type="script">
->-> msg ("What is your name")
->-> get input {
->->-> player.alias_x=result
->->-> show menu ("What is your gender?", split ("male;female",";"), false) {
->->->-> player.gender_x=result
->->->-> show menu ("What is your race?", split ("human;dwarf;elf",";"), false) {
->->->->-> player.race=result
->->->-> }
->->-> }
->-> }
-> </character_creation_script>
</object>

-----------------

do you see the difference in the coding format~syntax and their locations, between "CREATING" Attributes and "SCRIPTING" Attributes?

--------------------------

so, are you asking what is a "data object" ???

it's just a custom Object that has no parent (like your default "room" Room Object), used as like a "Data File" for various Attributes. It's basically for better organizing of your code, so you don't clutter up your Game Object or your Player Objects, and~or to have all of the same type of codings, like your "flags"=booleans, together for you to easily look at. And it's hidden from the person playing the game.

here's an example, which should make more sense in explaning this better:

<object name="global_flags_ie_booleans_data_object">
<inherit name="editor_object" />
<parent>null</parent>
<talked_to_king type="boolean">false</talked_to_king>
<found_dragon_slayer_sword type="boolean">false</found_dragon_slayer_sword>
<killed_the_dragon_king type="boolean">false</killed_the_dragon_king>
</object>

<turnscript name="global_turnscript">
<enabled />
if (dragon_slayer_sword.parent = player) {
global_flags_ie_booleans_data_object.found_dragon_slayer_sword=true
}
if (global_flags_ie_booleans_data_object.talked_to_king=true and global_flags_ie_booleans_data_object.found_dragon_slayer_sword=true and global_flags_ie_booleans_data_object.killed_the_dragon_king=true) {
msg ("You just won the game!")
finish
}
</turnscript>

<object name="castle">
<inherit name="editor_room" />
<object name="king">
<inherit name="editor_object" />
<talk type="script">
msg ("You talked to the king, and he told you about the dragon king and the dragon slayer sword to kill it")
global_flags_ie_booleans_data_object.talked_to_king=true
</talk>
<displayverbs type="simplestringlist">Talk</displayverbs>
</object>
</object>

<object name="haunted_woods">
<inherit name="editor_room" />
<object name="dragon_slayer_sword">
<inherit name="editor_object" />
<take />
<displayverbs type="simplestringlist">Take</displayverbs>
</object>
</object>

<object name="sky_mountain">
<inherit name="editor_room" />
<object name="dragon_king">
<inherit name="editor_object" />
<fight type="script">
if (dragon_slayer_sword.parent = player) {
msg ("You stab the dragon king with your dragon slayer sword, killing him!)
global_flags_ie_booleans_data_object.killed_the_dragon_king=true
} else {
msg ("You stab with your wooden sword, it shatters against his adamantium scales, and the dragon king then incinerates you.")
msg ("GAME OVER, you LOST!")
finish
}
</fight>
<displayverbs type="simplestringlist">Fight</displayverbs>
</object>
</object>

jaynabonne
Rainbow Dash wrote:
OKay, I understand, I got most of that. It doesnt help me to understand how to create a variable the way I need it to be.

I need to have a set of statistics as follows:

Strength - "Set by the players choice of class"
Agility - "Set by class"
Stamina - "Set by class"
Intellect - "Set by class"
Wits - "Set by class"
Personality - "Set by class"
Base Hits - "Set by class"

All of these need to be tied to the player object.

THEN I need a set of variables that can be freely altered in a number of ways, such as:

Attack - This is the sum of the characters Strength and Agility stat. So, I need to be able to add the strength and agility together to get this stat...but it also needs to be on the player object. Do you understand now what I need?

Sorry if I sound like I am getting short. This program is making a pigs-ear out of something that should be really bloody simple.


(I hope I don't overlap too much with HK's responses above. It's too early in the morning for me to read through all those volumes.:) )

That is a clear definition. I think this has gone off in the weeds a bit because I was trying to interpret your initial posting (the attribute definition that had a sum of two other attributes) without really knowing the requirements. It just dawned on me in my last post before going to bed that you were actually going for player attributes.

The thing to keep in mind is that you can do all sorts of manipulations of attributes (much more so even than BASIC!) but you have to do it somewhere in script, not at attribute definition time. Attribute definitions, if you have them, must be static, not based on other attributes.

So first of all, yes, you do want to put the attributes on the player, at least conceptually. You could leave them in the game, but that probably makes less sense (design wise) than tying them to the player object.

Also, given that you want the base attributes set by class, that means they won't be static either, but set in the script that handles the class selection response. One way to do this to set up class objects to hold the base attributes - or you can do it in code (see the following post). For example, you can do this:

<object name="HumanClass">
<strength type="int">4</strength>
<agility type="int">3</agility>
<stamina type="int">5</stamina>
... etc...
</object>
<object name="ElfClass">
<strength type="int">3</strength>
<agility type="int">5</agility>
<stamina type="int">3</stamina>
... etc...
</object>


I would then have a function to set the selected class onto the player. You can handle class attributes in two ways:

1) Copy the class attributes to the player object when the class is selected. This is probably the simplest.
<function name="SetClass" parameters="class">
player.strength = class.strength
player.agility = class.agility
player.stamina = class.stamina
... etc ...
player.attack = player.strength + player.agility
</function>

2) Have the player point to the class object. This allows the class to be changed, but requires you to go an extra level of attribute to access the base stats (e.g. player.class.stamina vs player.stamina)
<function name="SetClass" parameters="class">
player.class = class
player.attack = player.class.strength + player.class.agility
</function>


Let's assume you're going to go with the first. (The second solves other problems but complicates things. I just list it as an alternative.)

Then you can just do something like this to set the class variables:

SetClass(HumanClass)


Even if you could set up attributes as sums of one another statically, you wouldn't want to, because you need it all to be dynamically determined based on the player's class selection. Once you move from attribute definitions to actual code, you'll (eventually) find it's a piece of cake manipulating the attribute values.

Edit: fixed SetClass example param.

jaynabonne
(Continuing as the online response editor gets reealllly slow with longer posts.)

An alternative to creating separate class objects is to just hard-code it all in script. Here is an alternative "SetClass" function that takes a class name instead of a class object:

<function name="SetClass" parameters="classname">
switch (classname) {
case ("human") {
player.strength = 4
player.agility = 3
player.stamina = 5
.. etc...
}
case ("elf") {
player.strength = 3
player.agility = 5
player.stamina = 3
.. etc...
}
}
// And then finally set the derived attributes...
player.attack = player.strength + player.agility
</function>


And then you'd just do, for example:

SetClass("human")

Rainbow Dash
jaynabonne wrote:(Continuing as the online response editor gets reealllly slow with longer posts.)

An alternative to creating separate class objects is to just hard-code it all in script. Here is an alternative "SetClass" function that takes a class name instead of a class object:

<function name="SetClass" parameters="classname">
switch (classname) {
case ("human") {
player.strength = 4
player.agility = 3
player.stamina = 5
.. etc...
}
case ("elf") {
player.strength = 3
player.agility = 5
player.stamina = 3
.. etc...
}
}
// And then finally set the derived attributes...
player.attack = player.strength + player.agility
</function>


And then you'd just do, for example:

SetClass("human")


Okay, now lets say that the player levels up and his stats change, I would have to write a script into the level up function that reruns the arithmetic to get the correct attributes again, correct?

HegemonKhan
I'd have to take some time to understand Jayna's coding fully, and I'm too lazy to do so, so I'll let him explain it and how to do what you want with using his coding

however, I can just respond in general to your questions, hehe.

-----------------

Jayna's coding doesn't have an "adder (addition)" Attribute Expression, to increase your "stat" attributes by some amount at level up. His coding just gives a static (starting) "stat" attribute amount (value) based upon what is your "class". So, if you don't have this already in your level up scripting (a function or whatever it is), you need to put these code lines in to it:

Addition:

Object.Attribute = Object.Attribute + Value
ex: player.strength = player.strength + 5

Substraction:

Object.Attribute = Object.Attribute - Value
ex: player.strength = player.strength - 1

Multiplication:

Object.Attribute = Object.Attribute * Value
ex: player.strength = player.strength * 2

Division:

Object.Attribute = Object.Attribute / Value
ex: player.strength = player.strength / 10

how the logic~mental~thought works:

player.strength (new strength amount) = player.strength (old strength amount) + 2

here's it applied even further, for Shopping (virtual currency objects using Attributes):

Buying something from a shop_owner:

player.cash = player.cash - shop_owner.cash // we lower the player's cash amount to thus get the bought object in exchange.

shop_owner.cash = shop_owner.cash + player.cash // we raise the shop owner's cash amount in exhange for selling away his shop's object.

Selling something to a shop_owner:

player.cash = player.cash + shop_owner.cash // we raise the player's cash amount in exhange for selling away our object to the shop owner.

shop_owner.cash = shop_owner.cash + player.cash // we lower the shop owner's cash amount as he gets our object in exchange.

--------------------------

the Attributes themselves are directly immediately changed and thus recognized by the quest engine as their new amounts.

I'd have to check if your "adder" Attribute expression (using my example as I'm too lazy to look what actually is yours, lol: player.damage = player.strength + player.endurance), or you could, see if it gets changed, or not.

Then, you'd need to also check if the STATUS ATTRIBUTES (the display of your attributes during game play on the right panes) also are changed accordingly too, or not.

--------------------------

If you look at Jayna'a coding, there's only:

Object.Attribute = Value // it's a "defining ("setting")" expression: player.strength = 5

there's no computational "Operators":

+ (addition)
- (subtraction)
* (multiplication)
/ (division)

(see above for the correct format+syntax for the computational "operation" that you want to do)

------------------------------

if you want your bonus "stat" attributes at level up to be based upon your class, then you just need a "conditional" expression along with the computational operator attribute expression:

<game name="blah">
-> <turns type="int">0</turns>
-> <statusattributes type="simplestringlist">turns =</statusattributes>
</game>

<turnscript name="whatever you want to call your turnscript"
-> // a turnscript is an "always running script", which is why it is so useful !!!
-> leveling_function
-> game.turns = game.turns + 1
<turnscript>

<function name="leveling_function">
-> // if (blah blah blah) {
->-> // blah blah blah coding
->-> switch (player.class) {
->->-> case ("warrior") {
->->->-> player.strength = player.strength + 2
->->-> }
->->-> case ("cleric") {
->->->-> player.spirituality = player.spirituality + 2
->->-> }
->->-> case ("mage") {
->->->-> player.intelligence = player.intelligence + 2
->->-> }
->->-> case ("thief") {
->->->-> player.agility = player.agility + 2
->->-> }
->-> }
-> }
</function>

Rainbow Dash

jaynabonne
Rainbow Dash wrote:Okay, now lets say that the player levels up and his stats change, I would have to write a script into the level up function that reruns the arithmetic to get the correct attributes again, correct?


So let me understand once more, since I'm trying to guess based on what you are saying. :)

Is attack always identically equal to strength plus agility, at all times? I wasn't sure if it just started out that way as a base (and could, for example, increase independently thereafter), or whether it's just always equal.

If attack will always be equal to strength plus agility, with no additional factors, then you can create "changed" scripts for strength and agility, so that when those values are changed for any reason, then attack is updated.

If (as HK points out as well) attack is just starting out as strength plus agility, then I'm not sure what you'd be updating, since they're just base values.

If the relationship is more complicated, such as there is a base factor plus an added on factor, and the base value can change during the course of play as well as the added on values which must then be added in, then you'd need to track both (the additional values plus the total, since you'd always recompute the base from strength and agility). I think that makes sense. lol

Ah yes, the problem once more of incomplete specs. :)

If you do want a changed script, then here is a sample (add these to your player):

<changedagility type="script">
player.attack = player.strength + player.agility
</changedagility>

<changedstrength type="script">
player.attack = player.strength + player.agility
</changedstrength>


Then if either agility or strength are changed, attack will be recomputed from their sum. Of course, that one line 's redundant code. I'd break it out into a function ('perhaps "UpdateAttack") and call it from both places, but that's not necessary and just a style of mine.

Changed scripts are a nice feature of Quest. You don't get such niceties, for example, in languages like C and C++, where you have to manually invoke things (though they do have their own, other niceties).

jaynabonne
Trying to head off a problem: if you do add the "changed" scripts, be sure to provide attribute definitions for both agility and strength on the player. Otherwise, you won't be able to set either attribute since the other will be undefined when the changed script runs.

Rainbow Dash
OKay, so lets see if I have learned anything and understood what I have been told. I have set a set of variables on the player object that will act as the base statistics. I have then created 2 functions to handle the math required to determine the current hit points and the maximum hit points for the player object using a script in each. Here is my code, let me know if I have done it wrong and where I have gone wrong if I have.

<!--Saved by Quest 5.4.4873.16527-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Ascendancy">
<gameid>a132737e-d5bc-418d-a234-36d3bebd6441</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<class>none</class>
<level type="int">1</level>
<exp type="int">0</exp>
<strength type="int">0</strength>
<agility type="int">0</agility>
<stamina type="int">0</stamina>
<intellect type="int">0</intellect>
<wits type="int">0</wits>
<personality type="int">0</personality>
<basehits type="int">5</basehits>
<startinghits type="int">0</startinghits>
<maxhits type="int">0</maxhits>
<currenthits type="int">0</currenthits>
</object>
</object>
<function name="hit_points">
player.maxhits = player.stamina + player.basehits
</function>
<function name="current_hits">
player.currenthits = player.maxhits
</function>
<function name="starting_hits">
player.startinghits = player.basehits + player.stamina
</function>
</asl>

jaynabonne
That should work. You'll just need to call the scripts at the right time (or stick them in "changed" scripts so they happen automatically).

Now, just a personal note on the code...

I *personally* would not have an attribute called "currenthits" and a script called "current_hits" unless you either have already worked it out as a personal style or just enjoy inviting Fate and Insanity into later parts of your project, when your eyes are blurring and you can't remember which one is the attribute and which one is not, especially when assigning a value to "current_hits" would change your script attribute into an int. A typical programming convention is to use verbs for functions that do things. So a name might be "updatecurrenthits" or "setcurrenthits" or "update_currenthits" or however you want to verbalize it and spell it. Obviously, it's up to you what you want to name things, so I'll stop here. It's just something that struck me.

Rainbow Dash
jaynabonne wrote:That should work. You'll just need to call the scripts at the right time (or stick them in "changed" scripts so they happen automatically).

Now, just a personal note on the code...

I *personally* would not have an attribute called "currenthits" and a script called "current_hits" unless you either have already worked it out as a personal style or just enjoy inviting Fate and Insanity into later parts of your project, when your eyes are blurring and you can't remember which one is the attribute and which one is not, especially when assigning a value to "current_hits" would change your script attribute into an int. A typical programming convention is to use verbs for functions that do things. So a name might be "updatecurrenthits" or "setcurrenthits" or "update_currenthits" or however you want to verbalize it and spell it. Obviously, it's up to you what you want to name things, so I'll stop here. It's just something that struck me.


Changed scripts? OKay, I cant find that in the Scripts list.

Rainbow Dash
Okay, so I have started working on the class part of character creation. Here is my scripting so far.

<!--Saved by Quest 5.4.4873.16527-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Ascendancy">
<gameid>a132737e-d5bc-418d-a234-36d3bebd6441</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<class>none</class>
<level type="int">1</level>
<exp type="int">0</exp>
<strength type="int">0</strength>
<agility type="int">0</agility>
<stamina type="int">0</stamina>
<intellect type="int">0</intellect>
<wits type="int">0</wits>
<personality type="int">0</personality>
<basehits type="int">5</basehits>
<startinghits type="int">0</startinghits>
<maxhits type="int">0</maxhits>
<currenthits type="int">0</currenthits>
</object>
</object>
<function name="updatehit_points">
player.maxhits = player.stamina + player.basehits
</function>
<function name="updatecurrent_health">
player.currenthits = player.maxhits
</function>
<function name="starting_hits">
player.startinghits = player.basehits + player.stamina
</function>
<function name="SetClass" parameters="class">
switch (class) {
case (Mercenary) {
player.strength = 3
player.agility = 2
player.stamina = 3
player.intellect = 1
player.wits = 2
player.personality = 1
starting_hits
}
}
</function>
</asl>

jaynabonne
Aack, sorry. I didn't explain what a "changed script" was.

Whenever an attribute is set on an object, Quest will look to see if there is a script attribute on that object with the name "changed" plus the attribute name. If it exists, then the script is run. So, for example, if you have an attribute called "hits", it will look for a script called "changedhits" to run whenever "hits" is changed by a new value being assigned to it.

That's why I picked the name for the scripts I showed you before - if you use those names (e.g. changedagility and changedstrength), then they will be run for you by Quest so you don't have to.

To create a script attribute on the player (are you using the desktop version? If not, then I'm afraid you can't, so ignore this in that case), click the player object and then the Attributes tab. You can then create an attribute with the right name and set it to type "script" and then make it do what you like.

For example, for the functions you have below, you can trigger them with these player attributes:

<changedstamina type="script">
// Stamina changes both maxhits and startinghits
updatehit_points
starting_hits
</changedstamina>
<changedbasehits type="script">
// basehits changes both maxhits and startinghits
updatehit_points
starting_hits
</changedbasehits>
<changedmaxhits type="script">
// maxhits changes currenthits
updatecurrent_health
</changedmaxhits>

HegemonKhan
Thank you Jayna for explaining the "changed scripting" scripts! Now I have a different means of doing so, instead of just using a turnscript all the time as I've been doing. Cool that Alex has this coded in for us, for easy use, hehe. Wish I had realized this built-in feature sooner, hehe.

Rainbow Dash
jaynabonne wrote:Aack, sorry. I didn't explain what a "changed script" was.

Whenever an attribute is set on an object, Quest will look to see if there is a script attribute on that object with the name "changed" plus the attribute name. If it exists, then the script is run. So, for example, if you have an attribute called "hits", it will look for a script called "changedhits" to run whenever "hits" is changed by a new value being assigned to it.

That's why I picked the name for the scripts I showed you before - if you use those names (e.g. changedagility and changedstrength), then they will be run for you by Quest so you don't have to.

To create a script attribute on the player (are you using the desktop version? If not, then I'm afraid you can't, so ignore this in that case), click the player object and then the Attributes tab. You can then create an attribute with the right name and set it to type "script" and then make it do what you like.

For example, for the functions you have below, you can trigger them with these player attributes:

<changedstamina type="script">
// Stamina changes both maxhits and startinghits
updatehit_points
starting_hits
</changedstamina>
<changedbasehits type="script">
// basehits changes both maxhits and startinghits
updatehit_points
starting_hits
</changedbasehits>
<changedmaxhits type="script">
// maxhits changes currenthits
updatecurrent_health
</changedmaxhits>


Okay, so do I put the changed scripts into the game object so they are always running, or do I have to call them every time I want to use them? Ive got this so far.

<!--Saved by Quest 5.4.4873.16527-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Ascendancy">
<gameid>a132737e-d5bc-418d-a234-36d3bebd6441</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<changedbasehits type="script">
update_hitpoints
</changedbasehits>
<changedstamina type="script">
update_hitpoints
</changedstamina>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<class>none</class>
<level type="int">1</level>
<exp type="int">0</exp>
<strength type="int">0</strength>
<agility type="int">0</agility>
<stamina type="int">0</stamina>
<intellect type="int">0</intellect>
<wits type="int">0</wits>
<personality type="int">0</personality>
<basehits type="int">5</basehits>
<startinghits type="int">0</startinghits>
<maxhits type="int">0</maxhits>
<currenthits type="int">0</currenthits>
<attack type="int">0</attack>
<defense type="int">0</defense>
</object>
</object>
<function name="update_playerattack">
player.attack = player.agility
</function>
<function name="update_playerdefense">
player.defense = player.agility
</function>
<function name="update_hitpoints">
player.maxhits = player.stamina + player.basehits
</function>
<function name="update_currenthealth">
player.currenthits = player.maxhits
</function>
<function name="starting_hits">
player.startinghits = player.basehits + player.stamina
</function>
<function name="SetClass" parameters="class">
switch (class) {
case (Mercenary) {
player.strength = 3
player.agility = 2
player.stamina = 3
player.intellect = 1
player.wits = 2
player.personality = 1
starting_hits
updatecurrent_health
}
case (Rogue) {
player.strength = 2
player.stamina = 2
player.agility = 2
player.intellect = 1
player.wits = 3
player.personality = 2
starting_hits
update_currenthealth
}
case (Gadgeteer) {
player.strength = 1
player.stamina = 2
player.agility = 1
player.intellect = 3
player.wits = 2
player.personality = 2
starting_hits
update_currenthealth
}
}
</function>
</asl>

HegemonKhan
I think they go in the same place as their corresponding attributes, so if you got the attributes given to the "player" Player Object, then the "changedattributes" scripts go there too, they're like (or are, lol) a verb in this regard. As I think you set the changed scripts within the GUI~Editor, in the same place, the Object's Attribute (Tab) where you set its Attributes. At least I recall this to be the case, but I might be wrong.

[HK Edit: I just checked, they're indeed placed in the same Object as their Attributes, but maybe they can be placed anywhere too... I'm not sure of this, actually... I'll check it right now, lol]

[HK Edit 2: nope, you seem to have to put the changed script in the same location~Object as that of the Attribute that the "changedattribute" script is changing, lol]

Rainbow Dash
Look up, I changed what I have n the code box.

HegemonKhan
the "changedscripts", must go in the same Object as its Attributes.

<object name="player">

-> <inherit name="editor_player" />
-> <inherit name="editor_object" />

-> <turns type="int">0</turns>
-> <strength type="int">0</strength>
-> <endurance type="int">0</endurance>

-> <changedstrength type="script">
->-> player.sum_of_strength_and_endurance = player.strength + player.endurance
-> </changedstrength>

-> <changedendurance type="script">
->-> player.sum_of_strength_and_endurance = player.strength + player.endurance
-> </changedendurance>

-> <statusattributes type="simplestringlist">turns =;strength =;endurance =;sum_of_strength_and_endurance = Sum: !</statusattributes>

</object>

<turnscript name="testing_turnscript">
-> <enabled />

-> <script>

->-> player.strength = player.strength + 10
->-> player.endurance = player.endurance + 5

->-> player.turns = player.turns + 1

-> </script>

</turnscript>

HegemonKhan
Your code looks good, everything is correct as far as I can see, Jayna can look at his part of the code ("SetClass"), if you got it set up right or not.

Rainbow Dash
HegemonKhan wrote:Your code looks good, everything is correct as far as I can see, Jayna can look at his part of the code, if you got it set up right.


Nah, my changed scripts 'were' in the game object, so I moved them into the bottom of the player object and booted up the game. No errors thus far.

HegemonKhan
here, this game file has both methods ("changedattribute" script and via Turnscripts):

<!--Saved by Quest 5.4.4840.17608-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<turns type="int">0</turns>
<statusattributes type="stringdictionary">
<item>
<key>turns</key>
<value></value>
</item>
</statusattributes>
<start type="script">
msg ("What is your name?")
get input {
msg (" - " + result)
player.alias_x = result
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender_x = result
show menu ("What is your race?", split ("human;elf;dwarf" , ";"), false) {
player.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
player.class = result
msg (player.alias_x + " is a " + " " + player.gender_x + " " + player.race + " " + player.class + ".")
}
}
}
}
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_player" />
<inherit name="editor_object" />
<attr name="alias_x" type="string"></attr>
<attr name="gender_x" type="string"></attr>
<strength type="int">10</strength>
<endurance type="int">20</endurance>
<intelligence type="int">30</intelligence>
<spirituality type="int">40</spirituality>
<agility type="int">50</agility>
<statusattributes type="stringdictionary">
<item>
<key>alias_x</key>
<value>Name: !</value>
</item>
<item>
<key>gender_x</key>
<value>Gender: !</value>
</item>
<item>
<key>strength</key>
<value></value>
</item>
<item>
<key>endurance</key>
<value></value>
</item>
<item>
<key>intelligence</key>
<value></value>
</item>
<item>
<key>spirituality</key>
<value></value>
</item>
<item>
<key>agility</key>
<value></value>
</item>
<item>
<key>level</key>
<value></value>
</item>
<item>
<key>experience</key>
<value></value>
</item>
<item>
<key>physical_damage</key>
<value>PD: !</value>
</item>
<item>
<key>magical_damage</key>
<value>MD: !</value>
</item>
<item>
<key>total</key>
<value>total: !</value>
</item>
</statusattributes>
<level type="int">0</level>
<experience type="int">0</experience>
<attr name="physical_damage" type="int">0</attr>
<attr name="magical_damage" type="int">0</attr>
<total type="int">0</total>
<changedstrength type="script">
player.total = player.strength + player.endurance
</changedstrength>
<changedendurance type="script">
player.total = player.strength + player.endurance
</changedendurance>
</object>
<object name="potion100">
<inherit name="editor_object" />
<alias>potexp100</alias>
<take />
<displayverbs type="stringlist">
<value>Look at</value>
<value>Take</value>
<value>Drink</value>
</displayverbs>
<inventoryverbs type="stringlist">
<value>Look at</value>
<value>Use</value>
<value>Drop</value>
<value>Drink</value>
</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 100 experience.")
player.experience = player.experience + 100
</drink>
</object>
<object name="potion300">
<inherit name="editor_object" />
<alias>potexp300</alias>
<take />
<displayverbs type="stringlist">
<value>Look at</value>
<value>Take</value>
<value>Drink</value>
</displayverbs>
<inventoryverbs type="stringlist">
<value>Look at</value>
<value>Use</value>
<value>Drop</value>
<value>Drink</value>
</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 300 experience.")
player.experience = player.experience + 300
</drink>
</object>
<object name="bonus_strength">
<inherit name="editor_object" />
<alias>potstr</alias>
<take />
<displayverbs type="stringlist">
<value>Look at</value>
<value>Take</value>
<value>Drink</value>
</displayverbs>
<inventoryverbs type="stringlist">
<value>Look at</value>
<value>Use</value>
<value>Drop</value>
<value>Drink</value>
</inventoryverbs>
<drink type="script">
msg ("You drink the str potion, receiving +10 strength.")
player.strength = player.strength + 10
</drink>
</object>
<object name="bonus_endurance">
<inherit name="editor_object" />
<alias>potend</alias>
<take />
<displayverbs type="stringlist">
<value>Look at</value>
<value>Take</value>
<value>Drink</value>
</displayverbs>
<inventoryverbs type="stringlist">
<value>Look at</value>
<value>Use</value>
<value>Drop</value>
<value>Drink</value>
</inventoryverbs>
<drink type="script">
msg ("You drink the end potion, receiving +5 endurance.")
player.endurance = player.endurance + 5
</drink>
</object>
</object>
<turnscript name="global_events_turnscript">
<enabled />
<script>
leveling_function
player.physical_damage = player.strength + player.endurance
player.magical_damage = player.intelligence + player.spirituality
game.turns = game.turns + 1
</script>
</turnscript>
<function name="leveling_function"><![CDATA[
if (player.experience >= player.level * 100 + 100) {
player.experience = player.experience - (player.level * 100 + 100)
player.level = player.level + 1
switch (player.gender_x) {
case ("male") {
player.strength = player.strength + 1
}
case ("female") {
player.agility = player.agility + 1
}
}
switch (player.race) {
case ("dwarf") {
player.strength = player.strength + 2
player.endurance = player.endurance + 2
}
case ("elf") {
player.intelligence = player.intelligence + 2
player.spirituality = player.spirituality + 2
}
case ("human") {
player.strength = player.strength + 1
player.endurance = player.endurance + 1
player.agility = player.agility + 1
player.spirituality = player.spirituality + 1
}
}
switch (player.class) {
case ("warrior") {
player.strength = player.strength + 2
}
case ("cleric") {
player.intelligence = player.intelligence + 1
player.agility = player.agility + 1
}
case ("mage") {
player.intelligence = player.intelligence + 2
}
case ("thief") {
player.strength = player.strength + 1
player.agility = player.agility + 1
}
}
leveling_function
}
]]></function>
</asl>


and~or as an attachment:

jaynabonne
My only comment is that you have this:

case (Mercenary)


That won't work. I think you mean:

case ("Mercenary")


so you can pass a string. I thought at first you had an object called Mercenary or something, but I don't see that. So I think you do mean to have it be a string.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums