Jump to content

Creating a Plays Anywhere catridge


trenkle

Recommended Posts

I received questions from various cartridge authors on how to make a Plays Anywhere cartridge. Not only is the process not well defined, it also isn't supported by the current Builder (as of March 22, 2008), so enter at your own risk. I've used a relatively simple recipe twice now, with some success.

 

Please remember, I'm not a lua expert nor a Wherigo expert, just a hobbyist that likes to tinker. But, if you'd like to know how I've gotten around the current Builder to create Plays Anywhere experiences, read on...(download my source for Vegas Riddle and Anywhere Egg Hunt for references)

 

1. Get your cartridge completely written to play well start-to-finish at one location (your home park). Eventually, you'll do some manual authoring of the Lua file, and once you've done that, you risk the Builder not understanding your changes, so get as much out of the builder to begin with as possible.

 

2. Add a countdown timer, call it RepositionZones, duration 2 seconds (or similar). Make sure to start this timer when the cartridge starts. Add an event for when the Timer Tick event occurs. You can leave the event empty for now (but this is where you'll add your special code to relocate zones to the current player's location when you convert the cartridge to a Plays Anywhere variety).

 

3. Save this cartridge in the Builder. From this point forward, you will be using a text editor rather than the builder, because it is all hand coding. Download the source of either of my play anywhere cartridges to follow the remaining steps. ALWAYS CREATE BACKUPS WHEN HAND EDITING....YOU WILL PROBABLY NEED THEM AT SOME POINT (experience has taught me this!)

 

4. Open your *.lua file in a text editor (Notepad would work). Near the bottom of the file you'll find a line that says "Author Functions Go Here". You'll see in my lua files I've added a GetZonePoints function that creates and returns an octogon-shaped zone of particular radius around a given point. Feel free to borrow this for your own use if you'd like.

 

5. In your ztimerRepositionZones:OnTick() function, add code to move each zone from its original location to a new location, using this new GetZonesPoints author-defined function. See either of my sample cartridges for how to do this. The Vegas Riddle cartridge is easier to follow as Anywhere Egg Hunt uses a random number generator (so its just a little more complex). Anything with a location will likely need to be relocated. Note, if you do use the random generator, don't forget to add 'Require "math"' at the top of the Lua file.

 

6. The final key ingredient for creating a Plays Anywhere cartridge is to set the starting point of the cartridge to Wherigo.INVALID_ZONEPOINT. You should see a line such as "cartEggHunt.StartingLocation = XXX". Change XXX to Wherigo.INVALID_ZONEPOINT.

 

7. You can now save your changes. Once you've hand-edited your .lua file, you likely won't be able to use the builder with much success. You can open the Builder, NOT open your lua file, but instead "Compile a Cartridge..." from the Tools menu. Alternatively, you can open your Lua file and "Publish Cartridge..." to the web, just DO NOT try to edit it (or save it) from the Builder...the Builder's parser will likely choke and corrupt your Lua file.

Link to comment

Another tip...put as much as you can in the Author functions. It appears that builder doesn't mess with that area. However, Builder still has a problem when referencing string or numerical values and puts quotes where you don't want them to be. So in my lua code, I placed the following line to do the zone re-map...

 

if action == "Button2" then

Wherigo.MessageBox{Text=[[You've enable cache mode. This is tied to cache GCxxxx.]],}

else

x = "ReassignZones()"

end

end

...

 

-- #Author Functions Go Here# --

 

function ReassignZones()

local dist = Wherigo.Distance(50, 'ft')

zoneStart.Points = GetZonePoints(Player.ObjectLocation, dist)

...

 

I pretty much do the same things Trenkle does (got my start in his Vegas Riddle cart), but I put the main block of the zone reassignment code in a function called ReassignZones. You pass no parameters and although I put an 'x=ReassignZones()' in the code, 'x' doesn't do anything other than make Builder happy...why? Cause it can 'parse' it. Having just ReassignZones() sitting there without the 'x=' will work if you do the compile without loading it into builder; otherwise Builder will complain and not load and/or save your .lua file correctly.

 

However, note the quotation marks that Builder puts on

x="ReassignZones()"

you'll need to change it in the lua file manually outside of Builder to

x=ReassignZones()

You can't help that...Builder just does it. You'll have to take the quotes off for the function to get called. But the plus side is that you can still do editing and tweaks in Builder without upsetting builder. When you are done, then remove the quotes.

 

Let me reiterate one point in my last message about the timer and Wherigo.INVALID_ZONEPOINT. When you make the cart location equal to Wherigo.INVALID_ZONEPOINT, the emulator pops up a dialog box of where you want to start. This didn't work well, at least for me. I end up in London at 0 lat and 0 lon. If you just leave it alone, it seems to work just fine in the Emulator. Sure it will start you where you originally defined it, but then you just move the virtual player to where ever, and then use the button script to select the original zone or zone based on current location, (Anywhere). So, while you develop you code and make your changes, the worst thing that builder will do is put quotes around "ReassignZones". You can still save and edit in builder, and emulate your changes. When it comes time to re-publish, then remove the quotes and all will be good.

Link to comment

I've had several requests recently for me to send source files for my play anywhere concepts. It may not be known to all, but if the author of a cartridge allows it through the CC license, they can make source available for download on the cartridge page.

 

For instance, on the Anywhere Egg Hunt Page, http://www.Wherigo.com/cartridge/details.a...21-553379232d3e, you should see a "Download Source" link near the bottom of the left hand column (below "Attributes").

 

Feel free to download the source and explore.

 

trenkle

Link to comment

I've had several requests recently for me to send source files for my play anywhere concepts. It may not be known to all, but if the author of a cartridge allows it through the CC license, they can make source available for download on the cartridge page.

 

Thanks for that! I was just missing one point (setting the cartridge start point to INVALID_ZONEPOINT) to make my builder able to generate Play Anywhere cartridges with a single click.

 

I had hoped to be able to do all the relocation of zones, characters, and items in cartridge:OnStart(), but it seems that when that is called, the player's coordinates aren't set up yet. So I've used the 2-second timer trick with a special OnTick routine which moves all of the zones, characters, and items.

 

It seems that for a zone, it's sufficient to rebuild the Points{} table (or change each element). OriginalPoint doesn't seem to need changing. In fact I wonder what OriginalPoint does for a zone anyway, other than to serve as a central point for the builder to create squares around.

Link to comment

I've been working on my Pick-a-Path game and would like to make it playable anywhere. It would have 13 endings so the replay value is awesome! Once I finish it, could someone with more experience try to hand edit the text file to make the zones play anywhere?

 

I plan on using it for a Wherigo geocache but edit the same file to play anywhere but not to include the geocache location.

Link to comment

I make some PlayAnywhere cartridges. Here's how I start. Make a new cartridge. Starting point is any set of given coordinates. I tell it N37*40' and W97*20' just to put it somewhere I'm familiar with. Then I make a few functions with the Builder. When the cartridge is started, say a message and the message is "Test". That makes an OnStart function written out. When the cartridge is resumed, same thing to create an OnResume function. When the cartridge is closed, same thing to create an OnSync function. The content is not important right now. I just want the Builder to type it out in the file so I don't mess it up by using a period instead of a colon or something easy to confuse like that. Then save the cartridge. Now I can open up the Lua text file with a text editor and change some things. Change the location to Wherigo.INVALID_ZONEPOINT and the cartridge becomes a PlayAnywhere. Since the OnStart function is already written, I can edit it to do whatever I really want it to do. Say an introductory Hello and when the player hits the Hi button, a character explains what is going on and at the end of the explanation, the player is told that when the player is ready, the zones will be relocated to the player's current position, not necessarily in those words, but that's what happens zone-wise.

 

I can still open my cartridges with the Builder and do some editing with it, like add media, create items, make zones. I just can no longer hit that OK button if I want to edit stuff in the CARTRIDGE window. I can't hit OK because the Builder wants me to enter some start coordinates for the cartridge. THAT is why I made the OnStart function earlier, because now I can't.

 

I use the Builder to create chunks of text in the Lua file that I don't want to hand type, like zone definitions, button definitions for items, adding new media, entering the format for a CallBack Script that happens after the player sees a message box and pushes a button, stuff like that. Otherwise, I type it out in the Author Functions. Often I'll take the functions from the Builder Functions area and move it over to the Author functions area so I can see it easier in my mess of functions. I often change the CallBack numbers so I can add in a new message in the middle of a chain of messages; they don't have to be in numeric order; CB1 can call CB50 and CB50 can call CB2.

 

The writing for these can be started in the Builder and changed later on in a text editor. The Builder CAN be used to edit your Lua file AFTER you make the Wherigo.INVALID_ZONEPOINT change. It just has a few limitations that it won't do afterwards.

 

Start with the Builder. Do the Wherigo.INVALID_ZONEPOINT thing. Edit with the Builder and also with a text editor. Save. Save. Save. Open your .LUA file with the Builder and go to << TOOLS | Publish to My Machine >> to make a file that can be run with the Wherigo Builder's Emulator so you can test out your PlayAnywhere cartridge. When it asks if you want to specify a starting point, the answer doesn't matter; I say no and it picks a default spot. I run through playing the cartridge and look for places that I want to change. Then I make changes either with the Builder or with a text editor. Then I tell the Builder to reopen that Lua file, reprocess to My Machine, and rerun with the Emulator so I can see if my changes worked...then retweek some more.

Link to comment

Or, use Earwigo and turn any cartridge into "Play Anywhere" by checking a box. :laughing:

 

Actually, since Earwigo can read more or less any existing Lua file which comes directly from the Groundspeak Builder, I guess that means that Earwigo can be used simply as a "Play Anywhere Generator". It would be a shame to only use that functionality, but it ought to work.

Edited by sTeamTraen
Link to comment

Or, use Earwigo and turn any cartridge into "Play Anywhere" by checking a box. :D

 

Actually, since Earwigo can read more or less any existing Lua file which comes directly from the Groundspeak Builder, I guess that means that Earwigo can be used simply as a "Play Anywhere Generator". It would be a shame to only use that functionality, but it ought to work.

 

Using Earwigo where do I find the "Play Anywhere" to make the change? I have not found it yet....

Link to comment

Or, use Earwigo and turn any cartridge into "Play Anywhere" by checking a box. :laughing:

 

Actually, since Earwigo can read more or less any existing Lua file which comes directly from the Groundspeak Builder, I guess that means that Earwigo can be used simply as a "Play Anywhere Generator". It would be a shame to only use that functionality, but it ought to work.

How do I get "Earwigo"??

Link to comment
On 6/13/2010 at 1:23 PM, cantuland said:

When it asks if you want to specify a starting point, the answer doesn't matter; I say no and it picks a default spot. I run through playing the cartridge and look for places that I want to change.

I built a Play Anywhere Wherigo with Urwigo. I would like to make it possible to end to a Physical Geocache near my home location.  Can anyone guide me through in order to make it possible to enter a location near my home?

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