+HackAMen Posted October 30, 2014 Share Posted October 30, 2014 (edited) Hi, I have been trying to use the method GetAllOfType of a cart to list all the zones, ala objMyCart:GetAllOfType('Zone') I see that this works in the emulator but when I try to use it in WhereYouGo built with Urwigo I get an exception, namely Tried to call nil. I've seen that there were issues, namely https://code.google.com/p/openwig/issues/detail?id=160 but as that was some time ago I'd hoped that it was fixed. Not only that, but I've tried this rather basic call which is working in the emulator but not WhereYouGo local dist, angle = Wherigo.VectorToZone( Player.ObjectLocation, objTest1 ) objTest1 is a zone created in Urwigo It also fails with 'Tried to call nil' Am I missing something? Thanks. Edited October 30, 2014 by HackAMen Quote Link to comment
+charlenni Posted October 30, 2014 Share Posted October 30, 2014 There isn't such a function in OpenWIG. You have to write it by your own. It isn't very difficult. function GetAllOfType(type) result = {} for k,v in ipairs(cart.AllZObjects) do if Wherigo.NoCaseEquals(tostring(v), "a "..type.." instance") then table.insert(result, v) end end return result end Call it for example by for k,v in ipairs(GetAllOfType("Zone")) do print(v.Name) end to get all Zones or for k,v in ipairs(GetAllOfType("ZItem")) do print(v.Name) end to get all ZItem objects. Quote Link to comment
+HackAMen Posted October 31, 2014 Author Share Posted October 31, 2014 (edited) Thank you so much, that's spot on. I have to ask for some more help though. Using your code I have created this for k,v in ipairs(objTestCartridge.AllZObjects) do if Wherigo.NoCaseEquals(tostring(v), "a Zone instance") then if Wherigo.NoCaseEquals( tostring(v.Name), "Test1" ) then dist, angle = Wherigo.VectorToZone( Player.ObjectLocation, v ) break end end end I am getting a 'Tried to call nil' exception on Wherigo.VectorToZone again in WhereYouGo and not the emulator. Would you say that VectorToZone is not implemented in Wherigo or that ObjectLocation is not, or something else? I should say Player = Wherigo.Player /edit OK looking at https://code.google.com/r/biylda-openwig/source/browse/OpenWIGLibrary/src/cz/matejcik/openwig/WherigoLib.java It looks like VetorToPoint is implemented but not VectorToZone. Does that seem correct to you? /edit 2 After reading this http://forums.Groundspeak.com/GC/index.php?showtopic=316825 I can confirm that VectorToPoint works in WhereYouGo and it does exactly what I need. Thanks for pointing me in the right direction! Edited October 31, 2014 by HackAMen 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.