The Cartooners Posted September 24, 2008 Share Posted September 24, 2008 Here is the original location as created within the builder zoneBronzeAgeMan.Points = { ZonePoint(51.3176,-2.9823,0), ZonePoint(51.3176,-2.982,0), ZonePoint(51.3174,-2.982,0), ZonePoint(51.3174,-2.9823,0) } zoneBronzeAgeMan.OriginalPoint = ZonePoint(51.3175,-2.98215,0) And here is where I want to move the zone (under a certain condition) zoneBronzeAgeMan.Points = { ZonePoint(51.3166,-2.9820,0), ZonePoint(51.3166,-2.9817,0), ZonePoint(51.3162,-2.9817,0), ZonePoint(51.3162,-2.9820,0) } zoneBronzeAgeMan.OriginalPoint = ZonePoint(51.3164,-2.98185,0) as placed within a function within the Author Script section. As you can see the zone will not move far. Its purpose is that when the Player returns to a character (within the zone) that the character has moved a little. When this code is executed I receive an error First arguement must be a zonepoint What have I missed? Quote Link to comment
Ranger Fox Posted September 24, 2008 Share Posted September 24, 2008 (edited) Here's what I did for the "CenterZoneOnPoint" method in Whack-A-Lackey. It takes in a zone and a ZonePoint, the center of where I want the zone: --Moves the zone to a ZonePoint. This is used to prime all zones function CenterZoneOnPoint(zZone, point) local dist = Wherigo.Distance(0, 'ft') local newZp = Wherigo.TranslatePoint(point, dist, 0) -- new center point for the new zone dist = Wherigo.Distance(ZoneRadius, 'ft') local pts = { Wherigo.TranslatePoint(newZp, dist, 45), Wherigo.TranslatePoint(newZp, dist, 135), Wherigo.TranslatePoint(newZp, dist, 225), Wherigo.TranslatePoint(newZp, dist, 315), } zZone.Active = false zZone.OriginalPoint.latitude = newZp.latitude zZone.OriginalPoint.longitude = newZp.longitude zZone.Points = pts end If you still need help, I can post some other things and experiment a little. For now, I have to get back to work. Edit: I forgot to mention you do have to set the zone as inactive to move it. Edited September 24, 2008 by Ranger Fox Quote Link to comment
The Cartooners Posted September 26, 2008 Author Share Posted September 26, 2008 Here's what I did for the "CenterZoneOnPoint" method in Whack-A-Lackey. It takes in a zone and a ZonePoint, the center of where I want the zone: --Moves the zone to a ZonePoint. This is used to prime all zones function CenterZoneOnPoint(zZone, point) local dist = Wherigo.Distance(0, 'ft') local newZp = Wherigo.TranslatePoint(point, dist, 0) -- new center point for the new zone dist = Wherigo.Distance(ZoneRadius, 'ft') local pts = { Wherigo.TranslatePoint(newZp, dist, 45), Wherigo.TranslatePoint(newZp, dist, 135), Wherigo.TranslatePoint(newZp, dist, 225), Wherigo.TranslatePoint(newZp, dist, 315), } zZone.Active = false zZone.OriginalPoint.latitude = newZp.latitude zZone.OriginalPoint.longitude = newZp.longitude zZone.Points = pts end If you still need help, I can post some other things and experiment a little. For now, I have to get back to work. Edit: I forgot to mention you do have to set the zone as inactive to move it. Thanks Ranger, Here's how I got it to work 1. Copied your function 2. Added the following to my event local zp = Wherigo.ZonePoint(51.31710, -2.982,0) -- New Location of existing zone CenterZoneOnPoint(zoneBronzeAgeMan, zp) 3. The only change that I made within your function was the need to add local ZoneRadius = 60 Voila I failed to find anything within the LUA reference manual regaring ZonePoints etc. So once again thanks. Quote Link to comment
+Voller Posted November 22, 2009 Share Posted November 22, 2009 Voila Hello Ranger Fox and others. I want to use this function (I am building a cartridge that is to be published during an Event - so to spread out the players, I want to give them alternative routes.) I use a text-editor to insert the function under "-- #Author Functions Go Here# --". Then in the same editor I add code to call the function under one of the builder-generated events. It seems to work OK, but in the builder I get a "LUA Parsing Error", and in the source it says "Builder Generated functions, Do not Edit, this will be overwritten". Can I just ignore these warnings, or is there another way to call a user defined function? Please keep your answer in a simple language (preferentially with an simple example) as I am literally a BASIC programmer. Quote Link to comment
+sTeamTraen Posted November 22, 2009 Share Posted November 22, 2009 It seems to work OK, but in the builder I get a "LUA Parsing Error", and in the source it says "Builder Generated functions, Do not Edit, this will be overwritten". I'm not quite sure what the last part means here. That comment about "Builder Generated functions" is in every cartridge. Can you upload your Lua file (or the relevant parts, if the rest is secret) here so we can look at it? Can I just ignore these warnings, or is there another way to call a user defined function? In Earwigo (alternative builder), you can insert an arbitrary Lua statement at any point, without causing any sort of parsing issues, because the Earwigo editor doesn't look at the statement. Also, the "Author Functions" section has some Lua syntax checking. And, although it exists in 5 or 6 languages already, we need someone to translate into Danish... so if you want to try it out, please mail me via my profile. Quote Link to comment
+Voller Posted November 23, 2009 Share Posted November 23, 2009 I'm not quite sure what the last part means here. That comment about "Builder Generated functions" is in every cartridge. Can you upload your Lua file (or the relevant parts, if the rest is secret) here so we can look at it? The Function: -- #Author Functions Go Here# -- function CenterZoneOnPoint(zZone, point) local ZoneRadius = 60 local dist = Wherigo.Distance(0, 'ft') local newZp = Wherigo.TranslatePoint(point, dist, 0) -- new center point for the new zone dist = Wherigo.Distance(ZoneRadius, 'ft') local pts = { Wherigo.TranslatePoint(newZp, dist, 45), Wherigo.TranslatePoint(newZp, dist, 135), Wherigo.TranslatePoint(newZp, dist, 225), Wherigo.TranslatePoint(newZp, dist, 315), } zZone.Active = false zZone.OriginalPoint.latitude = newZp.latitude zZone.OriginalPoint.longitude = newZp.longitude zZone.Points = pts end -- #End Author Functions# -- The call: function zoneStartzone:OnEnter() -- #GroupDescription=Script -- -- #Comment=Script Comment -- local zp = Wherigo.ZonePoint(56.034841, 9.991811,0) CenterZoneOnPoint(zoneQ100, zp) ztimertimer1:Start() end ------End Builder Generated functions, Do not Edit, this will be overwritten------ Tools -> View Parse Errors...(1): Double Click the error: if you want to try it out, please mail me via my profile. I will do that. Quote Link to comment
+sTeamTraen Posted November 23, 2009 Share Posted November 23, 2009 (edited) The call: function zoneStartzone:OnEnter() -- #GroupDescription=Script -- -- #Comment=Script Comment -- local zp = Wherigo.ZonePoint(56.034841, 9.991811,0) CenterZoneOnPoint(zoneQ100, zp) ztimertimer1:Start() end ------End Builder Generated functions, Do not Edit, this will be overwritten------ Tools -> View Parse Errors...(1): Double Click the error: Yes, you've hit an issue with the Groundspeak builder: you can protect your own function definitions by putting them in the Author Functions section, but as far as I know, you can only protect the calls to those functions by commenting them out before you reopen the Lua file in the builder. It would be nice if the builder could at least skip a line containing just Lua-identifier(something,something,something) I have made you an Earwigo account. You can upload your existing Lua file into it. The upload function claims to be able to accept anything which the Groundspeak builder can output. Without examining the code closely, I can't say whether it will also accept your call of the author function. If it doesn't, the line will be omitted, and you will need to put it back as a "Lua statement". But after that, you shouldn't have to jump through hoops too much... well, apart from the bugs. Edited November 23, 2009 by sTeamTraen 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.