Jump to content

Trying to build my first Wherigo with Urwigo and need some help, please


Lozuath

Recommended Posts

Posted (edited)

I have no knowledge of using LUA in any form or shape, so I have tried to use ChatGPT to do some LUA coding for me.

So far with no luck.

I have created zones, and the starter zone is "Sandbukta"
image.thumb.png.7341020cf9d4359464b686b7683bcc69.png

 

I have created a chr called "Girl" with an associated media called "Girl".
image.thumb.png.ad68d3305e07af4fd856292128743d4f.png

 

"Girl" is visible in the startup zone.

image.thumb.png.e5471361fceea709c1130a2b8139d0f7.png

 

I have then attempted to use ChatGPT to create the script for the action and dialogue I want with this character in the zone. I attempt to put this in the "On enter" for the "Sandbukta zone".

It constantly fails though, so ChatGPT "dumbed" it down to see what the problem is. This is the "shrunk" version of the script:

 

function ZoneEnter()
  Wherigo.MessageBox{
    Text = "Test message on entering the zone.",
    Buttons = {"OK"},
    Callback = function(action)
      if action == "OK" then
        Wherigo.ShowScreen(Wherigo.MAINSCREEN)
      end
    end
  }
end

Zones["Sandbukta"].OnEnter = ZoneEnter

 

It starts, but when I enter the zone it fails:

Thu May 16 23:41:50 2024 WARN [Engine]: ProcessLocation(): Lua method call failed. .../urwigo-src-26970ad6-8627-48d3-bb47-8fafcf3624d3.lua:681: attempt to call field 'Debug' (a nil value)
Thu May 16 23:41:50 2024 CARTRIDGE [Lua]: 59.52705|10.50573|0.000|1.000|Zone:Enter - Sandbukta
Thu May 16 23:41:49 2024 CARTRIDGE [Lua]: 0.00000|0.00000|0.000|0.000|ZCartridge:Start - Downloaded Fri May 17 00:41:45 2024
Thu May 16 23:41:49 2024 CARTRIDGE [Lua]: 0.00000|0.00000|0.000|0.000|Engine Version 2.11, Player Name: Mr. Smith, Device ID: Desktop

 

This is the full version of the script ChatGPT has put together for me, based on my wishes for the zone and comunnication with the character in the zone:

-- This function is called when the player enters the zone "Sandbukta".
function ZoneEnter()
  -- Check if the girl is not already in the player's inventory.
  if ZCharacters["girl"].Container ~= cartPlayer.Inventory then
    -- Display a message box with options.
    Wherigo.MessageBox{
      Text = "As you enter the zone, you notice a girl crying on the beach. She says: 'Please could you help me find my parents. We have visited all the beaches here today, and I've lost my parents and all my things.'",
      Media = Wherigo.ZMedia("Girl_Image.jpg"), -- Ensure the path to the image is correct.
      Buttons = {"Yes, I'll help", "Sorry, I can't help"},
      Callback = function(action)
        -- Handle the player's response.
        if action == "Yes, I'll help" then
          -- Move the girl to the player's inventory.
          ZCharacters["girl"]:MoveTo(cartPlayer.Inventory)
          -- Thank the player for agreeing to help.
          Wherigo.MessageBox{
            Text = "Thank you so much! I really hope we find them soon."
          }
        else
          -- The player refused to help.
          Wherigo.MessageBox{
            Text = "Oh, okay. Please let me know if you change your mind."
          }
        end
      end
    }
  else
    -- The player has already interacted with the girl.
    Wherigo.MessageBox{
      Text = "You've already agreed to help the girl."
    }
  end
end

-- Attach the function to the zone's OnEnter event.
Zones["Sandbukta"].OnEnter = ZoneEnter


This fails even earlier:
image.png.0c4d76e70a47227921d5ea727da97c1d.png

 

Is my wish to use LUA scripts in this manner assisted by ChatGPT viable at all?

 

And if not, could someone please help me figure out how to set up the dialogue for the first zone withing Urwigo? I'm struggling a bit with the logic and what I need to do in order to make this work.

 

Any help and/or guidance would be most welcome.

Edited by Lozuath
Correcting a misspelled word
Link to comment

Try importing this cartridge.

 

Here's the sequence I took:

  • I created the zone and character.  No actions yet.
  • I created a variable to store the answer from the girl's question
  • I created an input.  The input's text is the question about helping the girl.  It will store its answer in the answer variable and the input type is multiple choice with the "Yes" and "Sorry" options you mentioned.
  • I set up the zone's OnEnter event.  If the girl is in the player's inventory, show the "You've already agreed to help the girl" message.  Else, show the input.
  • Back in the input, I created the event when the input gets input from the player.  If the input is the "Yes" message, move the character to the player.  Else, show the dejected girl message.

You can do things with a message box and buttons, but I'd say the input method is more standard and expected.  Few cartridges use the message box button approach.

 

ChatGPT tried to cram everything into one lua function.  As a software engineer, I like to break things into manageable and reusable pieces and not have everything together.  But if that's what you want, go for it.  If you want me to look through what ChatGPT generated and find what the problem was, ask and I might be able to get to that tomorrow night.  (Either the way it referred to the girl character or the way it tried to set the image.  Try removing the image and see what happens.)

 

You can also refer to any of my cartridges, like Cacher Pursuit or Battleship, for examples of what clean lua scripting within a cartridge looks like.

  • Upvote 1
Link to comment
Posted (edited)

Thanks for your reply.

I downloaded your cartridge and ran it in Webwigo, but even though I move the player into the zone - nothing happens?
image.thumb.png.af3149d7d430dfce8551dda38f6287be.png


And the bit about creating a variable and input is the crux of my problems.

 

I think I have managed to create an input:
image.thumb.png.f15071e7edb8c270c109dc30814c1000.png

 

But I have no idea how to use the input.

I have looked at the variable bit, but been unable to figure out how to set things up in Urwigo so that it takes the input and then how to use it.

If you are able to provide a *.urwigo file with this flow set up, it would be very helpful and hopefully set me on the right path. I really don't understand which action(s) is/are the right one(s) to use.

I found a tutorial on YouTube. He did set up a command "Talk to", but ironically he never got around to elaborate no how to set up the handling of it.

 

If using ChatGPT and Urwigo is viable, I would be most grateful if you were able to look at the script to see why it doesn't work. Since even the "shrunk" version of the script failed, I've hit a pretty soild wall.

 

Here I have uploaded my entire project:
https://1drv.ms/f/s!Ah32GzvTZ0Lhgo5ykxPYbCRtBf1VJg?e=PsEDY8

 

Please feel free to download it to have a look at what I have done so far. You will certainly not be impressed, but you should get an idea at what I am aiming for.

 

Again, I greatly appreciate you trying to help out a complete noob here.

Edited by Lozuath
Link to comment
Posted (edited)

Hmmmm, seems like I had a small breakthrough here (after several breakdowns):

 

I created this Input:
image.png.891f647fd4adcea82da03cd51f603d89.png

 

Then I made this flow to handle the "On get input":
image.png.3e9cead7bd1526051136a69fecd3c6d5.png

Then I put a "Talk to girl" command on the "Girl" character and eneabled/handled it:
image.thumb.png.56cd1996056ee0e493a4716b85342c8d.png

 

Now, if I click "Yes" the girl is moved to my inventory, and if I click "No" the message is shown with an "ok" button. If I click the "ok" button I am returned to the main screen and can try to accept helping her instead.

There are so many "Unhandled" places to click that it's a bit of a jungle at first.

Is this a good way to handle this, or are there better options available.

Don't get med wrong, I'm pretty happy to get this far.

I also wonder how to prevent the input "Talk to girl" from running when she has been moved to my inventory and I click on her?

Edited by Lozuath
Link to comment

Nothing happens when you visit the zone in Webwigo

Thank you for the screenshot.  The simulated GPSr is off (the red dot).  Please click it to turn it on.  I do not know why it's disabled by default.

 

Is that a good way to handle things?

The "OK" button is the default button for message boxes, so that's fine.  In the field, someone who elects not to help the girl will have to move outside the zone and reenter.  Not that much of a big deal because it's a very minor penalty for choosing the wrong answer.  Handling the "on get input" event is the way to go.

 

So many "unhandled" things

Yes, it would help if people, when creating a cartridge, knew they were supposed to add something to handle the input's event.

 

The input runs when the girl is added to your inventory and you click on her

That shouldn't have been.  The input is tied to the zone's enter event, and you have something preventing the input from running if the girl is in the player's inventory.  (One other way to handle things in a more complex cartridge is to have a second zone with the same name and coordinates as the first.  You could disable the first zone and enable the second zone.  This keeps subsequent game logic separate and a little easier to handle--but that's if you might have players going to and from the zone all the time.

 

Testing the ChatGPT-created code

I'll need to switch computers to do that (I just did a code move for work, so am still on my work computer).  I'll test that in a bit, before I stop for the night.

Link to comment

Looking at the ChatGPT-generated code:

  • I was going to guess this before, but thought I remembered wrong: the apostrophes in the comments prevent the cartridge from compiling.
  • Next, the way ChatGPT attempted to get the girl character resulted in an error.  That was one of the things I thought was going to be a problem.
  • Selecting the "yes" option resulted in the "oh, okay" message.  This is because the button name is stored in the "action" variable instead of the answer.  So, if you tested for "Button1" instead, it would work.
  • The way the character was added to inventory didn't work.  Moving the character to the Player object is the correct way.

The corrected code is as follows (removing the apostrophes from the comments without correcting the grammar):

function ZoneEnter()
  -- Check if the girl is not already in the players inventory.
  if zcharacterGirl.Container ~= cartPlayer.Inventory then
    -- Display a message box with options.
    Wherigo.MessageBox{
      Text = "As you enter the zone, you notice a girl crying on the beach. She says: 'Please could you help me find my parents. We have visited all the beaches here today, and I've lost my parents and all my things.'",
      Buttons = {"Yes, I'll help", "Sorry, I can't help"},
      Media = Wherigo.ZMedia("Girl_Image.jpg"),  -- Ensure the path to the image is correct.
      Callback = function(action)
        -- Handle the players response.
        if action == "Button1" then
          -- Move the girl to the players inventory.
          zcharacterGirl:MoveTo(Player)
          -- Thank the player for agreeing to help.
          Wherigo.MessageBox{
            Text = "Thank you so much! I really hope we find them soon."
          }
        else
          -- The player refused to help.
          Wherigo.MessageBox{
            Text = "Oh, okay. Please let me know if you change your mind."
          }
        end
      end
    }	
  else
    -- The player has already interacted with the girl.
    Wherigo.MessageBox{
      Text = "You've already agreed to help the girl."
    }
  end
end 

I have updated the cartridge on my NAS (the link I originally used).

 

When I began learning Wherigo, I would use the builder to perform certain actions, then open the lua file to see how it wrote things.  I then looked at the lua language reference to see how to perform certain operations in lua.  While learning, I ended up writing a lot of invalid stuff I had to fix.  So I didn't get too far in a cartridge and have to figure out where the error was, I would usually write three to ten lines, then reload the cartridge in a builder to make sure it could still read and compile the cartridge.  I'd then write more and open and compile in the builder again.

Link to comment
Posted (edited)

Thanks a lot for you help and input so far @Ranger Fox.

I have done a bit more work on the Wherigo now, and it seems to run quite well in the internal emulator in Urwigo.

However when I run it in webwigo some of the functionality does not work as expected.

Rather than having all the items show up as you enter a new zone, I have tried to build it so that you have to search the zone to enable displaying the item in the zone. In the built-in emulator in Urwigo this works very well. In webwigo the command to search simply does not display when you click on the location:

In internal emulator:
image.png.9eb2b8b82b7d32b692d749d6226ea26f.png

 

In Webwigo:
image.png.48cf479be2cf72f4feb9059e46b2f62a.png

 

I guess I could change it so that the item automatically pops up when you enter the zone, but I was hoping you could take a look and see if you can figure out the problem?

In this link you will find the compiled *.gwc and an extracted *.lua,
Beaches

 

I am also wondering what is the difference between a *.gwc and a *.gwz?

 

And finally, is it possible to upload the cartridge and test it in the field so to speak before making it publically available - and if so how do I go about it?

 

I do greatly appreciate you helping out here. I think a good Wherigo is a lot of fun, but Groundspeak is treating Wherigos very poorly. The official builder is a beta from 2008 that I couldn't even get to work properly - and the process of creating is hardly documented as all. Their "tutorial" was less than helpful, and is putting it mildly....

Edited by Lozuath
Link to comment
Posted (edited)

Just checking, but you did try clicking on the zone in Webwigo to see if the command is displayed there?

 

(For the rest of this, I will be treating zones as single points with proximity and distant events.)

 

One alternative you could do is to have one zone with a "large" proximity radius--that being the entirety of where people are to search--and several smaller but hidden zones, each of which contain an item.  Those zones might be named after an item and could be toggled visible and not based on their proximity and distance from the person.  This might be a more complicated way to gimmick things.  Or you could just have a search item a person has to use, and if searching while the person is within a hidden item zone, the zone either becomes visible or the item is moved to the player's inventory.  You can get the same effect different ways.  Figure what works for you and what might be easier for you to implement.  Just remember that you can do things several different ways.

 

Oh, and if you're wondering which way a player app will work, try making a test cartridge right where you're sitting, then load it into your player app and run it.  For concepts I'm not sure would work, I would just make a zone at my house or wherever I am so I could test something without moving to the field.  But though I like Webwigo a lot, the internal emulator is closer to reality.

 

 

 

The difference between a GWC and GWZ

Nothing, save for the file extension.

 

 

 

Testing before you go live

Perhaps the easiest way to do that is to make a listing on the Wherigo site and keep the box to show in the listing unchecked.  This will keep it private.  You can then log into the Wherigo site on your phone, go to your account, find the cartridge listing, and download it that way.  When you want to test something else, use your computer to upload a new version of the cartridge to the listing page.  I've also used a link on my NAS to avoid uploading a cartridge, and I've also used the Wherigo Foundation site to do so with a private listing.  All sorts of different ways.

 

 

 

Groundspeak and Wherigo

One other way to look at it is Wherigo is like Waymarking.  Groundspeak put it out, but doesn't seem to do a lot with it.  The Waymarking site is the same as I remember when I started geocaching in 2006.  The Wherigo site has been the same since it was launched in 2008.  If Waymarking hasn't shut down, Wherigo will likely still continueOh, there are ways to shut Wherigo down, but it'll continue to exist so long as the bit rot doesn't get too bad and we continue having community members support it with tools.

Edited by Ranger Fox
One "e" in "continue" was italicized
Link to comment

@Ranger Fox

Hi

Thanks to all your help my first Wherigo is now uploaded and awaiting publishing.

 

One more question if I may though: How do I go about protecting the container from being run in an emulator like Webwigo?

 

I've read a couple of your answers in the threads here, and it seems you said Urwigo have a fair bit of functionality for this?

I have to admit that I didn't quite understand from your replies how to go about actually doing it, so I wonder if you can give me the best way to do so that does not include hidden zones and questions about local signs etc.?

Link to comment

There are a couple ways of protecting a cartridge:

  • You could use Urwigo to add emulator protection
  • You could come up with an interesting way to do it yourself
  • You could ask a question in the cartridge that proves someone was there (e.g. number of bolts in a sign, something written on the back of an object, or anything else that people won't be able to use Google Maps photos or Waymarking photos to answer)
  • Don't include the final coordinates and just lead people around to assemble the final coordinates based on their answers to the cartridge's questions

I'd prefer working questions into the cartridge as part of its story.

 

I did, by the way, experiment with cheat protection in one of my cartridges, Lake Mac Menagerie.  I left a lot of red herrings for anyone who wanted to cheat.  Those would point to a bogus location that is more plausible than the actual location.  If the cheat protection was passed, the cartridge would perform some math to adjust the coordinates to their real location.

 

In the end, though, the easiest way to cheat at a cartridge is just to ask others who have played it for the final coordinates.  So, in my opinion, the best anti-cheat protection has two layers: ask as simple question to verify someone is there (a simple deterrence), then make the cartridge experience so fun and enjoyable that it's their loss for not playing it.  The more of a hassle you make the cartridge, the more people are going to want a way around it.  On the other hand, if they're going to walk by the locations anyway and the cartridge offers something of quality, they're more likely to play it than bypass it.  You're always going to have people who will want to bypass the cartridge.  Just make sure to reward with a great experience those who choose to spend their personal time playing what you created.  That's the most important thing.

Link to comment

@Ranger Fox

 

As always I am very grateful for your input.

I tried activating the emulator protection in Urwigo, but it seems that Webwigo isn't much bothered by it.

 

I will make a couple of zones where you have to input something from the actual site so go further.

 

I do wonder though if there is a way to make Urwigo stop Webwigo from running the code? I'm afraid my lack of knowlegde when it comes to Lua, makes me quite unable to come up with an interesting way to code my way around it. Do you have any suggestions for me on this one?

I see there is an expression "In emulator" which should return true if the code is run in an emulator, but despite my best efforts with Google I have come up with no idea how to utilize this expression.

 

I've had two people logging my first Wherigo so far, and I have 2/2 so far as favourite points go - so I must have done something right.
 

Edited by Lozuath
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...