Moving a Prop from Inventory to Room: Difference between revisions
From Sierra Wiki
Jump to navigationJump to search
m 1 revision imported |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
[[Category:SCI Pages]] | |||
[[Category:Temp SCI Pages]] | |||
[[Category:SCI Pages to be Edited]] | |||
<div align="center"><span style="font-size: 22pt">Moving a Prop from Inventory to Room</span><br />''By [[Phil Fortier]]''</div> | |||
<br /> | |||
==<br /> Introduction == | |||
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. | 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. | ||
| Line 48: | Line 54: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==<br /> References == | |||
<references /> | |||
==<br /> Related Links == | |||
* | |||
| | ||
[[Category:Inventory]] | [[Category:Inventory]] | ||
[[Category:SCI Inventory]] | |||
[[Category:Props]] | [[Category:Props]] | ||
[[Category:SCI Props]] | |||
[[Category:Scripting]] | [[Category:Scripting]] | ||
[[Category:SCI Scripting]] | |||
[[Category:Examples]] | [[Category:Examples]] | ||
[[Category:SCI Examples]] | |||
Latest revision as of 16:41, 29 April 2025
Introduction
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")
)
)
References
Related Links