+Forest-Ghost Posted September 6, 2016 Share Posted September 6, 2016 I am building a hot and cold Wherigo. I am trying to set it up so that every time the player moves 200 ft or more a message will be displayed stating if the player is getting hotter or colder (closer or farther from the geocache zone). So far I have setup a function to measure the distance from the geocache zone and tell if the player is getting hotter or colder. Now I am trying to create a second variable that will measure the distance from the player's last known location. Can a player's location be stored as a variable and if so, can you use this variable to compare distance from the player's last known location? I would like to set it up so that every time the player moves 200 ft the cartridge will display the hot/cold message which I have already setup. How would you do this? Any suggestions are welcome. Please let me know too if you think there is a better way to set up this cartridge. Quote Link to comment
+Kalkendotters Posted September 6, 2016 Share Posted September 6, 2016 Easiest way I can think of: Create a zone of 200ft around the player; then trigger an OnExit event when the player exists the zone. In the trigger you move the zone to the current player position, and display the warmer/colder/same temperature message. Quote Link to comment
+charlenni Posted September 6, 2016 Share Posted September 6, 2016 The position of the player is of type Wherigo.ZonePoint and could surely used to calculate a distance to the actual position. You could use the OnDistant and OnProximity events of zones. Set the position of the zone to the actual position of the player. Set the proximity range to 200 ft. If the player leaves the proximity range (here 200 ft) you get a OnDistant event, independent of the direction the player walks. See http://forums.Groundspeak.com/GC/index.php?showtopic=329458 too. Quote Link to comment
+Forest-Ghost Posted September 6, 2016 Author Share Posted September 6, 2016 Thank you, this sounds like it will work well. Sorry to ask questions again, but How do you set the position of the zone to the actual position of the player? I tried several commands on my own but they result in the cartridge crashing. Thank you for all of your help. Quote Link to comment
+Beach_hut Posted September 6, 2016 Share Posted September 6, 2016 Funnily enough, I had a variation of this same concept in mind. The player has a button in their inventory, with a "press" command. Every time they press, it compares the distance from the player to the final cache location to the distance as at the last time they pressed the button. If it goes up, then the cartridge tells them they're getting colder, if it goes down they're getting warmer. You could put some kind of a timer that disables the button for a period of time after it is pressed to prevent abuse. The problem I would foresee with a cartridge that detects them being exactly 200 feet away from last time it triggered is that, when the player gets within 200 feet of the cache, it gets hard to narrow down further which direction to go in. If it triggered when you're 100 feet away, you might potentially walk past the cache and be 100 feet the other side by the time it triggered. An alternative I've just thought of as I was writing this is to have a timer event which checks the distance every X seconds or minutes. Quote Link to comment
+Beach_hut Posted September 6, 2016 Share Posted September 6, 2016 Thank you, this sounds like it will work well. Sorry to ask questions again, but How do you set the position of the zone to the actual position of the player? I tried several commands on my own but they result in the cartridge crashing. Thank you for all of your help. You could try something like this: function DistanceFromZone(zone, units) local d2,b2 = Wherigo.VectorToPoint(Player.ObjectLocation, zone.Points[1]) local d = d2(units) --print("Distance from zone " .. zone.Name .. " = " .. d) return d end I've adapted this from something Ranger Fox created initially. Quote Link to comment
+charlenni Posted September 6, 2016 Share Posted September 6, 2016 To set a zone to the players position, take the actual position and create from this position 3 points: one with 10 m in 0°, one with 10 m in 120° and one with 10 m in 240°. Or search for "Wherigo moving zone". There should be some ready made functions. Quote Link to comment
+bflentje Posted September 6, 2016 Share Posted September 6, 2016 https://www.geocaching.com/geocache/GC640VX_huckle-buckle-beanstalk?guid=e528220a-af0a-449f-9caf-154139ce0911 Quote Link to comment
+Forest-Ghost Posted September 9, 2016 Author Share Posted September 9, 2016 Could someone possibly upload an example of this in urwigo? I am looking for: a zone that is set to the player's current location as an on exit event Sorry to ask again. I have read through all of the forum posts on this and tried the lua a number of ways but I still can't get it to work without crashing the cartridge. I even tried copying parts of several cartridges that are play anywhere but I still could not get it to work. I am not sure what I am missing. It would be a tremendous help. Thanks. Quote Link to comment
+charlenni Posted September 9, 2016 Share Posted September 9, 2016 Find attached a demo cartridge. See description for usage. MoveZoneToPlayer.zip Quote Link to comment
+Forest-Ghost Posted September 9, 2016 Author Share Posted September 9, 2016 Thank you so much for sharing this! I really appreciate it. I am not sure why, but when I try it on my emulator and phone, it does not seem to move the zone after I press the "set and then "move" command. Not sure if I am missing something. Quote Link to comment
+charlenni Posted September 9, 2016 Share Posted September 9, 2016 You must move to a new position. If the player location doesn't change, than the zone doesn't move. Quote Link to comment
+Forest-Ghost Posted September 9, 2016 Author Share Posted September 9, 2016 Ahh I see, thank you so much. I see how it works now. I really appreciate all of the help! Quote Link to comment
Recommended Posts
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.