Jump to content

Testing for player inside zone fails after toggling zone active state


IvoReikTeoViel

Recommended Posts

I am using Earwigo trying to make a game with lots of zones and activities. Each activity usually starts in one specific zone, and crosses other zones which must be inactive during the ongoing activity, in order not to fire other OnEnterZone events.

After choosing an activity, the player has to move to the right zone (which now is turned active) before being able to start the chosen activity. If the player is already there, the Start button pops up immediately.

This works fine the first time the player enters or already is inside the zone.

But: If the player now aborts the activity,  making the zone turning inactive. Then reconsiders and choose the same activity again, already standing in the right zone. When the zone now again turns active, Wherigo returns a false value to my request whether Zone:Contains(Player) even though the player really is inside the zone.

 

Can someone explain to me why, and/or suggest a workaround?

 

I put together a sample zonecontainsplayer.txt showing my problem.

 

Without luck I have tried to remove an item before inactivating the zone, then giving it back to the player and ask if the zone now contains this item.

I have also tried to move the zone away from the player for a little while, and I have tried to wait for a timer to tick before giving my request, to assure all other commands were fully executed.

 

Since I am new to programming, I might very well have done some syntax errors, or simply not understood some important knowledge about Wherigos. Appreciate help :)

Link to comment

I haven't figured out why the Zone:Contains(Player) doesn't work as expected every time when the player actually is inside the zone. After the zone.Active state has been set to false and later toggled true again, still containing the player, the zone:Contains(Player) returns false:

 

function InsideZone(x)         --where x is referred to a specific zone

  if x:Contains(Player) then  --returns true only the first time the zone is set active, also triggering OnEnter event of the zone

 [do some action]

end end

 

Maybe this is a possible explanation: The Contains(Player) is set to false when the zone is made inactive, and turns true only after an OnEnter event. When the zone becomes active again, the OnEnter event is not triggered, because the player hasn't left the zone since last time (s)he entered.

 

 

 

Anyway: The workaround was easy when I got aware of the method IsPointInZone, which works fine regardless of changes to the zone.Active state:

 

function InsideZone(x)

if Wherigo.IsPointInZone(Player.ObjectLocation, x) then 

[do some action]

end end

 

 

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