Object:getPosition() appears to return single value

I’m probably driving you batty by now with all these questions.

I know you had an object listener in your example for a spawnpoint but that has to occur before the map gets created. If you want to respawn the hero or any ‘baddies’ I need to get the spawnpoint from an object set in an object layer on the map. So I create an object and gave it a name and type so as to go get it info as follows:
[lua]local RopesLayer = map:getObjectLayer(“Ropes”)
local spawnpoint = RopesLayer:getObject(“Location1”,“HeroSpawn”)
print(spawnpoint)
local herolocation = spawnpoint:getPosition()
print(herolocation)[/lua]

The output appears to only give me the x location of the object.

WARNING: Simulator does not support multitouch events
table: 0xe32c4a0
113
canjump

Tell me if I’m doing it wrong :slight_smile: [import]uid: 9035 topic_id: 9140 reply_id: 309140[/import]

try
x,y = obj:getPosition()

i know lua supports this, but i havent looked at the docs for getPosition so i dont know if it returns 1 or 2 values [import]uid: 34945 topic_id: 9140 reply_id: 33349[/import]

Duh, I tried to pass the results to a table when I noticed in the function that it’s passing multiple values.

Didn’t know I could do that with lua. Still learning.

This works:
[lua]local herolocation = {}
herolocation.x, herolocation.y = spawnpoint:getPosition()[/lua] [import]uid: 9035 topic_id: 9140 reply_id: 33390[/import]

Glad to see it solved without me :slight_smile:

Originally the get positions returned tables however I was informed that the preferred style was to use multiple return values, I believe I have changed them all but if there are any left feel free to tell me. [import]uid: 5833 topic_id: 9140 reply_id: 33424[/import]

funny thing is, I didnt even notice this was in the LIME forums, and I had no idea what getPosition was referring to :wink:
I’ve never even looked at LIME before :smiley: [import]uid: 34945 topic_id: 9140 reply_id: 33491[/import]

Hehe, well now you know it exists feel free to look around :slight_smile: [import]uid: 5833 topic_id: 9140 reply_id: 33557[/import]