Jump to content

URWIGO - Contains not working?


mcaddy

Recommended Posts

I'm trying to use the contains operator to evaluate if a user has an item in their inventory or if it is in a zone. It seems that it is not working.

 

I've attached a simple test cart that demos what I believe to be the problem

 

Cart starts and 'Item' is in User inventory

 

When user enters the 'zone' an 'On Entry' event checks to see if item is in the zone and raises a message if it is, the message is displayed even though the item is in the player inventory and not in the zone inventory.

 

Any thoughts?

Test.urwigo.txt

Edited by mcaddy
Link to comment

That's odd. I got the "Item here" message without modifying your cartridge.

 

Considering the player is within the zone and the item is within the player's inventory, it stands to reason the item is also within the zone. If you want to differentiate between the item being within the zone or the player's inventory, you can perform a check against that (test to see whether the player contains the item) before checking to see if the item is within the zone.

 

What I'm not certain about because I have little first-hand experience (or maybe I do from playing other cartridges, but it's tough to say for sure when you're not looking at those cartridges' source code) is whether all player apps from Garmin to iOS to WhereYouGo will follow that logic: if the zone contains the player, the zone also contains everything the player has. A few of us would have to verify something like this across all player apps. I'd suggest to err on the side of caution.

Link to comment

Considering the player is within the zone and the item is within the player's inventory, it stands to reason the item is also within the zone. If you want to differentiate between the item being within the zone or the player's inventory, you can perform a check against that (test to see whether the player contains the item) before checking to see if the item is within the zone.

 

Hmm, I guess that makes sense.

 

So for others that might stumble across this problem in the future

 

If I change the condition to ('Player' not contains 'Item') I get the correct logic, however it is a little imprecise as it will still fire if the player has left the item in another zone, as a result I needed to use ('Player' not contains 'Item' AND 'Zone' contains 'Item') to be sure it's in the zone and not the player.

 

Or for all possible cases a compound if as shown in attached image

post-985672-046357300 1463606162_thumb.png

Link to comment

Without seeing the LUA which Urwigo generates, it's hard to say what, if anything, might be wrong here. Under the hood, the various class implementations have methods for testing containment. Not sure if this information is still valid, but at one time:

 

Zone had its own method for testing to see if an object was contained in the zone. I think this one tested only for direct containment.

 

Zobject, which is the base class for ZItem and ZCharacter, had two methods which seemed to differentiate between item in item (letter in an envelope) and item in inventory (presumably of the player, although it probably works for other characters as well).

 

Details under the various class links here.

 

To me, this seems to imply that Urwigo should generate different method calls depending on the type of object on the left side of the contains test. But I haven't actually looked at the LUA, and I might be way off base anyway...

Edited by twolpert
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...