Jump to content

a_snail

Members
  • Posts

    145
  • Joined

  • Last visited

Posts posted by a_snail

  1. If I remember correctly, you'll have to require math at the top of your author functions.

     

    Once you have a few programming languages under your belt, it gets easier to learn another because you already know how to write your thoughts in code.

     

    I'd advise you to take a look at some of the open source Wherigo cartridges. To find out if a cartridge is open source, go to the cartridge's listing page on the Wherigo.com site. If you see the Creative Commons logo and a link to download the source on the left side, it's open source. You can learn a lot about Wherigo and how things work by looking at open source cartridges and playing them through in the emulator.

     

    Good luck on your project. Feel free to ask the forum for any clarifications you might need.

     

    I thought I better test it before posting the code, and it does work, so I'm guessing somehow all the standard libraries like the maths one get included. Thats not to say the standard libraries will work correctly on all machines, for instance the IO (input output) library for file access does not work on Garmins, but does work in the emulator.

     

    True about programming languages, the slowest bit is looking up the syntax for the language you happend to be using at the moment. I kind of like Lua - easy going sort of language, although thats not always a good thing when your trying to work out whats gone wrong.

     

    Ranger Fox's Wack-a-lacky was the main one I looked through and adapted ideas - contains a bit of most things. Ranger Fox, is there a list anywhere of downloadable cartridges? Its always good to see what and how other people have done things and find out querks of the language.

  2. Hi thanks for your responses. What I want to create is a Wherigo based around a board game style game. I have zones mapped out for the squares of the board.

    I do have a little programming knowledge, at school I've done a little java, php, html, flash. not sure if lua is like any of those. Making this Wherigo is actually the final project I chose for my computers class at school, so I dont mind doing some raw coding, is there a tutorial for it?

    So what I would like to happen is when the player rolls the dice a number is generated. Then I can call that number to add to the numbered space they are on to activate the proper zones for them to travel to next. There will be tasks or questions at the squares that determine if the player moves backwards or forwards, so if they get the question right, they move forwards, if they get it wrong they move backwards.

     

    Not having done any of those languages I'm not sure how similar they are, but generally a programing language is a programming language, each one has slighly different syntax and benifits for using it, so you should be fine. So Author script it is :mad:

     

    Like I said earlier, you need to initialise the randomness, so in the example below, I've put that in the OK button for the Welcome message.

     

    For generating the random number, I've put that in a custom button for the Dice object and then display the results in a message box so that you can see the result.

     

    The example shows a number of techniques including putting numeric values into a builder variable, accessing a builder variable and putting it a message box and of course the random stuff.

     

    Have fun, and make sure you know what and why I've done what I've done incase you get asked for your assignment :huh:

     

     

    :blink::huh::D

    require "Wherigo"

    ZonePoint = Wherigo.ZonePoint

    Distance = Wherigo.Distance

    Player = Wherigo.Player

     

    -- #Author Directives Go Here# --

    -- #End Author Directives# --

     

    carttest = Wherigo.ZCartridge()

     

    -- MessageBox Callback Functions Table used by the Builder --

    carttest.MsgBoxCBFuncs = {}

     

    -- Cartridge Info --

    carttest.Id="5e372135-660b-476a-9264-9cc703e89b4e"

    carttest.Name="test"

    carttest.Description=[[]]

    carttest.Visible=true

    carttest.Activity="TourGuide"

    carttest.StartingLocationDescription=[[]]

    carttest.StartingLocation = ZonePoint(52,-2,0)

    carttest.Version=""

    carttest.Company=""

    carttest.Author=""

    carttest.BuilderVersion="2.0.5129.5086"

    carttest.CreateDate="5/13/2009 6:03:55 PM"

    carttest.PublishDate="1/1/0001 12:00:00 AM"

    carttest.UpdateDate="5/13/2009 6:23:17 PM"

    carttest.LastPlayedDate="1/1/0001 12:00:00 AM"

    carttest.TargetDevice="PocketPC"

    carttest.TargetDeviceVersion="0"

    carttest.StateId="1"

    carttest.CountryId="2"

    carttest.Complete=false

    carttest.UseLogging=false

     

    -- Zones --

    zoneAZone = Wherigo.Zone(carttest)

    zoneAZone.Id="8fe2e2d9-e550-482d-951f-e33e988da2a3"

    zoneAZone.Name="AZone"

    zoneAZone.Description=[[]]

    zoneAZone.Visible=true

    zoneAZone.DistanceRange = Distance(-1, "feet")

    zoneAZone.ShowObjects="Always"

    zoneAZone.ProximityRange = Distance(-1, "feet")

    zoneAZone.AllowSetPositionTo=false

    zoneAZone.Active=true

    zoneAZone.Points = {

    ZonePoint(52,-2.00001,0),

    ZonePoint(52,-1.99999,0),

    ZonePoint(52,-1.99999,0),

    ZonePoint(52,-2.00001,0)

    }

    zoneAZone.OriginalPoint = ZonePoint(52,-2,0)

    zoneAZone.DistanceRangeUOM = "Feet"

    zoneAZone.ProximityRangeUOM = "Feet"

    zoneAZone.OutOfRangeName = ""

    zoneAZone.InRangeName = ""

     

    -- Characters --

     

    -- Items --

    zitemDice = Wherigo.ZItem{Cartridge=carttest, Container=zoneAZone}

    zitemDice.Id="9ef7982b-1af2-462a-be17-8aaa25f19f58"

    zitemDice.Name="Dice"

    zitemDice.Description=[[]]

    zitemDice.Visible=true

    zitemDice.ObjectLocation = ZonePoint(51,-2.00000000181663,360)

    zitemDice.Locked = false

    zitemDice.Opened = false

    zitemDice.Commands = {

    RollDice = Wherigo.ZCommand{Text="Roll Dice", CmdWith=false, Enabled=true, EmptyTargetListText="Nothing available"},

    }

    zitemDice.Commands.RollDice.Custom = true

    zitemDice.Commands.RollDice.Id="8b1214bd-2711-4ffc-bf7d-0784e8c1b19b"

    zitemDice.Commands.RollDice.WorksWithAll = true

     

    -- Tasks --

     

    -- Cartridge Variables --

    DiceValue = 0

    carttest.ZVariables = {DiceValue = 0}

     

    -- Builder Variables (to be read by the builder only) --

    buildervar = {}

    buildervar.DiceValue = {}

    buildervar.DiceValue.Id ="c644c588-6676-48b5-97aa-6da4914713d2"

    buildervar.DiceValue.Name = "DiceValue"

    buildervar.DiceValue.Type = "Number"

    buildervar.DiceValue.Data=[[0]]

    buildervar.DiceValue.Description=[[]]

     

    -- ZTimers --

     

    -- Inputs --

     

    --

    -- Events/Conditions/Actions --

    --

     

    -------------------------------------------------------------------------------

    ------Builder Generated functions, Do not Edit, this will be overwritten------

    -------------------------------------------------------------------------------

     

    function carttest:OnStart()

    -- #GroupDescription=Welcome and initialisation --

    -- #Comment=Welcome and initialisation Comment --

    Wherigo.MessageBox{Text=[[Welcome to the .... game]],Buttons={"OK",},Callback=carttest.MsgBoxCBFuncs.MsgBoxCB1}

    end

     

    function zitemDice:OnRollDice()

    -- #GroupDescription=Roll that dice --

    -- #Comment=Roll that dice Comment --

    buildervar.DiceValue.Data = tostring(math.random(6))

    Wherigo.MessageBox{Text=[[You rolled ]]..buildervar.DiceValue.Data,}

    end

    ------End Builder Generated functions, Do not Edit, this will be overwritten------

    -------------------------------------------------------------------------------

    ------Builder Generated callbacks, Do not Edit, this will be overwritten------

    -------------------------------------------------------------------------------

    --#LASTCALLBACKKEY=0#--

    ------End Builder Generated callbacks, Do not Edit, this will be overwritten------

    -- #Author Functions Go Here# --

    carttest.MsgBoxCBFuncs.MsgBoxCB1 = function(action)

    if action ~= nil then

    -- #GroupDescription=initialise stuff here --

    -- #Comment=initialise stuff here Comment --

    math.randomseed( os.time() )

    end

     

    end

    -- #End Author Functions# --

    -- Nothing after this line --

    return carttest

    ;):):)

  3. Some of the other developers, more experienced than I, will probably chime in here shortly.

     

    I am sure there must be a random number generating function in the Lua language. There is no prewritten capability in the Builder. So you will need to do it in Author Script and call it from the program.

     

    roll=math.random(6)

     

    is the thing your after, but Tequila is correct, you will need to use Author Script and may be a little advanced if your only just starting to create Wherigos, and you don't have any computer programming knowledge.

     

    If you do want to give it a go, its a function call rather than an event and can be called anywhere. The trouble is if you use it, then the function its in will no longer be editable in the builder.

     

    Perhaps if you can give me an example of when you want to generate a random number, I can suggest minimising the effect on your Wherigo. I will probably suggest some sort of messagebox is displayed and when you press the OK button, the value is stored in a variable. Then you can use it when ever you want.

     

    Oops, nearly forgot to say, computers arn't random, you will always get the same random numbers using the above, you need to initialise the randomness by using something like:

     

    math.randomseed( os.time() )

     

    although for testing, having a repeatable sequence of random numbers can be very useful.

  4. The Oregon responds very slowly if too much stuff is happening. In the above example, if the Oregon can not complete all its stuff in a second, I have found it do one of the following things

    a. crashing

    b. processing the next set of events for the timer

    c. drawing the screen

     

    ...

     

    The way to sort this out is to lengthen the time interval, and give the Oregon more time to process your timer event. People don't tend to walk very fast, so checking every 5seconds should suffice for most things.

    Ah, but you fail to notice the brilliance behind using a countdown timer! Once the countdown expires, the timer does not begin anew! The last thing the function does is restart the timer. Therefore, the function can take as long as needed to process before the timer is started once more.

     

    Despite the novelty of this approach, I did this sort of thing when I was experimenting with the ZoneMover class--that is, using countdown instead of interval timers. Even so, it slowed the Oregon. I wonder if that GPSr is the eMachine of its category--seems good to the layman, but certain corners were cut to make it more affordable.

     

    Yes, restarting the timer each time is a very good way to get round it. Either way, the Oregon does need its breathing space, and display is the last thing it does. It is also the reason why you can't have any more than 9 (preferably 6) active zones on the Oregon at the same time otherwise things start grinding to a holt when its spending all its time working out if your in a zone or proximity or not and not responding to buttons.

  5. I have attached a sample cartridge of what you asked. Move David into the zone. For demonstration purposes, this will start two timers. Now, move David outside the zone to anywhere you want. When you get more than 100 feet away, a message box will tell you. After five seconds have elapsed, another message box will tell you your current distance from the zone.

     

    What I'm doing is not visible in the Builder; you'll have to see the lua code towards the bottom.

     

    You'll note in the code I'm using one of the zone's edge points and not the center. If you move a zone, the OriginalPoint property, as far as I remember, will not be correct. Hence my decision to use one of the zone's points.

     

    a_snail is right in using the "Wherigo.VectorToPoint" function call. The value won't be negative because in 3D space you cannot get a negative distance away from a point. "d2(m)" will give you the measurement in whatever format you want; the example here is in meters. In my code, I give you both meters and feet.

     

    -----

     

    Now, on to explaining what I did to get you what you wanted. I chose to implement a countdown timer with a duration of one second. When you enter the zone, the timer is started. Every second, it will measure your player's distance from the zone. If it's less than one hundred feet, it will start the timer again. If not, it'll display a message box (which you could change to a function call). I used a countdown timer instead of an interval timer because "ztimerDistant:Stop()" would not actually stop an interval timer (which is odd).

     

    Now, a word of caution. I would strongly suggest you test anything using timers on an Oregon before you release the cartridge the public. I had a problem on one of my cartridges where, with a timer running in the background and zone measurements going on, dialog boxes (among other things) on the Oregon took a minute or so to display.

     

    If you have any other questions, feel free to ask them. Quite a few people here are knowledgeable enough to assist you. Good luck and have fun!

     

    Ah, you had that problem as well with the timer not stopping as well. Good to know it not just me having problems. The Oregon responds very slowely if too much stuff is happening. In the above example, if the Oregon can not complete all its stuff in a second, I have found it do one of the following things

    a. crashing

    b. processing the next set of events for the timer

    c. drawing the screen

     

    The order reflects the load i.e. if there is very little processing, option c is done i.e. draw the screen. If more processing needs to be done, the Oregon preferes to do the next batch of processing over drawing the screen. Finally, if you try and do too much, crash.

     

    The way to sort this out is to lengthen the time interval, and give the Oregon more time to process your timer event. People don't tend to walk very fast, so checking every 5seconds should suffice for most things.

  6. I need to trigger an event when the player gets a certain distance away from his current location, and there doesn't seem to be anything I can use in the interface. How can I retrieve coordinates from the GPS device? Would a negative number in the "distance range" box have the desired effect?

     

    Your best bet if you want to keep it simple is to have another zone (invisible) that extends up to the distance your interested in. The exit zone code will trigger when you reach the appropreate distance.

     

    For the brave, you can get the players location (Player.ObjectLoctaion) and distance from the player to an object (probably zone, but need to test that), but that involves Author code (see below). You could have a timer and make this check every time interval e.g. second.

     

    local d2,b2 = Wherigo.VectorToPoint(zcharacterSammy.ObjectLocation,Player.ObjectLocation)

    local distance = d2(m)

     

    Hope that helps

  7. One of the first emails I got from Ranger Fox suggested that I would reach a point where I would drift away from the Builder and start developing code in the text editor. :anitongue:

     

    Not only is R/F one helluva Wherigo illuminati, he is also a bit of a prophet. LOL

    One of the design goals of Earwigo was to allow you to include arbitrary Lua code inline without having to abandon the point-and-click builder for the easy bits. Using a text editor is fine for code but not so much fun for regular data declarations.

     

    I think its the cut and paste I like so much with the text editor :) and the fact that I can save the lua file in the text editor, load and run the script in the builder, find its taken out the builder or emulator and just undo the changes with out loosing all my work.

  8. Thanks. Those are great ideas.

     

    A friend also includes "easter eggs" in his code. He always has a " secret sequence of event" the player can easily do if they need to get a cartridge marked "complete.

     

    In the past I've used a configuration tablet which has all sort of customisations on it, and then I just mark as invisible if I don't want people to use it.

     

    That said, I've stopped putting in preventions, as long as people enjoy the Wherigo that is sufficient for me, if they want to dry run it in the emulator first before taking the kids out, I'm not too bothered (apart from the initial first to find). My aim these days is to make it fun and something people want to play, and for the game to be slightly random, so even if they have pre-played, its still a challange when they play for real. Also I have no objection to people who have no chance of ever getting to the UK playing in the emulator and getting ideas for their own games. Anyway, enough of that for now, probably should be in a different thread.

  9. Thank you. That is exactly what I want.

     

    I assume you created the CheckCartridgeIsOKToPlay() call in the OnStart function with a text editor and not the Builder. Is that correct?

     

    Also, once I open the source in the Builder, I am able to open the OnStart code (it appears in red). Can I add code to it in the Builder?

     

    Thanks gain.

     

    Yes, I did use a text editor to add in the function into OnStart (I have to confess, I use the text editor for 95% of my building these days). Once the call to the function is in place, you will only be able to modify the source code directly (although you can do that in the builder), the builder will no longer help you construct the code, which is why I suggested putting that sort of call in a MessageBox button function earlier. Let me know if you need a demo of that.

  10. To answer R/F's question, I was able to finally get the first sample working by putting the code in a function. However, I had to use the OnStart for the cartridge which meant I could not have an OnStart function in the normal builder code.

     

    I got both of the above samples to work the same way.

     

    While this works, it is not quite what I was hoping to be able to use.

     

    I was hoping to have a bunch of code in the Author Script that I could cut/paste into every cartridge that I develop without having to rewrite/modify the code each time. In the above case, the function OnStart has to be modified to account for the different cartridge name. Perhaps this is the best I can get.

     

    As you can no doubt see, my programming skills are pretty limited. :D

     

    Back to R/F's comment: If I call the function something other than OnStart, how would I call it from the Builder?

     

    Thanks for all your help AND patience. :anicute:

     

     

    The example below might be what your after. If you want to just copy it to a load of cartridges, what you would do is copy the function in the author code, and then wherever you want to do a check, add in the line:

    CheckCartridgeIsOKToPlay()

     

    In the example below I've put it in OnStart, but it can go anywhere. The problem you are going to have is that the builder will not like any function with the CheckCartridgeIsOKToPlay() in it because its not something it knows about, so it will show it in author code. The best way to get round this I've found is to put it in a out of the way bit of Wherigo i.e the only thing that function is going to do is call CheckCartridgeIsOKToPlay e.g.

    1. In response to a message box button been pressed (eg. as part of the welcome message)

    2. as part of a timer event, although be careful about this one in case other things are happening and canel your message.

     

    Example Lua:

     

    :laughing::anibad::blink:

    require "Wherigo"

    ZonePoint = Wherigo.ZonePoint

    Distance = Wherigo.Distance

    Player = Wherigo.Player

     

    -- #Author Directives Go Here# --

    -- #End Author Directives# --

     

    cartcheck = Wherigo.ZCartridge()

     

    -- MessageBox Callback Functions Table used by the Builder --

    cartcheck.MsgBoxCBFuncs = {}

     

    -- Cartridge Info --

    cartcheck.Id="8eacdb25-4bea-4dac-bb08-9dcefd610c60"

    cartcheck.Name="check"

    cartcheck.Description=[[]]

    cartcheck.Visible=true

    cartcheck.Activity="TourGuide"

    cartcheck.StartingLocationDescription=[[]]

    cartcheck.StartingLocation = ZonePoint(51,-2,0)

    cartcheck.Version=""

    cartcheck.Company=""

    cartcheck.Author=""

    cartcheck.BuilderVersion="2.0.5129.5086"

    cartcheck.CreateDate="5/10/2009 7:24:58 AM"

    cartcheck.PublishDate="1/1/0001 12:00:00 AM"

    cartcheck.UpdateDate="5/10/2009 12:28:07 PM"

    cartcheck.LastPlayedDate="1/1/0001 12:00:00 AM"

    cartcheck.TargetDevice="PocketPC"

    cartcheck.TargetDeviceVersion="0"

    cartcheck.StateId="1"

    cartcheck.CountryId="2"

    cartcheck.Complete=false

    cartcheck.UseLogging=false

     

    -- Zones --

     

    -- Characters --

     

    -- Items --

     

    -- Tasks --

     

    -- Cartridge Variables --

    -- Builder Variables (to be read by the builder only) --

    buildervar = {}

    -- ZTimers --

     

    -- Inputs --

     

    --

    -- Events/Conditions/Actions --

    --

     

    -------------------------------------------------------------------------------

    ------Builder Generated functions, Do not Edit, this will be overwritten------

    -------------------------------------------------------------------------------

     

    function cartcheck:OnStart()

    CheckCartridgeIsOKToPlay()

     

    end

    ------End Builder Generated functions, Do not Edit, this will be overwritten------

    -------------------------------------------------------------------------------

    ------Builder Generated callbacks, Do not Edit, this will be overwritten------

    -------------------------------------------------------------------------------

    --#LASTCALLBACKKEY=0#--

    ------End Builder Generated callbacks, Do not Edit, this will be overwritten------

    -- #Author Functions Go Here# --

     

    function CheckCartridgeIsOKToPlay()

    -- #GroupDescription=test --

    theCurrentTime = os.date('!*t')

    if theCurrentTime.year == 2009 and theCurrentTime.month == 5 and theCurrentTime.day == 10 and Player.Name ~= "Me" then

    Wherigo.MessageBox{Text=[[its OK to play today]],Buttons={"OK",},}

    else

    Wherigo.MessageBox{Text=[[You cant play this cartridge in the Emulator]],Buttons={"OK",},}

    end

    -- #Comment=test Comment --

    end

    -- #End Author Functions# --

    -- Nothing after this line --

    return cartcheck

     

    :anicute::anicute::anicute:

  11. Here is an example .lua file. Appologies for a few missing bits of code in the previous example, but now fixed and tested :anicute: This can be viewed and editited in the normal builder, just highlight the date values and change them in the window that appears when you double click on When a cartridge is started

     

    require "Wherigo"

    ZonePoint = Wherigo.ZonePoint

    Distance = Wherigo.Distance

    Player = Wherigo.Player

     

    -- #Author Directives Go Here# --

    -- #End Author Directives# --

     

    cartcheck = Wherigo.ZCartridge()

     

    -- MessageBox Callback Functions Table used by the Builder --

    cartcheck.MsgBoxCBFuncs = {}

     

    -- Cartridge Info --

    cartcheck.Id="8eacdb25-4bea-4dac-bb08-9dcefd610c60"

    cartcheck.Name="check"

    cartcheck.Description=[[]]

    cartcheck.Visible=true

    cartcheck.Activity="TourGuide"

    cartcheck.StartingLocationDescription=[[]]

    cartcheck.StartingLocation = ZonePoint(51,-2,0)

    cartcheck.Version=""

    cartcheck.Company=""

    cartcheck.Author=""

    cartcheck.BuilderVersion="2.0.5129.5086"

    cartcheck.CreateDate="5/10/2009 7:24:58 AM"

    cartcheck.PublishDate="1/1/0001 12:00:00 AM"

    cartcheck.UpdateDate="5/10/2009 7:31:18 AM"

    cartcheck.LastPlayedDate="1/1/0001 12:00:00 AM"

    cartcheck.TargetDevice="PocketPC"

    cartcheck.TargetDeviceVersion="0"

    cartcheck.StateId="1"

    cartcheck.CountryId="2"

    cartcheck.Complete=false

    cartcheck.UseLogging=false

     

    -- Zones --

     

    -- Characters --

     

    -- Items --

     

    -- Tasks --

     

    -- Cartridge Variables --

    -- Builder Variables (to be read by the builder only) --

    buildervar = {}

    -- ZTimers --

     

    -- Inputs --

     

    --

    -- Events/Conditions/Actions --

    --

     

    -------------------------------------------------------------------------------

    ------Builder Generated functions, Do not Edit, this will be overwritten------

    -------------------------------------------------------------------------------

     

    function cartcheck:OnStart()

    -- #GroupDescription=test --

    theCurrentTime = os.date('!*t')

    if theCurrentTime.year == 2009 and theCurrentTime.month == 5 and theCurrentTime.day == 10 and Player.Name ~= "Me" then

    Wherigo.MessageBox{Text=[[its OK to play today]],Buttons={"OK",},}

    else

    Wherigo.MessageBox{Text=[[You cant play this cartridge in the Emulator]],Buttons={"OK",},}

    end

    -- #Comment=test Comment --

     

    end

    ------End Builder Generated functions, Do not Edit, this will be overwritten------

    -------------------------------------------------------------------------------

    ------Builder Generated callbacks, Do not Edit, this will be overwritten------

    -------------------------------------------------------------------------------

    --#LASTCALLBACKKEY=0#--

    ------End Builder Generated callbacks, Do not Edit, this will be overwritten------

    -- #Author Functions Go Here# --

    -- #End Author Functions# --

    -- Nothing after this line --

    return cartcheck

     

    :laughing::anibad::blink:

     

     

     

    Alternatively, you can move the function to the author code and used the author view

     

    :anicute::anicute::anicute:

    require "Wherigo"

    ZonePoint = Wherigo.ZonePoint

    Distance = Wherigo.Distance

    Player = Wherigo.Player

     

    -- #Author Directives Go Here# --

    -- #End Author Directives# --

     

    cartcheck = Wherigo.ZCartridge()

     

    -- MessageBox Callback Functions Table used by the Builder --

    cartcheck.MsgBoxCBFuncs = {}

     

    -- Cartridge Info --

    cartcheck.Id="8eacdb25-4bea-4dac-bb08-9dcefd610c60"

    cartcheck.Name="check"

    cartcheck.Description=[[]]

    cartcheck.Visible=true

    cartcheck.Activity="TourGuide"

    cartcheck.StartingLocationDescription=[[]]

    cartcheck.StartingLocation = ZonePoint(51,-2,0)

    cartcheck.Version=""

    cartcheck.Company=""

    cartcheck.Author=""

    cartcheck.BuilderVersion="2.0.5129.5086"

    cartcheck.CreateDate="5/10/2009 7:24:58 AM"

    cartcheck.PublishDate="1/1/0001 12:00:00 AM"

    cartcheck.UpdateDate="5/10/2009 7:31:18 AM"

    cartcheck.LastPlayedDate="1/1/0001 12:00:00 AM"

    cartcheck.TargetDevice="PocketPC"

    cartcheck.TargetDeviceVersion="0"

    cartcheck.StateId="1"

    cartcheck.CountryId="2"

    cartcheck.Complete=false

    cartcheck.UseLogging=false

     

    -- Zones --

     

    -- Characters --

     

    -- Items --

     

    -- Tasks --

     

    -- Cartridge Variables --

    -- Builder Variables (to be read by the builder only) --

    buildervar = {}

    -- ZTimers --

     

    -- Inputs --

     

    --

    -- Events/Conditions/Actions --

    --

     

    -------------------------------------------------------------------------------

    ------Builder Generated functions, Do not Edit, this will be overwritten------

    -------------------------------------------------------------------------------

     

    ------End Builder Generated functions, Do not Edit, this will be overwritten------

    -------------------------------------------------------------------------------

    ------Builder Generated callbacks, Do not Edit, this will be overwritten------

    -------------------------------------------------------------------------------

    --#LASTCALLBACKKEY=0#--

    ------End Builder Generated callbacks, Do not Edit, this will be overwritten------

    -- #Author Functions Go Here# --

    function cartcheck:OnStart()

    -- #GroupDescription=test --

    theCurrentTime = os.date('!*t')

    if theCurrentTime.year == 2009 and theCurrentTime.month == 5 and theCurrentTime.day == 10 and Player.Name ~= "Me" then

    Wherigo.MessageBox{Text=[[its OK to play today]],Buttons={"OK",},}

    else

    Wherigo.MessageBox{Text=[[You cant play this cartridge in the Emulator]],Buttons={"OK",},}

    end

    end

     

    -- #End Author Functions# --

    -- Nothing after this line --

    return cartcheck

    :D:anicute::anicute:

     

    or, you could put the new code in a function and call it from a different function, but its still going to be red in the normal builder and confuse it slightly.

  12. And if so, what does the command look like?

     

    I would like to take my "emulator check", player name processing and a bunch of date/time checks and create a single Author Script to handle all of that.

     

    I need to be able to display messages such as "You can't play this cartridge in the Emulator"

     

    Is there a way to do that? Would really appreciate a code example.

     

    Thanks.

     

    Author Script is identical to normal script, if you edit the lua file direct, you can move entire functions in there, however you would not then be able to access them through the normal builder interface, only through the author script.

     

    When I started, I would tend to use the builder to create the basics of something, then edit the lua file to see what the syntax was and copy out the bits of interest i.e. in this example you want to display a message, so if you create a message with some text; a message box with a picture; a message box with a button; etc, you can see the differences and how each is done.

     

    Refering back to the time question, if you paste the following code into the author script, then that will check the date is the 9th May 2009 and your not using the emulator, will do one thing otherwise do something else (in this case display two different messages). Just keep adding the ANDs for your other checks.

     

    theCurrentTime = os.date('!*t')

    if theCurrentTime.year == 2009 and month == 5 and day == 9 and Player.Name ~= "Builder" then

    Wherigo.MessageBox{Text=[[its OK to play today]],Buttons={"OK",},}

    else

    Wherigo.MessageBox{Text=[[You cant play this cartridge in the Emulator]],Buttons={"OK",},}

    end

     

    After the second MessageBox, but before the end, you could put the code to end the cartridge, but I forget what that is just at the moment.

    Note: identical comparison is a double equals; not equal to is a ~=

     

    Hope thats what your asking for :laughing:

  13. You can get the date using date()

     

    e.g.

    message = os.date()

    Wherigo.MessageBox{Text=[[Date is :]]..message,Media=zmediaPicture,Buttons={"OK",},}

     

    or

     

    theCurrentTime = os.date('!*t')

    if theCurrentTime.year == 2009 then

    Wherigo.MessageBox{Text=[[its 2009]],Buttons={"OK",},}

    else

    Wherigo.MessageBox{Text=[[its not 2009]],Buttons={"OK",},}

    end

     

    The fields of interest are

    hour

    min

    wday

    year

    yday

    month

    sec

    day

    isdst

     

    All variables are numbers, apart from isdst which is true or false (is daylight saving time)

     

    The !*t I think gets you universal time/GMT/+0hours, so people can't cheat by changing the timezone :P

  14. You may want to try a new version than 2.0. I remember reading some posts in the forum in which others installed 2.0 but it did not work and they had to install a version newer like 3.0 or 3.5. I can not remember the version they used but it is worth a try.

     

    Have you tried reading http://forums.Groundspeak.com/GC/index.php?showtopic=212622

    Updating the builder may sort your problems out. I still run an XP Virtual machine on my Windows Vista - the whole OS is geared around Wherigo building - bit of a hassle, but it works.

  15. Hi all

     

    I've been looking at mboensch cartridge who had a problem with messagebox's buttons not working correctly. See original post: http://forums.Groundspeak.com/GC/index.php...p;#entry3892915 for more details.

     

    I eventually tracked it down to the name of the cartridge. The name he used was:

    A_Tour_of_Frankenmuth

    but doing a search and replace and changing it to

    ATourOfFrankenmuth

    fixed the problems.

     

    I'm guessing _ is a special character although in most languages _ is often used to represent space characters. I was wondering if anyone else had come across this and knew what other characters to avoid, or should all names (cartridge, zone, variable, etc) all be named using only A to Z and a to z characters.

  16. I gather Groundspeak are been a bit poor in offering to host it, so he may be interested in other host sites.

    I don't recall saying that. :anicute: Groundspeak's hosting offer is taking some time to materialise, but I'm not looking for other hosting. It would be nice if my ISP would fix their ridiculous 20Kbyte limit on POST data for Web services, which limits the size of cartridge which you can compile in a single click, but if you go through a ZIP file there are no other major issues.

     

    Not been a Mac or Linux person, I have no idea if it works, but I don't see why not.

    Apart from one or two minor layout issues with Safari, I think it ought to work fine. It only uses the OS to save files.

     

    Now, a Wherigo player for the iPhone... that would be cool.

     

    Appologies for getting the wrong end of the stick about groundspeaks hosting.

     

    Isn't OpenWig (http://code.google.com/p/openwig/) designed for mobile phones like the iPhone (not having a compatible phone, I've not really looked into it) other than thinking how on earth am I going to fix the bug reported by someone playing my Wherigo in OpenWig (especially given they didn't answer any questions I asked them regarding the crash).

  17. It looks like the major dependency for Wherigo Builder is the .Net framework. What's so magic about this framework that it can't be replaced by Foundation/AppKit in Cocoa?

     

    Both my son and I are intrigued by Wherigo and eager to put some ideas we have into cartridges. But we only use Macintosh. With the tremendous success of the iPhone applications and many new first time developers, it's clear that the Cocoa development platform is viable, easy to use and can produce applications for handheld devices. An interesting application might be a Wherigo Player for the iPhone 3G to expand the Wherigo audience by millions! Anybody working on that?

     

    We have a Colorado and an Oregon GPS and have both enjoyed the Wherigo experience on them, but we're withering over the lack of support for developement on the Macintosh. If Wherigo Builder is considered an Alpha product still, can't we get some alpha level work done on a Macintosh version. With the creative reputation of the Macintosh community, I'm sure you won't be disappointed by expanding your developer base.

     

    Please help us.

     

    Cocoa is even less portable than .net! (Many .net apps can be moved to mono, an open-source friendly third cousin twice removed of .net, which can run on Mac OSX, Linux, and BSD, with little effort.)

     

    I'd love to get together with interested individuals and put together a portable builder/player so that those of us who don't do M$ products can participate in building Werigo cartridges... I'm just not sure I have the time to spearhead it.

     

    I would happily have my company provide hosting for such an effort, and contribute to testing/documenting/bugfixing/issue triage as my schedule allows.

     

    --Susan

     

    I've been having a play with Earwigo a web page version of the builder that sTeamTraen has created. Best feature I've found so far is the mapping works!!! I gather Groundspeak are been a bit poor in offering to host it, so he may be interested in other host sites. Not been a Mac or Linux person, I have no idea if it works, but I don't see why not.

  18. The Colorado also has a lag of a few seconds between choosing an action and seeing the result. Although, it does this when there are lots of stuff active, zones and tasks, but the time lag gets smaller and smaller as the list of active stuff turns to unactive stuff.

     

    How about the locations screen?

     

    Wherigo.ShowScreen(Wherigo.LOCATIONSCREEN)

     

    Does that work in the Oregon? That's the only place where I show a screen in a program I'm working on. If that won't work in an Oregon, then I'll take it out.

     

    It does work, although I have experienced occasional crashes which I suspect was caused by the ShowScreen, especially showing tasks. I've since taken most if not all of them out and reliability has definitely improved although that may be down to other changes made at the same time.

  19. but where do the brackets go if i have:

     

    Hallo Player.Name and more text

     

    i get errors when i do this

     

    Here is an example:

    [[Hello ]] .. Player.Name .. [[. How are you today?]]
    

     

     .. 

    is the string concatenation operator in lua,

    [[ ]]

    are the text delimiters (although

    ""

    and

    ''

    seem to work in some places, using

    [[

    and

    ]]

    seems to be safest )

     

    If you want to just use the builder, you can enter

     

    Hello ]] .. Player.Name .. [[ how are you?
    

     

    into the "Build a MessageBox"'s "Enter the text to show" box. I can save the project and load it back up again with out things going wrong. Take a backup before trying though, just in case. The reason you don't need the starting and ending brackets is because the builder takes care of them for you.

     

    Seems to work, although you might run into trouble if for some reason the builder descides to use double quotes instead of [[.

  20. Just noticed when the original articles where posted :P

     

    I was having similar thoughts over Christmas and Packman looked like the easiest of the old style games to implement with the twist that your in the maze rather than looking top down.

     

    I was also pondering something along the lines of the game at the end of a TV game show called the Adventure Game where you have to cross a grid with out getting vaporised by an invisible vortex. You took it in turns to move. The way to tell if the Vortex was on the destination point was to throw a bread roll at it - quality show around 25 years ago at a guess.

    The problem with the invisible maze idea is the player can quickly get lost in which way s/he came because the point of reference just isn't there. I played one of those in the field and it took a while. I would have preferred to have physical reference points or some virtual breadcrumb trail.

     

    I also thought of an idea like Pac-Man. Again, the problem was a lack of enforcing a wall. However, the idea of "Keep Away" did come to me. Once again, you play it on a football field. A number of "ghosts" will try to chase you. Your job is to keep away from the ghosts while going around and picking up "flags" for points (or, perhaps, you have to clear a certain number of "flags" before the time limit to win the game).

     

    Since then, I learned that while the Colorado is great at running a game like this, the Oregon is absolutely horrible at anything involving zone movement and calculation. One of my location-specific cartridges, "Sadie's BiG Adventure", had to be scaled back because the Oregon kept slowing down when a player was on a dialog screen and zones were moving in the background. Is the hardware limit that easy to hit or is the Wherigo Engine itself inefficient in some aspect?

     

    The "Keep Away" game idea just doesn't sound as appealing and exciting as "Whack-A-Lackey", though.

     

    In the case of this game, I was using actual paths in a relatively flat grassy park so its really obvious where you are meant to go and how to get to any point on the map (Packman isn't intended to be a hidden maze). I agree a football pitch would be much harder given you have no reference points, that said, the game is a play anywhere so if people where really keen they could play it. On a larger scale, I could also have used streets for paths and the buildings act at the visual boundaries.

     

    There is code to make sure you stay on the path and don't cheating by heading down a side street the game doesn't know about, so virtual walls are enforced. No avoiding the squirrels!!!

     

    In some ways not knowing where you are in the maze is one of the points of a maze (for which this game could easily be adapted), and I'm sure an enterprising player would soon work out that their gps was plotting where they had gone so far and use that to help navigate (no so easy on the Oregon I admit where you would have to save the game, swap to map view to see where you had been and then reload the game).

     

    The nodes I'm intending to change from all those types of nut to just "Nut" (or "Path"/"Junction" if the player had been there already) simplifying the whole thing and giving it the virtual bread crumbs. I just went of on a tangent one day trying to find as many type of nut as I could for the game because it sounded good at the time, but in reality over complicates it - kind of interesting though.

     

    Collecting flags and avoiding ghosts on a football pitch I like, but the Oregon just can't do many moving things, I would say 3 is the absolute limit, which is well, not really enough. The game its self would be fairly easy to do. One issue might be time, processing events every second might be a bit too unresponsive for a fast action game like that.

×
×
  • Create New...