Re: The Inventory
Status: Alpha
Brought to you by:
cwalther
|
From: Christian W. <cwa...@gm...> - 2012-01-03 17:00:13
|
James C. Wilson wrote:
> I'm having a bit of trouble applying the
> inventory operations in the demo to my project: Is this the proper way
> to test if an inventory object is carried, then drop it?
> Pipmak doesn't see equality.
>
> hotspot {
> cursor = cur_inventory, enabled = not state.observCablePlaced,
> onmousedown = function()
> if state.inventory[state.inventory.carried] == "TVCable" then
> inventory:message("drop", "TVCable")
> pipmak.gethotspot(3):enable(false)
> state.observCablePlaced = true
> pipmak.getpatch(1):setvisible(true)
> end
> end
> }
One mistake I can see is that the "drop" message of the inventory takes
an index, not an object name. You can also leave out the argument
entirely, it will then automatically assume state.inventory.carried. See
nodes 9 (use of the key from the inventory in a similar way to what
you're trying to do) and 50 (inventory) in the demo project.
If as you say you don't even get that far because
state.inventory[state.inventory.carried] == "TVCable" is never true,
then I would suggest inserting
pipmak.print(state.inventory[state.inventory.carried])
or examining state.inventory using the table inspector from the Lua
command line to find out what it is.
-Christian
|