Properties and actions

ramtha
08 Mar 2006, 00:12
I'm quite confused when it come to the actions and properties of objects.
it seems no matter how many times i read the manual, i cant seem to get it. so if any anyone would be so kind as to explain how they work, and how to make them... I would appreciate it alot. I think it will come in hady.

paul_one
08 Mar 2006, 11:46
To use them, you need a "do object action", although I'm not sure how to get to it in QDK.
Properties can be set quite easily - not sure how easily through QDK.

Object actions are like functions/procedures. Properties are just like variables - but properties are for objects or rooms instead.
The good thing about them is they can be tied into 'types', so can properties - but that's another issue I think.

Calling an object action through code is:

doaction <#object#;#action#>

For instance, say I had an object action called "jump".. And I set up a command called "poke #thingy#" .
As the script I'd have:
command <poke #thingy#> doaction <#thingy#; jump>

Now, to create the action - in QDK you'd have a tab at the top, and in one of those you can select actions/types (I don't have a copy of Quest installed here for reference).

Before I continue, can you give me some idea of how you are doing this - and how far you understand this?

ramtha
11 Mar 2006, 02:47
Well, I think I figured out the actions. But I was wondering if there was any specfic purpose to the Types, and how do the properties work.
While I'm at it I suppose I could also ask how a function works.

paul_one
11 Mar 2006, 22:51
Well, functions are basically blocks of code that runs when you call them.
They can take parameters if you want - but the most important part is that they RETURN a value.

For instance let's say you have a function that takes (we usually say 'takes' in reference to a parameter - because we give this value over to the function when we call it.) one parameter and add's 2 then multiplies this value by 3..

This function would be called "myfunction", and we don't care how it works right now.

Let's start off by CALLING a function..
Where you would normally just go through bit by bit in code - you can (in ASL) do the following:
set string <fail_or_succ; $myfunction(5)$>

This would pass 5 to the function 'myfunction'. Myfunction would change this value - and would return "21" into the string.
So now, the string is set to "21".

You can do alot more with functions - but returning a value is the critical part.

Types.
These are useful if you want different 'types' of objects that have the same properties/actions/etc..
Let's say you want a pumpkin type - now this type would have the following (for example);
property <colour=orange; shape=ovoid; taste=bad>
and the actions could be as follows:
action <eat> msg <you look at the #object#.. You think wiser than to eat this!>
action <throw> msg <you throw the #object# at #person#..>

Now, if you have 5 objects, instead of typing the exact same thing out for those 5 objects - just put the above into a 'type', and then add the type tag into the object:
define object <object1>
type <pumpkin>
end define

This could give it an alias name, description, anything you like!
And the best bit is it saves you LOADS of typing!
Now - if you want something to change - say one object to have the property of "taste=good", then you just set it in the object properties (as I think it over-rides type definitions... at least it should).

Do you get that?

ramtha
12 Mar 2006, 00:18
There are just two things i dont understand, When you were talking about the functions, you mentioned mutiplying. do you know if you can have status variables mutiply to make another one. Becuse i thought you couldnt mutiply.
And how do the properties work?
I mean there is a name and value, but whats the value for?

paul_one
12 Mar 2006, 15:54
The value is exactly that - a value. :shock:

So if we have an object called "gold", we can have a property called "amount", and have the property value set to how much gold is held - say "5".

Or, we could have the object called "sword", and give it the property "power" with the value of "10"... Which can effect combat/story events.

You can easily multiply any number - just set a variable.
To add two numbers together you do:
3 + 5
To subtract:
3 - 5
To multiply:
3 * 5 (Remember, x is a letter - not a mathmatical symbol.. In maths it's usually not even written - unless you're pre-algebra)
To devide:
3 / 5 (Something like a fraction - which is exactly a devide just not worked out yet to an exact value - usually for aesthetic reasons, or the fact that it creates a number like pi - with no end.)

Properties work like variables:
For instance, setting the property <gold; amount=20> will give the property a value of 20.
Now, to use that - you can use the following:
msg <Hello - you have #gold:amount# pieces of gold!>

The powerful part comes from if you have also potions and scrolls etc, all using "amount".
You can get it to print out the following in about 3 or 4 lines - which you can also use for a million other objects:
"You have 5 gold pieces,"
"You have 10 yellow scarfs,"
"You have 15 tin cans,"
"You have 3 oranges,"
"You have 1 bottle of water,"
"You have 11 hats,"

ramtha
12 Mar 2006, 19:20
Yeah.... I tried that. What I was hoping the outcome for the muliplcation would be a number. But i just end up getting the equation i put out.
What i'm trying to do is have say your stats like strength and defence multiplied together to get what your heath would be.
Say the Strength is 2 and defence is 3 I would have %Strength%*%defence%
But in the game it would show up as 2*3 and not 5.
is there anyway to fix that?

paul_one
14 Mar 2006, 12:54
Yes.
set numeric <health; %strength% * %defense%>
msg <Your health is %health%.>

ramtha
14 Mar 2006, 15:03
one more question, do they need to be in the GT LT brakets