Where I Go Again Posted January 13, 2008 Share Posted January 13, 2008 How do I do the following: You start out with an item in your inventory - a book. You can open and read the book. (No problems coding this) You meet a character along your travels. After talking to him, he grabs the book from you and transports it to another location (no problem coding this) Now, here's the problem, when you stumble across the book again. The only options are open and read. I would like to disable these option until you grab the book. How do I code for it? Thanks, CJ This is a repost - I'm getting fatal error on the system every time I attempt a post. Sorry about the doubling up. Quote Link to comment
Where I Go Again Posted January 13, 2008 Author Share Posted January 13, 2008 Just an addition to the above, Currently, I'm just the code from the example BOOK code listed in the forums. If the player does not contain item, move item to player else show a message, "You already have item" I was hoping for a more elegant solution where the ACTION of grab book appears if the don't have the book. Thanks, CJ Quote Link to comment
Where I Go Again Posted January 14, 2008 Author Share Posted January 14, 2008 A few hours later and I figured it out. When the player enters the start zone, I can turn the object command off aka make it false. Object:Grab enabled false Wow this software is cool. And fun to play around with. CJ Quote Link to comment
+GeoGern Posted January 14, 2008 Share Posted January 14, 2008 I am glad that you figured it out, CJ. The Book example that I posted in another thread was, necessarily, very simple so that it didn't confuse by adding too much detail or functionality. But what you've discovered is that there is a much better way (IMHO) of handling "invalid" commands. Rather than always having a command (like "Grab") enabled on an item like the Book, it makes much more sense to only have it enabled (and visible to the user) when it makes sense to allow the user to invoke the action. So, yes, the object commands have the ability to be enabled and disabled. When they are enabled, they show up in the UI for the user to select, and then they are disabled, they are hidden in the UI and the user cannot select them. This means that rather than having script in the zitemBook:OnGrab() event that checks whether or not the book is already in the user's inventory, I can, for example, start the book in the user's inventory and have the Grab command disabled (zitemBook.Commands.Grab.Enabled = false). Then, when they "drop" the book or "give" the book to another character, I would enable the book's Grab command (zitemBook.Commands.Grab.Enabled = true) in the script code that "moves" the book in to the inventory of the new location/character. Keep playing around and enjoying the experience of discovering what it possible with Wherigo. -peter Quote Link to comment
delta123 Posted February 8, 2008 Share Posted February 8, 2008 (edited) I was struggeling with this but found the explanation here, Thanks. When will there be a bit more documentation? EDIT: after implementing this i keep getting errors when i change from true to false 9attempt to indexx field xxx (a nil value) Edited February 8, 2008 by delta123 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.