Community

SCI Programming => SCI Syntax Help => Topic started by: jtyler125 on March 07, 2007, 05:11:46 PM

Title: Inventory Blues
Post by: jtyler125 on March 07, 2007, 05:11:46 PM
Ok can someone put up a sample simple script showing how to make an object in my inventory appear on the screen after I say put key on table for example.  And then it comes out of my inventory...I need this to finish my game.
Title: Inventory Blues
Post by: troflip on March 07, 2007, 05:46:03 PM
I'm just winging this, since I'm at work now and can't test it... but given your inventory key is identified with INV_KEY,  I think it might look like:

In your room, define a key Prop:
Code: [Select]
(instance keyOnTable of Prop
    (properties
        x 100
        y 130
        view 100
    )
)

In your room's init method:
Code: [Select]
// 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: [Select]
(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")
    )
)
Title: Inventory Blues
Post by: jtyler125 on March 07, 2007, 09:02:43 PM
Thanks Tro,

I actually banged out a yucky way to make it work using what was up there already and it seems to work good enough for now.

Now I need to make a deathhandler come up when I try to leave the room unless I have a certain amount of points any takers on what that script might look like:

Thanks,
JT