Last night I finally figured out my Lua coding in Urwigo issue and I wanted to share it with others who are also a little bit new to building their own Wherigo's. I am making a cartridge where a bunch of items get moved to the Player but I only want the Player to be able to use items in their inventory on the other items which will not be moved to the inventory.
The Entire Problem I was trying to solve: I wanted to make custom on-the-fly inputs of choices depending on items that are on the Player. While it is true that you can make a command and set command targets of another item it immediately becomes a two-way command. The command is available from the item where you write the command but also from the item that receives the command. (I tried tricks of making one not visible and other elaborate schemes but the software is too smart for this) I found I was getting extra button clicks coming from the destination object and I didn't like the way it played. I abandoned the idea of using command targets and set targets all back to "none". Basically I knew that I needed to make the input choices every time of items currently on the Player. I also knew that it would have to be done with some Lua coding.
I scanned tons of posts on this board to get me part way there. There is a Lua function Player:Contains() that you can use to check if the Player holds an item. You have to create unique item ID's and use these to see if Player actually holds the item. I made ID's for all of my items and eventually for the input also. With Lua you can build what Lua calls a table (actually an array) and assign it to the Input choices. The part I couldn't figure out after awhile was "How do I assign the table after I make it to the choices?".
The answer was incredibly simple, but I didn't understand how to get into the Lua code. It's simple. A package you store out of the Urwigo software in a .GWZ file is actually a .ZIP file. Rename the extension to .ZIP and then extract the package including the Lua code. (Windows XP complained about extracting the .ZIP file for some reason so I used 7-zip, an available .ZIP extractor.) I made a test cartridge where all I did is make an Input and saved it out. I unzipped it and voila, I had the code. The unique ID I used for the Input is actually used as the name of the Input object, so you just assign the table to this object's member called "Choices" and you have made your own Input on the fly. My id for the input is "iinput".
I think for my purposes I will make multiple Inputs, one for each item not on the Player, and run the code when the person playing chooses one of these items in the zone to interact with. Because normally in game play a person is going to look at something in the zone, and then decide at that moment how to interact with it using items in their inventory.
I'm posting the code from my Urwigo and the Lua code I found when I saved out my test cartridge as a .GWZ and extracted. I hope this helps others out there like me that are somewhat new at this.
As a final note, the Urwigo builder complained when I made choices in the Input that didn't line up with the event handler for that Input. So I put all possible choices in the Input of what the player can carry to begin with and on startup I run the code so that the player only originally has his "Trusty Pocket Knife".