Passing objects and returning properties

rob.woolhouse
Hi,

I have only just started out working with ASL and QDK so please bear with me if this is a silly question; I've been through the docs and tried several different things but nothing seems to work.

I have defined a Weapon type and then created a specific object IronDagger from it with a property Damage defined to be 3.

I now wish to pass this object to a function WeaponDamage which will simply retrieve the value of that property from the object passed as parameter(1) and return that value to the calling procedure.

I may want to use the returned numeric value for a message or for further calculation.

1. What is the syntax for getting that property from the object once it has been passed into my WeaponDamage function ?

2. Is it returned as a numeric value or string, and does it matter much in ASL ?

3. If it is returned as a number, can I still use it in a msg<> statement without conversion ?

Any advice appreciated,

Thanks

RW

Thanatos
Im not here to offer you advice, but to say welcome.

So welcome!

Alex
Instead of using a function to return a property, it's easier just to reference the property directly.

For example, to return the Damage property of the object IronDagger, use #IronDagger:Damage#

To generalise this to return the Damage property for the object referenced by the string variable "myobject", use #(myobject):Damage#

The documentation page for this is here: http://www.axeuk.com/quest/developer/do ... erties.htm

To answer questions 2 and 3, ASL doesn't worry about data types, so you can assign a string value to a numeric variable without having to do any explicit conversion.

rob.woolhouse
Thanks Alex, I've tried that and it does what I wanted.

I always seem to make coding things harder than need be .

I may be back with more questions though. I am currently spending the 2 hours a day I have free messing around with Quest cos I love it !

Thanatos : thanks for welcome.

Cheers

RW

Elexxorine
I also bid you welcome. Be careful using capital letters in names, make sure you always capitalise them the same, 'Damage' and 'damage' are seen as different things by quest.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums