Moving a Prop from Inventory to Room
From SCI Wiki
Jump to navigationJump to searchThe printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
By troflip
To make an object in inventory, such as a key, appear on the screen and be removed from the inventory, if the inventory item is identified with INV_KEY, you can use this code.
In your room, define a key Prop:
Code:
(instance keyOnTable of Prop
(properties
x 100
y 130
view 100
)
)
In your room's init method:
Code:
// If the inventory key is owned by this room, make the "key on table" visual show up:
(var invItem)
(= invItem (send gInv:at(INV_KEY)))
(if (send invItem:ownedBy(gRoomNumber))
(keyOnTable:init())
)
Then in the RoomScript's handleEVent method:
Code:
(if (Said('put/key/table'))
(if (send gEgo:has(INV_KEY))
(send gEgo:put(INV_KEY gRoomNumber)) // Give inventory key from the ego to the room
(keyOnTable:init()) // Make the "key on table" visual show up
)
(else
Print("You don't have the key")
)
)