The Cartooners Posted September 11, 2008 Share Posted September 11, 2008 (edited) The code below for _,v in ipairs(cartUphillChallenge:GetAllOfType('ZItem')) do print("Item: " .. v.Name .. " is in location: " .. v.ObjectLocation) end generates the following error attempt to concatenate ObjectLocation Does anyone know what the problem might be and how do I fix it. Thanks in advance Edited September 11, 2008 by The Cartooners Quote Link to comment
Ranger Fox Posted September 11, 2008 Share Posted September 11, 2008 ObjectLocation should be an object. You're trying to reduce ObjectLocation to a string when it doesn't have an implicit string conversion. Did you try "v.ObjectLocation.Name"? That might work. (I'm answering this at work, so don't have enough time to test my own suggestion.) Quote Link to comment
The Cartooners Posted September 11, 2008 Author Share Posted September 11, 2008 ObjectLocation should be an object. You're trying to reduce ObjectLocation to a string when it doesn't have an implicit string conversion. Did you try "v.ObjectLocation.Name"? That might work. (I'm answering this at work, so don't have enough time to test my own suggestion.) No joy on that one Ranger. What I need is a ToString() Quote Link to comment
The Cartooners Posted September 11, 2008 Author Share Posted September 11, 2008 Thats it: tostring Here is the modified code for _,v in ipairs(cartUphillChallenge:GetAllOfType('ZItem')) do print("Item: " .. v.Name .. " is in location: " .. tostring(v.ObjectLocation)) end which produces an iteration of all items like this Item: Sword is in location ZonePoint(51.xxxxx, -2.xxxxx, Distance(0, 'm')) etc etc Hope this helps someone Quote Link to comment
+Geofellas Posted September 11, 2008 Share Posted September 11, 2008 I think you could get the individual lat and long (as numbers) this way too if you needed it. I know it works when I do Player.ObjectLocation.latitude etc. lat = v.ObjectLocation.latitude long = v.ObjectLocation.longitude Quote Link to comment
Ranger Fox Posted September 12, 2008 Share Posted September 12, 2008 Oh! ObjectLocation is of type ZonePoint! Then, yes, the latitude and longitude properties will be available and not a name. Thank you, Geofellas. Boy do I get sloppy when I can't test out my own ideas before posting. 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.