Problems taking objects which aren't on the floor
philtepper
02 Jan 2014, 18:37Suppose I enter a room to find a painting on the wall. I can take the painting but want to be able to hang it back on the wall. If I've defined a verb 'hang' and invoke it to hang the painting, I cannot then (re-)take it because I've not dropped it first. Is there any way to overcome this, say by embedding some of the 'drop' code into my 'hang' functionality?
Also, is it possible to write code to modify displayverbs or inventoryverbs? I've tried this by using
Addtolist painting.inventoryverbs value text take
but get
Error running script: Cannot modify the contents of this list as it is defined by an inherited type. Clone it before attempting to modify.
from which I can't understand whether or not what I'm trying to do is possible.
Also, is it possible to write code to modify displayverbs or inventoryverbs? I've tried this by using
Addtolist painting.inventoryverbs value text take
but get
Error running script: Cannot modify the contents of this list as it is defined by an inherited type. Clone it before attempting to modify.
from which I can't understand whether or not what I'm trying to do is possible.

jaynabonne
02 Jan 2014, 19:25To have the painting be back in the room (as opposed to owned by the player still), assign it back to the room. Something like:
(or "player.parent"). The player's parent should be the room the player is currently in.
There is a trick to make inventoryverbs work. The inventoryverbs attribute is defined in a base type, and you can't modify it until you create a fresh, modifiable copy in the object. To do that, use this seemingly useless statement before you attempt to add any verbs:
When you assign a list to an object's attribute, Quest makes a copy of it. By doing the above, it takes the current, un-modifiable list, creates a copy of it, and assigns it back to the inventoryverbs attribute. You should then be able to add items to it.
painting.parent = game.pov.parent
(or "player.parent"). The player's parent should be the room the player is currently in.
There is a trick to make inventoryverbs work. The inventoryverbs attribute is defined in a base type, and you can't modify it until you create a fresh, modifiable copy in the object. To do that, use this seemingly useless statement before you attempt to add any verbs:
painting.inventoryverbs = painting.inventoryverbs
When you assign a list to an object's attribute, Quest makes a copy of it. By doing the above, it takes the current, un-modifiable list, creates a copy of it, and assigns it back to the inventoryverbs attribute. You should then be able to add items to it.
philtepper
02 Jan 2014, 19:37Thanks again jaynabonne, you are a star. Slightly ashamed that (even though at newbie status) I failed to think of assigning the painting to the room myself!
HegemonKhan
02 Jan 2014, 19:52aside from simply using the built-in "parent" attribute as Jayna already explained, I think you could do:
"painting (hanging)"
(see Pixie's Clothing or Chase's Wearables libraries, ie equipment coding)
but, it'd involve some really advanced coding on top of the equipment coding (which isn't code-noobie friendly).
-----------------
the game world is a bunch of Objects, which can have Objects within them.
think of these Objects as a family, with children and parents.
you've got the "parent" Object, which holds within it, the "children" Objects.
the far left sided " -> " (arrows) is my way of showing the "nesting~indenting" = the parent'ing~children'ing
wallet = parent object
-> $10_bill = child object
-> $5_bill = child object
-> $1_bill = child object
************
additional examples:
HK = parent (root) object of "the 3 bills", "HK's_pant's_pocket", and "wallet"
-> HK's_pant's_pocket = child of "HK" and parent of "wallet"
->-> wallet = child of "HK's_pant's_pocket" and parent of // "the 3 bills"
->->-> // the 3 bills = child objects of "HK", "HK's_pant's_pocket", and "wallet"
C:\ Drive = parent (root) Folder of "program folder" and "C:\ Drive"
-> program folder = child folder of "C:\ Drive" and parent of "quest folder"
->-> quest folder = child folder of "program folder" and "C:\ Drive"
**************
so, in code, it'd look like this:
$10_bill.parent = wallet
$5_bill.parent = wallet
$1_bill.parent = wallet
the 3 bills are within~attached to~held by the wallet
this is also how we can move objects around:
old location of the $10_bill: $10_bill.parent = wallet
new location of the $10_bill: $10_bill.parent = bank
-----------
in the GUI~Editor, you'd just use the:
"MoveObject" script ("add a script" button) within your Object's Verb's scripting
"painting" (Object) -> Verb (Tab) -> Add -> Name: "hang" -> run as script (small drop down box) -> add a script (small cirlce button) -> Objects Script Category -> "MoveObject" (script)
"painting (hanging)"
(see Pixie's Clothing or Chase's Wearables libraries, ie equipment coding)
but, it'd involve some really advanced coding on top of the equipment coding (which isn't code-noobie friendly).
-----------------
the game world is a bunch of Objects, which can have Objects within them.
think of these Objects as a family, with children and parents.
you've got the "parent" Object, which holds within it, the "children" Objects.
the far left sided " -> " (arrows) is my way of showing the "nesting~indenting" = the parent'ing~children'ing
wallet = parent object
-> $10_bill = child object
-> $5_bill = child object
-> $1_bill = child object
************
additional examples:
HK = parent (root) object of "the 3 bills", "HK's_pant's_pocket", and "wallet"
-> HK's_pant's_pocket = child of "HK" and parent of "wallet"
->-> wallet = child of "HK's_pant's_pocket" and parent of // "the 3 bills"
->->-> // the 3 bills = child objects of "HK", "HK's_pant's_pocket", and "wallet"
C:\ Drive = parent (root) Folder of "program folder" and "C:\ Drive"
-> program folder = child folder of "C:\ Drive" and parent of "quest folder"
->-> quest folder = child folder of "program folder" and "C:\ Drive"
**************
so, in code, it'd look like this:
$10_bill.parent = wallet
$5_bill.parent = wallet
$1_bill.parent = wallet
the 3 bills are within~attached to~held by the wallet
this is also how we can move objects around:
old location of the $10_bill: $10_bill.parent = wallet
new location of the $10_bill: $10_bill.parent = bank
-----------
in the GUI~Editor, you'd just use the:
"MoveObject" script ("add a script" button) within your Object's Verb's scripting
"painting" (Object) -> Verb (Tab) -> Add -> Name: "hang" -> run as script (small drop down box) -> add a script (small cirlce button) -> Objects Script Category -> "MoveObject" (script)