creating objects on the fly
stokesie18
18 Jan 2009, 22:56Is it possible to clone an object, whislt in game, based on an object already hard coded?
For instance, if i have a numeric variable (no_of_seeds) that often changes.
When the player types "plant seed", i would like to be able clone a pre-existing "tree" object for every seed the character plants.
Is this possible?
For instance, if i have a numeric variable (no_of_seeds) that often changes.
When the player types "plant seed", i would like to be able clone a pre-existing "tree" object for every seed the character plants.
Is this possible?
Redsun
19 Jan 2009, 02:54thats a good question, i know you can clone an object, not sure if its coding is cloned to, but this is a question i'd like answered to.
Alex
19 Jan 2009, 17:51You can clone an object using the "Clone an object" command from the "Modify" category.
If by coding you mean the various actions and scripts that are associated with the object, these are all cloned as well.
If by coding you mean the various actions and scripts that are associated with the object, these are all cloned as well.
Redsun
19 Jan 2009, 18:25Awesome, that makes things easier then.
stokesie18
19 Jan 2009, 21:56Ok. I feel a little bit stupid for missing something that obvious. But, the code i wrote to handle planting objects (which, as of yet is unfinished), to a point where i could test it with a fruit (namely, apple), and it's not working. Any ideas?
I getting the "you dont have apple" response, when i do in fact have an apple. Hmmm.
command <plant #@_obj#> {
if got <#@_obj#> and type <#@_obj#; plantable> then {
if ( ##@_obj#:grows_on# = ##quest.currentroom#:land_style# ) then {
msg <you plant the #_obj#.>
move <#@_obj#; garbage>
if type <#_obj#; fruit> then {
select case <##@_obj#:frt_type#> {
case <apple> {
clone <treApple1; appleTree%tree_clones%; #quest.currentroom#>
inc <tree_clones>}
} } else msg <Thats not a fruit.> } else {
msg <That won't grow here.> } } else {
msg <You don't have: #@_obj#> }
}
I getting the "you dont have apple" response, when i do in fact have an apple. Hmmm.
Alex
20 Jan 2009, 17:20Only use the #@...# variable form for the "command" line. Elsewhere just use #...#, except if you're displaying the object name.
#@...# form is for the "displayed" version of the object name, i.e. one a user can type in, or one that is displayed to the user - this could be an alias or one of the "Other Names" set up for the object.
#...# form is for the "internal" version of the object name, i.e. the actual name of the object in QDK.
Also if you want to get the property of an object that's in a variable, use #(variable):property#
#@...# form is for the "displayed" version of the object name, i.e. one a user can type in, or one that is displayed to the user - this could be an alias or one of the "Other Names" set up for the object.
#...# form is for the "internal" version of the object name, i.e. the actual name of the object in QDK.
Also if you want to get the property of an object that's in a variable, use #(variable):property#
command <plant #@_obj#> {
if got <#_obj#> and type <#_obj#; plantable> then {
if ( #(_obj):grows_on# = #(quest.currentroom):land_style# ) then {
msg <you plant the #@_obj#.>
move <#_obj#; garbage>
if type <#_obj#; fruit> then {
select case <#(_obj):frt_type#> {
case <apple> {
clone <treApple1; appleTree%tree_clones%; #quest.currentroom#>
inc <tree_clones>}
} } else msg <Thats not a fruit.> } else {
msg <That won't grow here.> } } else {
msg <You don't have: #@_obj#> }
}
stokesie18
21 Jan 2009, 07:33Thanks alex, that makes alot of sense. Ive made the ammendments to my code and it seems to be running fine.