Jump to content

Grab an Object Question


Where I Go Again

Recommended Posts

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.

Link to comment

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

Link to comment

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. :laughing:

 

-peter

Link to comment

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 by delta123
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...