Question about attributes and using volume

Vega
28 Nov 2015, 20:49
Hi,

TLDR; "How can I change and adapt the attributes and / or volume of an object?"

I can't figure out how to use attributes and volumes in objects.

I have my objects and they have attributes which are integers.

Eg.

object.volumeofobject

cup.500ml

How can I add *some but not all* of the volume of that object to the players inventory?

Eg.

Add 250ml of the cup to the player's inventory.

I think I need to create another object with the same alias, then add it to the players inventory. But what about the volume / attribute of the content of the object?

Thanks!

TinFoilMkIV
28 Nov 2015, 21:22
So lets say you have a cup with 500ml of water. In order to take some but not all of that water you first need a second container to put that water into (assuming fairly normal circumstances of course). Then when the player does the action to take water from the first cup into their container, you remove the set amount from the cup and add it to the amount contained in the players container.

As for the setup, I would personally create an attribute on a container type object for whatever is contained, as an example I'll name the attribute "holding" and it will be a string since we just want a name to list whats inside our cup. So in this case Cup.holding = "water". Now you need a second attribute for the amount being held, I'll just call this "volume", so then Cup.volume = 500. You want just a number here, you can add the labels such as 'ml' in the description and such. If you add any letters it will treat it as a word and not a number value.

To take part of the contents you'll need to create a verb on the cup to take the contents and not the cup itself, how much flexibility you want to give the player (ie: enter any number vs pick from some options) is up to you. Then when you remove the selected amount, you then add that to the volume of the player's container.

Vega
28 Nov 2015, 21:32
HI,

I do not know how to implement this in the SDK.

I have my object.

I have my object attribute (which is the number)

I have my player's inventory.

But I can't figure out how to create the verb script that will create a new object in the players inventory and add some contents of the attributes to it, and subtract the same amount from the original objects attribute...

Generally speaking, I do not understand how to use the attributes in the game. The tutorial only goes over print scripts, not other kinds of player interactions - such as the one I am struggling with.

In the attached pictures you can see my current script, using the *move object* command. But this is not what I want - I don't want to move the entire object, I want to move a portion of an attribute in the object... How do I do that?
example.png

Vega
28 Nov 2015, 21:33
Is there a good way to implement using this menu?
dsfasfdf.png

Vega
28 Nov 2015, 21:42
An even simpler question would be:

How do I change an attribute with a verb script?

Especially while using the menu provided by the SDK?

Thanks-

Vega
28 Nov 2015, 21:49
Here is my new attempt to make this work. It is giving an error.
asdfsadfsd.png

TinFoilMkIV
28 Nov 2015, 21:55
Okay, so in this case you're removing some number of Tuna from the ocean and adding them to the players Hull Storage if I'm reading this correctly?

You will want at least two different Tuna objects. One for the the Tuna in the Ocean, and one for 'CaughtTuna'. So we need an attribute to count how many there are of each type. So in that screenshot you posted you're in the 'verbs' tab, you want to go over to 'attributes', then hit the 'add' button in the lower section that says 'attributes' next to it, NOT the upper 'inherited types' section. I'm just going to call my attribute "amount", then you want to change it's type to 'integer' so it counts in whole numbers.

You already have a catch verb, so instead of move, you want to decrease the amount of normal Tuna, and increase the amount on CaughtTuna. To keep things simple I'm going to catch 1 Tuna.
if(Got(Short Rods)) {
Tuna.amount = Tuna.amount - 1
CaughtTuna.amount = CaughtTuna.ammount +1
}

The reason it's written this way is to tell Quest that you want to change Tuna.amount to be equal to whatever it's already at minus 1. Then we do the opposite for the CaughtTuna, increasing the amount by 1.

Something you'll need to keep in mind is this method wont automatically remove your Tuna from the ocean if the amount reaches 0, so you'll need to add something to the end of that script to check to see if there are any left after catching them.

EDIT: what do you mean by 'SDK'? I'm not familiar with that abbreviation.

Also what is the error message? My guess would be the object type when you're creating the tuna, since you likely didn't create an 'integer' type for objects. you can just leave that blank and it will be fine, its the attribute type you want to be integer

The Pixie
28 Nov 2015, 22:12
Quest has two types of types. The first type is one of integer, Boolean, object, list, dictionary, script, double. You can set an attribute to be any of these types. The second type is what objects can be. Some examples are editor_object and namedfemale, and you can create your own ones too.

In your script above you are creating an object, Tuna, and setting its type. The type in that context is the second one, but you have set it to integer, which is the first one (and in fact is not even that, because Quest uses "int" for integer).

Are you trying to limit the number of fish that can be caught in one go? I would have a volume attribute on the Hull Storage object, and when a fish is caught modify that. So keep the first line that moves the fish, delete the second and fourth, and change the third like this:
Set variable [Hull Storage.volume] = [expression] [Hull Storage.volume - this.volume * 0.5]

You can use "this" to stand for the tuna1 because the script is attached to tuna1, and if you later have a tuna2, tuna3, etc. it will still work for them.

You will need to set up a double attribute on the Hull Storage Attributes tab called volume, with the capacity.

Vega
28 Nov 2015, 22:16
HI,

I'm using SDK in the sense that Quest has a Software Developer Kit, which we are using. Specifically I am trying to ask if I will be able to implement my ideas without having to write code in a text editor, and instead use the handy UI menu that they created - because I am very new to coding in general and have only used Python for about 2 months.

But SDK is my reference to both the entire UI and the nice handy menu that comes with it.

XanMag
28 Nov 2015, 22:23
Do you want a specific amount? Say 273 ml? Or 86 ml? Or 124 ml? Or do you want to keep it simple like only being able to take 250 ml? If it's simple, I have a simple solution for you. If you want any number takeable between 1 and 500... Well, that's a bit tougher.

The Pixie
28 Nov 2015, 22:43
Vega wrote:I'm using SDK in the sense that Quest has a Software Developer Kit, which we are using. Specifically I am trying to ask if I will be able to implement my ideas without having to write code in a text editor, and instead use the handy UI menu that they created - because I am very new to coding in general and have only used Python for about 2 months.

Two months of Python probably puts you ahead of the game (you even know what an SDK is!).

You can do everything in the GUI that you can in code. Internally it is stored as the same thing. The advantages of code is that you can see more of it in one go as it is smaller, which makes working stuff out easier, and it is easier to talk about on the forum. It certainly has disadvantages too.

Once you have some scripts working, go in to code view (seventh icon above the script) and see what the code looks like.

Vega
28 Nov 2015, 22:45
HI,

I got it working! So helpful guys thanks! I was getting super discouraged.

I could not understand how the *set variable* script worked. I think it may have been because I was using .5 notation, not 0.5... maybe?

Anyways - here is the working product.

I intend on making a store where I can sell these fish for another resource...

Would I be wrong to assume that the *set variable* script is very useful and common in these games?

Any other advice on what scripts are really useful for beginners?
WORKING ATTRIBUTES.png

HegemonKhan
29 Nov 2015, 04:21
here, see this thread (scroll down a ways in it, to the '2.Scriptings' section and its 'TWO SUPER SCRIPTS' stuff, which is the 'set a variable or attribute' Script and the 'if' Script, though you'll probably want to read the whole thing too, as I think it'll be useful for you):

viewtopic.php?f=18&t=5559

you should be able to learn quest's code quickly if you know some programming in general and~or python.

figuring out how to do what you want with the GUI~Editor... is a pain... if you're more code-oriented-able, lol. At least for me, figuring out the GUI~Editor's Scripts isn't intuitive...