Increasing attributes
metalmario991
11 Sept 2013, 22:27I'm trying to write a game where one of the attributes are cash and you need to increase to progress the game but i can't find a way to increase it without getting errors help! 

HegemonKhan
12 Sept 2013, 00:10the GUI~Editor has a script (add a~new script) to increase counter (or something like this), but I think it's stuck at "By 1", or maybe it's not, and you can select what value, not sure as I don't use the GUI~Editor much, and am too lazy to check it right now.
--------------------------
if you can work with code, then it's easy:
Addition:
Object.Attribute = Object.Attribute + Value
example 1: HK.strength = HK.strength + 5
example 2: HK.strength = HK.strength + 100
Subtraction:
Object.Attribute = Object.Attribute - Value
example 1: HK.strength = HK.strength - 30
example 2: HK.strength = HK.strength - 2
Multiplication:
Object.Attribute = Object.Attribute * Value
example 1: HK.strength = HK.strength * 7
example 2: HK.strength = HK.strength * 100
Division:
Object.Attribute = Object.Attribute / Value
example 1: HK.strength = HK.strength / 9
example 2: HK.strength = HK.strength / 4
--------------------------------
conceptually:
Object.Attribute (new amount) <--- = <--- Object.Attribute (old amount) + Value
example:
old amount: HK.strength = 100
Value: 50
Operator: + (addition)
new amount: HK.strength = HK.strength + Value
new amount: HK.strength = 100 + 50
new amount: HK.strength = 150
--------------------------
Virtual Bartering~Exchanging:
(manipulating~changing Objects' Attributes, like a "cash~currency" Attribute, instead of using~moving actual Objects around, like "gold_coin" Objects, is A VERY GOOD THING!)
Buying:
(for example: "HK" buying a wooden_sword costing 100 from a "shop_owner")
HK.cash = HK.cash - 100
shop_owner.cash = shop_owner.cash + 100
from: wooden_sword.parent = shop_owner // do NOT code in this line! I show it here only for concept!
to: wooden_sword.parent = HK // DO code in this line!
Selling:
(for example: "HK" selling a wooden_sword for 100 to a "shop_owner")
HK.cash = HK.cash + 100
shop_owner.cash = shop_owner.cash - 100
from: wooden_sword.parent = HK // do NOT code in this line! I show it here only for concept!
to: wooden_sword.parent = shop_owner // DO code in this line!
--------------------------
if you can work with code, then it's easy:
Addition:
Object.Attribute = Object.Attribute + Value
example 1: HK.strength = HK.strength + 5
example 2: HK.strength = HK.strength + 100
Subtraction:
Object.Attribute = Object.Attribute - Value
example 1: HK.strength = HK.strength - 30
example 2: HK.strength = HK.strength - 2
Multiplication:
Object.Attribute = Object.Attribute * Value
example 1: HK.strength = HK.strength * 7
example 2: HK.strength = HK.strength * 100
Division:
Object.Attribute = Object.Attribute / Value
example 1: HK.strength = HK.strength / 9
example 2: HK.strength = HK.strength / 4
--------------------------------
conceptually:
Object.Attribute (new amount) <--- = <--- Object.Attribute (old amount) + Value
example:
old amount: HK.strength = 100
Value: 50
Operator: + (addition)
new amount: HK.strength = HK.strength + Value
new amount: HK.strength = 100 + 50
new amount: HK.strength = 150
--------------------------
Virtual Bartering~Exchanging:
(manipulating~changing Objects' Attributes, like a "cash~currency" Attribute, instead of using~moving actual Objects around, like "gold_coin" Objects, is A VERY GOOD THING!)
Buying:
(for example: "HK" buying a wooden_sword costing 100 from a "shop_owner")
HK.cash = HK.cash - 100
shop_owner.cash = shop_owner.cash + 100
from: wooden_sword.parent = shop_owner // do NOT code in this line! I show it here only for concept!
to: wooden_sword.parent = HK // DO code in this line!
Selling:
(for example: "HK" selling a wooden_sword for 100 to a "shop_owner")
HK.cash = HK.cash + 100
shop_owner.cash = shop_owner.cash - 100
from: wooden_sword.parent = HK // do NOT code in this line! I show it here only for concept!
to: wooden_sword.parent = shop_owner // DO code in this line!
metalmario991
12 Sept 2013, 01:47HegemonKhan wrote:the GUI~Editor has a script (add a~new script) to increase counter (or something like this), but I think it's stuck at "By 1", or maybe it's not, and you can select what value, not sure as I don't use the GUI~Editor much, and am too lazy to check it right now.
--------------------------
if you can work with code, then it's easy:
Addition:
Object.Attribute = Object.Attribute + Value
example 1: HK.strength = HK.strength + 5
example 2: HK.strength = HK.strength + 100
Subtraction:
Object.Attribute = Object.Attribute - Value
example 1: HK.strength = HK.strength - 30
example 2: HK.strength = HK.strength - 2
Multiplication:
Object.Attribute = Object.Attribute * Value
example 1: HK.strength = HK.strength * 7
example 2: HK.strength = HK.strength * 100
Division:
Object.Attribute = Object.Attribute / Value
example 1: HK.strength = HK.strength / 9
example 2: HK.strength = HK.strength / 4
--------------------------------
conceptually:
Object.Attribute (new amount) <--- = <--- Object.Attribute (old amount) + Value
example:
old amount: HK.strength = 100
Value: 50
Operator: + (addition)
new amount: HK.strength = HK.strength + Value
new amount: HK.strength = 100 + 50
new amount: HK.strength = 150
--------------------------
Virtual Bartering~Exchanging:
(manipulating~changing Objects' Attributes, like a "cash~currency" Attribute, instead of using~moving actual Objects around, like "gold_coin" Objects, is A VERY GOOD THING!)
Buying:
(for example: "HK" buying a wooden_sword costing 100 from a "shop_owner")
HK.cash = HK.cash - 100
shop_owner.cash = shop_owner.cash + 100
from: wooden_sword.parent = shop_owner // do NOT code in this line! I show it here only for concept!
to: wooden_sword.parent = HK // DO code in this line!
Selling:
(for example: "HK" selling a wooden_sword for 100 to a "shop_owner")
HK.cash = HK.cash + 100
shop_owner.cash = shop_owner.cash - 100
from: wooden_sword.parent = HK // do NOT code in this line! I show it here only for concept!
to: wooden_sword.parent = shop_owner // DO code in this line!
RE: I did player.cash= player.cash + 85 but i got this error:
Error running script: Error compiling expression 'player.cash + 89': ArithmeticElement: Operation 'Add' is not defined for types 'Object' and 'Int32'
HegemonKhan
12 Sept 2013, 02:01.
.
My apologies for not mentioning this other thing that you MUST do as well. This is my fault. See below for what I forgot to tell you in my previous post:
If you forget to actually create (add) the attribute itself to the object, the error says "object" <not equal> "int32~integer or whatever". I don't know why, but if quest can't find something, it's error has "object" in it, even if no object is involved with it. Annoying for trouble shooting, lol.
so, do this:
in the GUI~Editor:
"player" (Object) -> Attributes (Tab) -> Attributes -> Add ->
Name: cash // or whatever you want to call this attribute (though you'd have to change the "cash" attribute in the script (add a~new script) to match what you call it, they have to be typed~spelled the exact same, for quest to recognize them as being the same attribute.
Type: int (integer)
Value: (whatever amount you want)
or, in-code:
----------
by the way, to do the "addition, subtr.., etc", in the GUI~Editor:
Add a~new script -> Variables -> Increase~Decrease object counter -> [counter name ~ for just adding~subtracting by 1] or [expression ~ for choosing~typing~in your own value, and~or for using multiplying or division]
-----------
scripts (add a~new script) are ACTIONS (or USES) with an Object's Attribute (Object.Attribute=Value_or_Expression).
well, to do that action (or use), you need the attribute itself, you need to create (add) the attribute to (within) the object (like the "player" default Player Object) that you want to have that attribute.
so, try to remember that you got to ADD the attribute to the object, along with doing the script (add a~new script) stuff. It is easy to forget, I have forgotten a bit myself. It might be better to try to add the attributes to the objects first, before you do the "add a~new script" stuff, as this way avoids the issue of forgetting.
----------
here's a game code for you to look at:
and here is the game file itself for you too:
.
My apologies for not mentioning this other thing that you MUST do as well. This is my fault. See below for what I forgot to tell you in my previous post:
If you forget to actually create (add) the attribute itself to the object, the error says "object" <not equal> "int32~integer or whatever". I don't know why, but if quest can't find something, it's error has "object" in it, even if no object is involved with it. Annoying for trouble shooting, lol.
so, do this:
in the GUI~Editor:
"player" (Object) -> Attributes (Tab) -> Attributes -> Add ->
Name: cash // or whatever you want to call this attribute (though you'd have to change the "cash" attribute in the script (add a~new script) to match what you call it, they have to be typed~spelled the exact same, for quest to recognize them as being the same attribute.
Type: int (integer)
Value: (whatever amount you want)
or, in-code:
<object name="player">
<inherit name="editor_player" />
<inherit name="editor_object" />
// blah coding
<cash type="int">500</cash> // you can change "cash" and "500" to whatever you want (again, the name has to match up)
// blah coding
</object>
----------
by the way, to do the "addition, subtr.., etc", in the GUI~Editor:
Add a~new script -> Variables -> Increase~Decrease object counter -> [counter name ~ for just adding~subtracting by 1] or [expression ~ for choosing~typing~in your own value, and~or for using multiplying or division]
-----------
scripts (add a~new script) are ACTIONS (or USES) with an Object's Attribute (Object.Attribute=Value_or_Expression).
well, to do that action (or use), you need the attribute itself, you need to create (add) the attribute to (within) the object (like the "player" default Player Object) that you want to have that attribute.
so, try to remember that you got to ADD the attribute to the object, along with doing the script (add a~new script) stuff. It is easy to forget, I have forgotten a bit myself. It might be better to try to add the attributes to the objects first, before you do the "add a~new script" stuff, as this way avoids the issue of forgetting.
----------
here's a game code for you to look at:
<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">0</strength>
<intelligence type="int">0</intelligence>
<agility type="int">0</agility>
<statusattributes type="simplestringdictionary">alias_x = Name: !;gender_x = Gender: !;strength = ;intelligence = ;agility = ;level = ;experience = ;cash = </statusattributes>
<level type="int">0</level>
<experience type="int">0</experience>
<cash type="int">0</cash>
</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
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
}
case ("elf") {
player.agility = player.intelligence + 2
}
case ("human") {
player.strength = player.strength + 1
player.agility = player.agility + 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 here is the game file itself for you too:
metalmario991
14 Sept 2013, 14:25Excuse me but the GUI-editor you talked about says you can put a type to the attribute but i can't find it. (Sorry but i'm terribly new at this)
HegemonKhan
14 Sept 2013, 16:07no problem, feel free to ask about anything! I was a total noob a year ago myself, hehe. My apologies for not explaining how to choose (nor what is, nor what I mean by) the "TYPE" of Attribute, my bad!
an example:
"player" (Object) -> Attributes (Tab) -> Attributes -> Add ->
first, to create (add) an attribute, it asks for the attribute's NAME attribute, which you type into the "popup" box, such as:
strength
Name of Attribute: strength
Second, after you do this (type in the name in the popup box), now, at the bottom of the (right side) window~pane, there's a small rectangle "drop down" box (this is how you select the: TYPE), it's default shown~seleted Type is "string", but we can: click on it, to get (select) from the other choices available:
string
int (integer)
double
script
string list
object list
string dictionary
object dictionary
script dictionary
for "strength", we'll choose:
int
Type of Attribute: int
Third, after you've selected your TYPE, below this small "drop down" box, is our VALUE box, which will change based upon what TYPE we had chosen. (Since the default TYPE is set~on as a "string", the VALUE box will contain a box for typing in what you want, but this will change if you select a different TYPE in small the "drop down" TYPE box above it)
since, we chose "int" for our TYPE, this VALUE box, will change to allow you to choose a number amount, which we'll choose, let's say:
100
Value of Attribute: 100
Object's Name Attribute: player
Name Attribute: strength
Type Attribute: int
Value Attribute: 100
and we could make (add) more attributes for our "player" Player Object (Object):
Name: race
Type: string (or stringlist)
Value: human
Name: dead
Type: boolean
Value: false
Name: physical_damage
Type: double
Value: 50.7165
Name: player_death_script
Type: script
Value: (see directly below)
if (player.hit_points <= 0) {
-> msg ("GAME OVER")
-> finish
}
-------------------------
Lastly, if you want to edit~change your Object's Attributes:
for example:
"player" (Object) -> Attributes (Tab) -> Attributes ->
at the bottom (of the right window~pane) is the attributes box, scroll down until you find the attribute that you want to edit~change, and click on it, so that it'll now be highlighted.
once you got it highlighted (by just clicking on it), you should now see that attribute's editing~changing buttons below it:
most of the same buttons that you had when you were creating (adding) the attribute, so for example:
scroll down to the player's "strength" attribute, click on it, then below, you should have aproximately (too lazy to open up the GUI~Editor to be precise here, but hopefully this is good enough, lol):
TYPE and VALUE boxes, which you can change (I think that you'd ahve to delete the attribute and re-create it, to give it a different name), such as maybe doing this, for a simple example:
(Name: strength)
Type: double
Value: 100.75
an example:
"player" (Object) -> Attributes (Tab) -> Attributes -> Add ->
first, to create (add) an attribute, it asks for the attribute's NAME attribute, which you type into the "popup" box, such as:
strength
Name of Attribute: strength
Second, after you do this (type in the name in the popup box), now, at the bottom of the (right side) window~pane, there's a small rectangle "drop down" box (this is how you select the: TYPE), it's default shown~seleted Type is "string", but we can: click on it, to get (select) from the other choices available:
string
int (integer)
double
script
string list
object list
string dictionary
object dictionary
script dictionary
for "strength", we'll choose:
int
Type of Attribute: int
Third, after you've selected your TYPE, below this small "drop down" box, is our VALUE box, which will change based upon what TYPE we had chosen. (Since the default TYPE is set~on as a "string", the VALUE box will contain a box for typing in what you want, but this will change if you select a different TYPE in small the "drop down" TYPE box above it)
since, we chose "int" for our TYPE, this VALUE box, will change to allow you to choose a number amount, which we'll choose, let's say:
100
Value of Attribute: 100
Object's Name Attribute: player
Name Attribute: strength
Type Attribute: int
Value Attribute: 100
and we could make (add) more attributes for our "player" Player Object (Object):
Name: race
Type: string (or stringlist)
Value: human
Name: dead
Type: boolean
Value: false
Name: physical_damage
Type: double
Value: 50.7165
Name: player_death_script
Type: script
Value: (see directly below)
if (player.hit_points <= 0) {
-> msg ("GAME OVER")
-> finish
}
-------------------------
Lastly, if you want to edit~change your Object's Attributes:
for example:
"player" (Object) -> Attributes (Tab) -> Attributes ->
at the bottom (of the right window~pane) is the attributes box, scroll down until you find the attribute that you want to edit~change, and click on it, so that it'll now be highlighted.
once you got it highlighted (by just clicking on it), you should now see that attribute's editing~changing buttons below it:
most of the same buttons that you had when you were creating (adding) the attribute, so for example:
scroll down to the player's "strength" attribute, click on it, then below, you should have aproximately (too lazy to open up the GUI~Editor to be precise here, but hopefully this is good enough, lol):
TYPE and VALUE boxes, which you can change (I think that you'd ahve to delete the attribute and re-create it, to give it a different name), such as maybe doing this, for a simple example:
(Name: strength)
Type: double
Value: 100.75
metalmario991
14 Sept 2013, 19:15I put in the attribute name but that rectangular box thingy isn't there. Am i in the wrong place as is there somewhere else you deal with the attributes?
sonic102
14 Sept 2013, 20:29Here's a small troubleshoot: Is your cash attribute an "object"? If so, change it into an "integer" then try it. 

HegemonKhan
14 Sept 2013, 21:541. Are you using the online~web version? Or, the offline~desktop version?
http://quest5.net/wiki/Custom_attributes
2. Are you in simple game mode?
http://quest5.net/wiki/Creating_a_simple_game
3. see how it is done here:
http://quest5.net/wiki/Custom_attributes (wiki web page)
http://quest5.net/wiki/File:Weightflour.png (wiki picture)
left side window~pane~panel, the "tree of stuff":
Object (highlighted ~ hard to see highlight color though): "flour"
right side window~pane~panel, the details of the: "flour" (Object)
Tab: Attributes
Inherited Types Box:
Attributes Box:
(they already added the attribute: "Name: weight, Type: int ~ integer, and Value: 0", already)
Attribute (highlighted ~ hard to see highlight color though): "weight"
see, the little rectangle box below? (it's showing~has selected~ the Type: integer)
this is the TYPE of Attribute "drop down" box, click on it to see (and select) the Attribute Type choices (choice that you want).
and below is the VALUE box, which since the Type is an "int", it allows you to select a number amount. (it's showing~has selected, for it's amount: 500)
http://quest5.net/wiki/Custom_attributes
Custom attributes:
Note: The attributes editor is currently only available in the Windows desktop version of Quest.
2. Are you in simple game mode?
http://quest5.net/wiki/Creating_a_simple_game
Simple ModeWhen starting out with Quest, you may find it easier to run in "Simple Mode". This hides much of Quest's more advanced functionality, but still gives you access to the core features.
You can toggle Simple Mode on or off at any time:
on the Windows desktop version, you can toggle Simple Mode from the Tools menu.
on the web version, click the Settings button at the top right of the screen.
3. see how it is done here:
http://quest5.net/wiki/Custom_attributes (wiki web page)
http://quest5.net/wiki/File:Weightflour.png (wiki picture)
left side window~pane~panel, the "tree of stuff":
Object (highlighted ~ hard to see highlight color though): "flour"
right side window~pane~panel, the details of the: "flour" (Object)
Tab: Attributes
Inherited Types Box:
Attributes Box:
(they already added the attribute: "Name: weight, Type: int ~ integer, and Value: 0", already)
Attribute (highlighted ~ hard to see highlight color though): "weight"
see, the little rectangle box below? (it's showing~has selected~ the Type: integer)
this is the TYPE of Attribute "drop down" box, click on it to see (and select) the Attribute Type choices (choice that you want).
and below is the VALUE box, which since the Type is an "int", it allows you to select a number amount. (it's showing~has selected, for it's amount: 500)
metalmario991
15 Sept 2013, 00:41About your question i'm not sure but since i don't have normal computer access i do my editing on my Wii U internet and do the rest at the Dell computers at the library.
HegemonKhan
15 Sept 2013, 01:22so, you probably haven't downloaded a "quest.exe" file, which you installed, and open~startup to do quest work from your~a computer (or computer device~appliance like your wii or upon your library's computers ~ like they'd let you download a game making software, an ".exe" file, onto their computers, lol), correct?
if this is so, then it seems you don't have the normal capabilities with using attributes, maybe there's a way for you to have these capabilities, but you'll have to ask someone here, who's familiar with working with~on the web~online version.
----------
you're in luck (with time) as Alex wants to go in the online direction, as that is the future of computing (the "cloud" ~ internet):
viewtopic.php?f=15&t=3816
so, just be patient... lol
if this is so, then it seems you don't have the normal capabilities with using attributes, maybe there's a way for you to have these capabilities, but you'll have to ask someone here, who's familiar with working with~on the web~online version.
----------
you're in luck (with time) as Alex wants to go in the online direction, as that is the future of computing (the "cloud" ~ internet):
viewtopic.php?f=15&t=3816
so, just be patient... lol

jaynabonne
15 Sept 2013, 09:46To initialize an attribute in the online version, you can do this:
- Click on the "game" object.
- Click on "Script"
- Click the "+ Add new script" button
- In what pops up, click "Variables" on the left.
- Then, on the right, click "Set a variable or attribute"
- Hit OK
- In the box beside "set variable", type:
player.cash
- In the box to the right of "expression", type:
0
That should help a bit. You can do the same for any other variables you wish to add - just assign them yourself in the game start script.
- Click on the "game" object.
- Click on "Script"
- Click the "+ Add new script" button
- In what pops up, click "Variables" on the left.
- Then, on the right, click "Set a variable or attribute"
- Hit OK
- In the box beside "set variable", type:
player.cash
- In the box to the right of "expression", type:
0
That should help a bit. You can do the same for any other variables you wish to add - just assign them yourself in the game start script.
metalmario991
20 Sept 2013, 19:57OK i've totally given up on attributes so i'm trying counters and i just one to know if their is a way to increase them by a set number.