Objects and properties - how to access
rob.woolhouse
03 Oct 2008, 05:18Hi,
Got a 24 hour clock displaying correctly now so must be getting somewhere, BUT...
Still having some trouble getting my head round the syntax in ASL.
I have a reasonably clear idea of how I want to code games, but can't get some important things to work.
For instance, I've defined a procedure CombatAttack as below :
define procedure <CombatAttack>
msg <#(parameter(1)):DamageMax#>
end define
which seems to be the way the documentation tells me to i.e.
#(variable name):property#
where parameter(1) = variable name
(This is still very simple at the moment as it's just for learning / debugging !)
What I want is to pass an object of type Sword, say, to that procedure, extract its DamageMax property and then use that value within the procedure.
What is the correct way to do that ?
Also, when defining status variables, the syntax in the docs for displaying in the right pane is
display <!%% health>
I get "10% health" with that (health being 10) when I just want "10". Any attempts at changing the expression result either in "[ERROR]" or "1010" !
Anyone with a better grasp of ASL able to help ?
Cheers,
RW
Got a 24 hour clock displaying correctly now so must be getting somewhere, BUT...
Still having some trouble getting my head round the syntax in ASL.
I have a reasonably clear idea of how I want to code games, but can't get some important things to work.
For instance, I've defined a procedure CombatAttack as below :
define procedure <CombatAttack>
msg <#(parameter(1)):DamageMax#>
end define
which seems to be the way the documentation tells me to i.e.
#(variable name):property#
where parameter(1) = variable name
(This is still very simple at the moment as it's just for learning / debugging !)
What I want is to pass an object of type Sword, say, to that procedure, extract its DamageMax property and then use that value within the procedure.
What is the correct way to do that ?
Also, when defining status variables, the syntax in the docs for displaying in the right pane is
display <!%% health>
I get "10% health" with that (health being 10) when I just want "10". Any attempts at changing the expression result either in "[ERROR]" or "1010" !
Anyone with a better grasp of ASL able to help ?
Cheers,
RW
paul_one
03 Oct 2008, 14:39The line you're using is invalid since parameter(1) is actually a function and not a variable.
Use :
Instead.
I'd also say, instead of type "sword", that property would be generic across all 'weapons' (swords, axes, knives).
Use :
set string <weapon; $parameter(1)$>
msg <#(weapon):DamageMax#>
Instead.
I'd also say, instead of type "sword", that property would be generic across all 'weapons' (swords, axes, knives).
rob.woolhouse
04 Oct 2008, 04:47Yes, I've used what you suggested and it works fine. Thanks.
BTW the status variable part of the post I figured out about 5 minutes before I ran to get to work today !
I'd misunderstood the documentation and had not realised the double %% was meant to indicate an escape from ASL code to allow for a literal '%' character (not something I want).
I'd also say, instead of type "sword", that property would be generic across all 'weapons' (swords, axes, knives).
'Sword' is a type derived from 'Weapon' which has the properties needed to properly define any type of Weapon...although an ameteur at programming in any language I recognise the value of OOP. See below
define type <Weapon>
DamageMax
DamageMin
HitChanceBonus
end define
define type <Sword>
type <Weapon>
DamageMax = 10
DamageMin = 2
HitChanceBonus = 10
end define
Is this a good way to build a hierarchy of types in ASL ?
Thanks again for your help...
I love QDK
Rob Woolhouse
BTW the status variable part of the post I figured out about 5 minutes before I ran to get to work today !
I'd misunderstood the documentation and had not realised the double %% was meant to indicate an escape from ASL code to allow for a literal '%' character (not something I want).
I'd also say, instead of type "sword", that property would be generic across all 'weapons' (swords, axes, knives).
'Sword' is a type derived from 'Weapon' which has the properties needed to properly define any type of Weapon...although an ameteur at programming in any language I recognise the value of OOP. See below
define type <Weapon>
DamageMax
DamageMin
HitChanceBonus
end define
define type <Sword>
type <Weapon>
DamageMax = 10
DamageMin = 2
HitChanceBonus = 10
end define
Is this a good way to build a hierarchy of types in ASL ?
Thanks again for your help...
I love QDK
Rob Woolhouse
paul_one
05 Oct 2008, 21:37Ahhh good-good.
And yeah, the inheritance in ASL works that way (I hope).
And yeah, the inheritance in ASL works that way (I hope).