Object Counters

metalmario991
21 Sept 2013, 22:49
I just need to know if it possible to increase/decrease object counters by a specific number.

HegemonKhan
22 Sept 2013, 03:58
there doesn't seem to be that capability from the "IncreaseObjectCounter" function (Filter -> Show Library Elements -> Functions -> IncreaseObjectCounter), as seen:

<function name="IncreaseObjectCounter" parameters="object,counter">
if(not HasInt(object,counter) {
object.counter=0
}
object.counter=GetInt(object,counter)+1
</function>


so, the easiest thing to do, is to simply use this script instead:

Run as a script -> Add a~new script -> Variables -> Set a variable or an attribute ->

name_of_object.name_of_attribute=name_of_object.name_of_attribute operator_type number_amount

for example:

name_of_object: player
name_of_attribute: cash
operator_type: +
number_amount: 100

player.cash=player.cash+100

~OR~

WARNING: THIS IS A GLOBAL CHANGE ~ from "+1" to "+your_new_number_amount"

Filter -> Show Library Elements -> Functions -> IncreaseObjectCounter -> Copy ->

<function name="IncreaseObjectCounter" parameters="object,counter">
if(not HasInt(object,counter) {
object.counter=0
}
// change the "1" in the code line below to whatever you want
object.counter=GetInt(object,counter)+1
</function>

jaynabonne
22 Sept 2013, 09:59
I personally would not make a global change to IncreaseObjectCounter. That would only support incrementing by a single hard-coded value (which I doubt you want) and it's just going to cause you grief later when you can't figure out why things aren't working the way they should. If you don't want to simply use a "+" expression to handle this (as HK said above, and which is the easiest by far), you could create your own function - but that's just wrapping an addition inside a new function.

I sense you're having difficulty with getting the expression right to add a value to your counter. If you could show the code (e.g. post the game file or a sample of it), I'm sure we could help straighten that out.

metalmario991
24 Sept 2013, 00:03
Would this be what you mean?
AddToInventory (Wallet)
IncreaseObjectCounter (player, "CASH")

HegemonKhan
24 Sept 2013, 05:27
Note: you can type in whatever you want within the single quotation marks, but the attributes' Names must be typed exactly. And, you can use (type in) whatever number amount you want for the ' cash ' Values, of course.

if you want to use a ' wallet ' Object, then it needs to have a ' cash ' Integer (Int) Attribute, and you'll need this Script instead of the ' IncreaseObjectCounter ' Script:

Run a script -> Add a~new script -> Variables -> Set a variable or an attribute -> (fill it in)

In Code:

<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<cash type="int">0</cash>
<changedcash type="script">
player.cash = player.cash + wallet.cash or player.cash = player.cash - wallet.cash
</changedcash>
<statusattributes type="simplestringdictionary">cash =</statusattributes>
</object>

<object name="wallet">
<inherit name="editor_object" />
<take type="script">
player.cash = player.cash + wallet.cash
wallet.parent=player
</take>
<drop type="script">
player.cash = player.cash - wallet.cash
wallet.parent=player.parent
</drop>
<cash type="int">100</cash>
</object>


In GUI~Editor:

' whatever_the_container_or_parent_object_of_the_wallet ' (Object) -> Objects (Tab) -> Add ->

Name: wallet

wallet (Object) -> Attributes (Tab) -> Attributes -> Add ->

Name: cash
Type: int (integer)
Value: 100

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

Name: cash
Type: int (integer)
Value: 0

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

Name: cash
Value: (leave blank)

in whatever Verb (such as the ' wallet ' Object's ' take ' Verb):

Run a script -> Add a~new script -> Variables -> Set a variable or an attribute ->

[Object.Attribute] = [Expression]

player.cash = player.cash + wallet.cash

and, the reverse (such as with the ' wallet ' Object's ' drop ' Verb):

Run a script -> Add a~new script -> Variables -> Set a variable or an attribute ->

[Object.Attribute] = [Expression]

player.cash = player.cash - wallet.cash

Pertex
24 Sept 2013, 15:20
I am sure I added some counter functions for the gamebook mode in Q5.5. :D Perhaps I should do this for object counter, too. :oops:

metalmario991
28 Sept 2013, 00:24
I don't mean to offend anyone but i'm dumb and its hard for me to figure out the codes you send me. I get the concept but i can't figure out how to do it right. :(

HegemonKhan
28 Sept 2013, 17:26
your not offending anyone, nor are you dumb, I just suck at explaining~teaching this stuff, so my apologies to you!

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

I have just a few questions for you, which if you could answer, would help me to then hopefully better help you.

Q1. I forgot, are you using the online~web version, the offline~computer~downloaded gamebook mode version, or the offline~computer~downloaded text adventure mode version?

Q2. have you gone through the tutorial ( http://quest5.net/wiki/Tutorial ) ? Could you do most of it, or did you have trouble with it? what parts did you have trouble with?

Q3. do you know what I mean when I say~use "GUI~Editor or GUI~Editor mode" and "in-Code or Code or Code View mode" in my posts ??? Also, do you understand my other terminology (or concepts), or not? what terminology (or concepts) is confusing you?

Q4. Do you want to increase the number~amount of an object itself? for example: 1 potion to 99 potions. OR, do you want to increase an attribute of an object? for example: player has 0 strength to player has 100 strength. There's a difference in the two in how you do them, so I need to know what you want to do.

Q5. If you're getting the concept, then what parts~steps are you having trouble with doing or are not understanding? Can you follow along (actually do the stuff in quest that I talk about in my post), or not at all, or where~what specifically spot are you getting stuck at with following along?

metalmario991
28 Sept 2013, 22:24
A1. Online version.
A2. No.
A3. I have no idea what GUI-Editor is.
A4. Either one as i need to increase a set amount. I didn't use this on the other game i made so i'm clueless.
A5. Everytime I try to increase a attribute or object counter (set amount for counter) I GET THE DREADED ERROR!

HegemonKhan
29 Sept 2013, 01:15
Q = (my) question
A = (your) answer
R = (my) response
lol

R1. unless you've got a reason to use the online~web version, as of right now, the offline~computer~desktop~downloaded version has much more functionality~capability (and noob-friendly at that, too), making it easier for you do what you want and also for us to help you too!). Though, you can certainly keep working with the online~web version, we'll get you learning to use quest, eventually (hopefully sooner rather than later, of course, lol).

I believe that the online~web version doesn't have the details on the right side~pane, right? ie, it doesn't look like this:

http://quest5.net/wiki/File:Blankgame.png

so, if I remember right about the online~web version, you only got the:

haha (I got such bad memory!), as I re-looked up this thread:

viewtopic.php?f=10&t=3914

anyways, for the online~web version, you only got the (and we'll be using Jayna's post to guide you through this too):

(you're going to have to do some slight coding, ie typing in some code~script lines, but it's not too difficult *hopefully* as can be seen below)

Jayna wrote:To 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.


Can you follow Jayna's instructions~steps? This will create (add) an attribute to an object. We need to do this, as we can't add, subtract, multiply, and~or divide upon an attribute's value, when there is no such attribute and its value to do so upon, lol.

Do note:

we are *NOT* using the "IncreaseObjectCounter" Script choice, as this can only change it by "+1" amount, when you want to change it by a greater amount, lol.

In Jayna's example:

player.cash
player.cash=0

an explanation of the code lines above:

Object (Name Attribute of Object; it's ID tag for game engine to recognize): player
Object <connector> Attribute: . (period~dot)
Attribute (of "player" Object): cash
Operator (for~of the Value; Attribute <connector> Value): = (equals sign)
Value (of "cash" Attribute): 0 (your starting amount)

I haven't used the online~web version at all (too lazy to do so ~ have to create an account ~ too much work ~ lol), but hopefully you can do this (where ever or whenever you want~need it to be done):

to now add, subtract, multiply, and~or divide upon your Attribute's Value:

(Run as a script ~ if this first option choice exists) -> Add a~new script -> Variables -> Set a variable or attribute ->

Type this in (still using~continuing with Jayna's example):

the [ ]'s is what should already be there on the quest screen, so you don't type in what is inside the [ ]'s below

the ( )'s is what you choose to select as your choice for this drop down box, so you don't type in what is inside the ( )'s below, as well, lol

you can change the "100" to whatever amount you want, I'm just using it as an example amount.

Addition:

[Set variable] player.cash [=] (EXPRESSION) player.cash + 100

Subtraction:

[Set variable] player.cash [=] (EXPRESSION) player.cash - 100

Multiplication:

[Set variable] player.cash [=] (EXPRESSION) player.cash * 100

Division:

[Set variable] player.cash [=] (EXPRESSION) player.cash / 100

Conceptually (using Addition as the example equation):

the "0" can be changed to whatever amount you want, it is just used as an example amount by Jayna and me.

player.cash (starting or old amount) = 0

player.cash (starting or old amount) = 0
player.cash (new amount) = player.cash (starting or old amount) + 100
player.cash (new amount) = 0 + 100
player.cash (new amount) = 100

player.cash (new amount) = 100

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

R2. You should go through the tutorial (well of what you can do in~with the offline~web version), and even if you can't do most of it, still go through all of it, reading it, as it'll help you to understand how to do a lot of this stuff that you're having trouble with right now.

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

R3. the GUI (Graphical User Interface) is simply windows~screens with buttons, folders, icons, and etc stuff for you to use (mostly with~via~for being able to use your mouse or fingers), making it easier and simplier to do stuff. All modern computers and mobile devices (via their OS ~ operating system: windows xp, windows vista, windows 7, windows 8, MacOs, and etc) utilize a GUI. Very old computers could only use "command line prompts" (coding ~ typing in commands of what you want to do), which obviously is very intimidating for many people. Command line prompts still exist for a good reason: they are even much more powerful, than their prototype of MS-DOS, but it takes coding~programming skill~knowledge to use them properly (as with that power, comes danger: you can completely make your computer or other electronic device not ever work again).

the GUI (Graphical User Interface) ~ Editor (for game making) mode is simply this stuff (windows with buttons and etc making it easy to do stuff):

http://quest5.net/wiki/File:Blankgame.png

and this is what the Game Play mode looks like (on the offline~computer~desktop~downloaded version, using the text adventure choice, not the game book choice), the GUI~Editor ~ Game Play:

http://quest5.net/wiki/File:Playblankgame.png

And, in-Code (or Quest's Code View mode), it looks like this (example of~using a newly created game of the downloaded~offline~computer~desktop version, using text adventure game choice):

<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</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" />
</object>
</object>
</asl>


if you're willing, I can teach you to learn to use~work with~do coding, and it might be useful for you. Let my know if you want to learn to code with quest games. It's really not too terribly hard to learn, Alex did an incredible job, making it very noob-friendly to learn and use, despite how it seems right now to you. I'm sure you can learn it quickly, you'll surprise yourself, hehe.

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

R4. let's first get you able to change (addition, subtraction, multiplication, division) an object's (integer) attribute's value in the sections above on this post, and then afterwards, we'll help you with how to change an object itself's amount. To begin:

it involves at the most basical level:

CloneObject, CreateObject, RemoveObject, DestroyObject, and~or MoveObject

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

R5. Errors are "scary" because they attempt to tell you what the problem is (and thus how to fix it), but this can be cryptic, and thus "scary". It does take some effort to be able to learn and understand what an error is trying to say~tell you about what the problems are that you've got, hehe. I still am trying learn the error messages myself, sighs.