Jump to content

ObjectLocation


The Cartooners

Recommended Posts

Posted (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 by The Cartooners
Posted

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.)

Posted

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()

Posted

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

Posted

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

Posted

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.

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...