Jump to content

Remove player from zone


IvoReikTeoViel

Recommended Posts

I am building a cartridge with lots of zones and levels. When a level is completed, all zones are deactivated. Then some zones will be reactivated during the next level.

 

Let's say the player is inside a zone when it is deactivated, then moves away from the deactivated zone. In another level, the zone is reactivated: Now it triggers the Exit code of the zone as if the Player is leaving the zone at this moment, which is not true. Is there a way to prevent this from happening? It will be complicated to make new zones every time they are to be activated, and also complicated to wait for the Player to leave the zone before deactivating it. If possible I would prefer not to use a lot of conditions for the execution of zone exit functions.

 

In a Wherigo reference I found a possible solution in removing zone from InsideOfZones table of the Player, but I didn't manage to get it to work:

Wherigo.Player._removeFromZone (zone) from the reference seems to have an odd syntax, but it returned an error message also when I tried some variants of the spelling, because it couldn't find the right field in the Player metatable: attempt to call field '_removeFromZone' (a nil value). Does anyone know whether this command/function is possible to use - and in case - how?

 

Is there a way to display all fields of the Player metatable and other metatables, and to display the field's values?

 

(I use Earwigo as my basic when I build)

 

Link to comment
5 hours ago, IvoReikTeoViel said:

Player metatable: attempt to call field '_removeFromZone' (a nil value). Does anyone know whether this command/function is possible to use - and in case - how?


That is likely a “private” function used by the Webwigo runtime. It isn’t likely to be callable (and definitely doesn’t exist within the apps’ runtimes.)

 

5 hours ago, IvoReikTeoViel said:

If possible I would prefer not to use a lot of conditions for the execution of zone exit functions.


You could store the current level in a global variable and compare against that when the exit event is fired. I don’t think that that is “a lot of conditions.”

Link to comment
23 minutes ago, Hügh said:

You could store the current level in a global variable and compare against that when the exit event is fired. I don’t think that that is “a lot of conditions.”

Thank you for the reply, Hügh!

The same zone will be activated and deactivated in several levels, and sometimes more than once in the same level. So after each level I will rather rewrite to "clean up" all but the zone the player is inside, and clean that one up in a conditioned zone exit.

 

It seems like my problem only exists when testing in Webwigo, not in the most used apps WhereYouGo and Wherigo. Maybe the function I mentioned is already internally/automaticlaly in use in the apps when turning off zones, and not incorporated in the Webwigo. So it looks like it resolves without doing anything :)

Link to comment

If you wanted a workaround, you could create a flag variable and a timer.  You can set the flag and start the timer prior to setting up the game board.  Any zone events fired during this time should be ignored by your code.  After the timer elapses, you can unset the flag, which will then enable zone events.  Perhaps something like that.

Link to comment
On 9/24/2023 at 10:09 AM, IvoReikTeoViel said:

So it looks like it resolves without doing anything :)

 

Oh, interesting, that is unexpected.

 

To give yet another solution, you could keep track of the active state of the zone separately, and only accept events if that flag is true. It means that you have to double up on the work of hiding a zone (hide it, and also set the flag).

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