Jump to content

Creating\Moving Zones in Play Anywhere Cartridges


trenkle

Recommended Posts

So I'd like to create a Play Anywhere cartridge with a handful of zones. Once the cartridge starts, I'd like the zones to be "moved" to near where the cartridge player is currently. Does the builder help me with this, or do I need to write a bunch of Lua?

 

It appears I have to specify a Play Anywhere cartridge, so it would be cool if my zones in such a cartridge could use "relative" positioning rather than "absolute" as it appears they do now.

 

-trenkle

Link to comment

Creating "Play Anywhere" cartridges is considered an "advanced" topic (for more than one reason), so while it *can* be done in the Builder, it is not something that the Builder goes out of its way to make easy. So, yes, you will need to write some Lua script to make a Play Anywhere cart. You are on the right track, however, in defining your zones at design-time and then "moving" the zones at run-time to where the user is.

 

-peter

Link to comment

I took your (trenkle) comment as a challenge ;) and I created a bit of script code that can be added to pretty much any cartridge to turn it into a "Play Anywhere" cartridge. Before I talk a bit about how to use it, please note that this technique is NOT Groundspeak supported and not something I am guaranteeing to work for everyone (or anyone, really...). It is something of a hack, it has been very minimally tested, and may cause a singularity to open up in your vicinity that destroys the universe as we know it. You've been warned. ;)

 

The basic idea here is that you create a regular, location-specific cartridge using the builder. You put in all your zones and characters and items and whatnot. You test it in the Emulator. You go outside and test it. You feed it to your dog and see if he likes it. When you're satisfied that it is ready, you open up the script for your cartridge, copy my code into the end of your cartridge, and set a single coordinate that acts as the "reference point" for all the existing zones, objects, etc, and then re-build the cartridge and now it is a "Play Anywhere" cartridge. It works by translating all the points in your cartridge to the location where the user plays it, using the reference point you set as the player's relative starting point. Please see the readme.txt in the zip file for usage details.

 

A few things to note about this: Besides being totally unsupported (beyond what I am able to provide in these forums), this method of creating a "Play Anywhere" cartridge is not how the Wherigo Tutorial cartridge does it. The Tutorial uses "dynamic zones" and other advanced concepts that is the topic for another day in another thread. This method currently triggers a Builder bug that may make your script un-editable in the Builder after you paste my code in to it. The bug has been noted and hopefully will be fixed soon. Oh, and did I mention that this method is not official and is not supported? Good.

 

So, have fun with this. Please _do_ give me feedback if you use this or make use of parts of it, or don't ever touch it but think it might be cool to create a singularity in your neighborhood.

 

Cheers,

-peter

MakeLocationless.zip

Link to comment

peter,

 

you'll probably notice I used the tutorial sample lua file Jeremy posted to learn how to do the Play Anywhere dynamic zones before you posted your script file. It actually wasn't as hard as I was expecting and the builder still was able to open my hand-modified lua file.

 

My original attempt was to use your GetZonePoints function to move each zone near my current location when the cartridge started. In my player, this didn't work though because I was trying to use an offset of Player.ObjectLocation, which apparently wasn't set yet.

 

My workaround was to fire a short countdown timer upon starting the cartridge. When the timer tick fires, I move the zone. This bought the device enough time to have Player.ObjectLocation set to my current location.

 

I did see in your Lua file where you use Player.RefreshLocation(). I thought about trying that at cartridge start, but figured my workaround was good enough, so why bother!

 

-trenkle

Link to comment

My workaround was to fire a short countdown timer upon starting the cartridge. When the timer tick fires, I move the zone. This bought the device enough time to have Player.ObjectLocation set to my current location.

 

There's one gotcha that we dealt with in the tutorial you will want to make sure you check. When you wear the spacesuit in the tutorial it checks to make sure that the latest GPS signal quality is good enough to create the starting zone. If you don't do this on the Colorado it will always assume that the current coordinate on the device is your current location even if you don't have signal. That can result in having your zones created miles - if not thousands of miles - from your current location.

Link to comment

you'll probably notice I used the tutorial sample lua file Jeremy posted to learn how to do the Play Anywhere dynamic zones before you posted your script file. It actually wasn't as hard as I was expecting and the builder still was able to open my hand-modified lua file.

 

My original attempt was to use your GetZonePoints function to move each zone near my current location when the cartridge started. In my player, this didn't work though because I was trying to use an offset of Player.ObjectLocation, which apparently wasn't set yet.

 

My workaround was to fire a short countdown timer upon starting the cartridge. When the timer tick fires, I move the zone. This bought the device enough time to have Player.ObjectLocation set to my current location.

 

I did see in your Lua file where you use Player.RefreshLocation(). I thought about trying that at cartridge start, but figured my workaround was good enough, so why bother!

 

I am glad to hear that you found a solution that works for you. That is one of my favourite aspects of having Lua as the base scripting launguage for Wherigo; there are many ways to solve a problem, and if one way doesn't make sense or doesn't work for your specific problem, another way most likely will.

 

As for the small issue you mentioned, that is why both the Wherigo Tutorial and the technique I posted above both wait for some sort of action/input from the user before attempting to create or move the zone(s) to current location. By waiting (either for action from the user, or with a timer as you did), you give the device a chance to ensure that the location information is accurate and up to date.

 

-peter

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