Custom Attributes

Samus300
19 Aug 2013, 17:46
Hey! I have started using quest again and have hit the same problem that caused my quitting last time: there are some things not able to be done or are too difficult to be done by people who use quest to get by the need of scripting language. My main question here is, how to edit custom attributes without telling the game to set the attribute. I tried to do a switch script and had fewer options than I liked so I switched over to using an "If then" and "Else If" system. The problem was, I kept getting an error. I don't remember what it was but it isn't important to me. What is is that there is some way to create a currency using custom attributes. I love quest and would love to see a way to have a money system separate from the score system. Also, if there is no fix to that, is there a way to rename score? I tried looking at the code view option but didn't find it in there either. Once again, I love quest and it would be nice if there is a solution to this problem.

jaynabonne
19 Aug 2013, 17:51
If you're using the desktop version, then when you select an object, there is an Attributes tab in the editor. On that tab, you have a list of all the attributes for that object, and you can modify them or create new ones.

Samus300
19 Aug 2013, 18:27
I know that but is there a way to have say a pile of gold add to the attribute instead of having to set the attribute?

jaynabonne
19 Aug 2013, 19:16
I think I'm missing your emphasis, so bear with me. :)

If you had an attribute on the player called "gold", you could add to it by:

player.gold = player.gold + 5

or

player.gold = player.gold + pileofgold.amount

You can't change an attribute without assigning a value to ("setting") it. If you mean is there some code already written in Quest that will automatically do it for you, then I think you'd have to use a library (with already written code) or create it yourself.

Samus300
19 Aug 2013, 20:30
oh ok. I needed to use a code where the attribute needed to be listed. That is where my problem is. I think originally I tried just +20 and the thing said unexpected "+". I understand my mistake. This is why people who don't know scripting language too well should not use scripting language. Also sorry. The emphasis was on add. I tend to forget to show a way to be obvious when emphasizing. So I tried the code "player.Money = player.Money + 20" (as Money is the set attribute and 20 being the amount of gold) and it says "Error running script: Error compiling expression 'player.Money = player.Money + 20': ArithmeticElement: Operation 'Add' is not defined for types 'Object' and 'Int32'" Any idea why?

HegemonKhan
19 Aug 2013, 23:49
this is one aspect of "developing a coding mindset" of thought (which just takes practice and patience, lol):

(and this way of thinking is needed for BOTH working with the GUI~Editor and with Code)

normal thinking: gold = +5

code thinking: HK.gold (my new gold amount) = HK.gold (my old gold amount) + 5

In the GUI~Editor, you can do:

Add a~new script -> Output -> Print a message -> Print [EXPRESSION] HK.gold = HK.gold + 5

or, i think...

Add a~new script -> Variables -> Increase object counter -> // though I'm not sure by how much it'll increase your amount, lol, and besides you want to choose what amount anyways, so switch it from [COUNTER NAME] to [EXPRESSION]

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

if you're getting an "int32" <-> "object"-or-"string" Error, then your attribute types don't match up.

Types of Attributes:

int (integer), string, boolean (or a "flag"), script, stringlist, objectlist, stringdictionary, objectdictionary, and scriptdictionary

as this doesn't make sense to a computer:

int + object = ERROR!

this is the more common error however:

int + string = ERROR!

as you got this (an example):

4 (int) + 5 (string)

even though, you got the two number characters, their ATTRIBUTE TYPES are different, and:

"4" can be either an INT or a STRING, quest needs to know which it is, so it can know whether it can add them together or not.

so, what you got to figure out (or show us your game code, so we can do so for you):

you either got to get your game part that has the error, as:

x (int) + x (int)

or

your object just needs an attribute to it (as the error shows that the game is getting an actual OBJECT for your thing, which you don't want in this case, as you can't add something to an actual OBJECT).

HegemonKhan
20 Aug 2013, 00:16
Oops...

I should have read your post more carefully:

Samus wrote:So I tried the code "player.Money = player.Money + 20" (as Money is the set attribute and 20 being the amount of gold) and it says "Error running script: Error compiling expression 'player.Money = player.Money + 20': ArithmeticElement: Operation 'Add' is not defined for types 'Object' and 'Int32'" Any idea why?


because, noobs to quest or to coding, commonly use the actual objects, not yet understanding the concept and usage of "virtual amounts" via the use of Attributes (and their adjustments).

So, I'm certain that your "player.Money" is an actual Object, that you added to the "player" Player Object, correct? Yes (99%)

hence the Error of "int32 <-> object" :

Object.Object = Object + int // "computer does not compute" (and us too ~ it makes sense to us that this doesn't work too)
player(Object).Money(Object) = player(Object).Money(Object) + 5(Int)

see, the problem with this?

what you got to do:

(if you can actually use an Object ~ if there is indeed a way to do so, then I did not know this!, lol)

1. delete your "Money" Object from your "player" Player Object
2. and instead, do this:

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

Name: Money // or gold or whatever you want // also, a helpful tip, don't use capital letters unless you need or really want to do so! it'll save you a lot of time if you don't use them, lol!
Type: int (integer)
Value: 0 // or whatever amount you want to start with, lol

now, in your (likely) Verb (Tab) of whatever the Object (for example: "atm_machine", lol):

"atm_machine" -> Verb (Tab) -> Add ->

name: give_me_more_money // lol
box: [RUN A SCRIPT]

Add a~new script -> Output -> Print a message -> Print [EXPRESSION] HK.Money = HK.Money + 1000000000000 // oh ya! :mrgreen:
(you wouldn't use "HK" of course, lol. You'd use "player" or whatever you named your Player Object as instead)

Also, if you don't realize:

using for example only: "player" and "cash" and "5"

For Addition:

player.cash = player.cash + 5

For Subtraction:

player.cash = player.cash - 5

For Multiplication:

player.cash = player.cash * 5

For Division:

player.cash = player.cash / 5

Also, here's some other ideas for you:

player.cash = player.cash + orc.cash // like after you kill the monster Object: "orc"
player.experience_points = player.experience_points + orc.experience_points // like after you kill the monster Object: "orc"

Also, if you're doing a transaction, then you need a transaction of scripts:

You Buy something from a shop owner:

player.cash = player.cash - 100 // you lose money due to buying something from the shop owner
shop_owner.cash = shop_owner.cash + 100 // shop owner gains money as you're buying something from him

You Sell something to a shop owner:

player.cash = player.cash + 100 // you gain money due to selling something to the shop owner
shop_owner.cash = shop_owner.cash - 100 // shop owner loses money as you're selling something to him

see, "virtual amounts", in action by "adjusting the attributes". No need for having, using, and moving actual Objects around! (thank goodness!)

jaynabonne
20 Aug 2013, 00:29
You will also get that error if player.Money does not exist as an attribute (missing attributes get reported as type "object").

Samus300
10 May 2014, 00:45
I know this is in the wrong place, but I can't recall how to add a forum post, so I will ask to a forum I posted a few years ago. I was curious about a Linux version and if such a thing exists. I am currently on a Linux machine and don't have access to Windows.

R2T1
10 May 2014, 05:50
There is no offline (desktop) version for Linux or its derivatives. However, you could use the web interface at http://textadventures.co.uk/
As for creating a new topic, when you are in the forum in which you want to post, there should be a button at the top left that says 'New Topic'. Click this and post away.

Samus300
05 Jun 2014, 00:41
Oh, I was hoping there would be. I don't like the online editor. It has less functionality. I do have Windows but due to drivers being conditioned for a different hard drive, I cannot access internet from there for when I need help.