Error While loading Object TiledMap

Hi,

Here is the code:

local tiled = require "com.ponywolf.ponytiled" local json = require "json" local mapData = json.decodeFile(system.pathForFile("maps/objects/un.json", system.ResourceDirectory)) -- load from json export local map = tiled.new(mapData, "maps/objects") -- center the map on screen map.x,map.y = display.contentCenterX - map.designedWidth/2, display.contentCenterY - map.designedHeight/2 -- drag the whole map for fun local dragable = require "com.ponywolf.plugins.dragable" map = dragable.new(map)

Here is the error:

21:06:29.040  Copyright © 2009-2017  C o r o n a   L a b s   I n c .

21:06:29.040  Version: 3.0.0

21:06:29.040  Build: 2017.3184

21:06:29.050  Platform: iPhone / x64 / 6.1 / ATI Radeon HD 5400 Series / 4.5.13399 Compatibility Profile Context 15.200.1062.1004 / 2017.3184 / en_US | US | en_US | en

21:06:29.050  Loading project from:   C:\Users\user\Documents\Corona Projects\ponytiled-master - Test

21:06:29.050  Project sandbox folder: C:\Users\user\AppData\Local\Corona Labs\Corona Simulator\Sandbox\ponytiled-master - test-3D9E7C65AC2A387CA8272061669E75AB\Documents

21:06:29.070  WARNING: External tilesets only suported for tilesheets…

21:06:29.070  ERROR: Runtime error

21:06:29.070  C:\Users\user\Documents\Corona Projects\ponytiled-master - Test\com\ponywolf\ponytiled.lua:142: attempt to compare number with nil

21:06:29.070  stack traceback:

21:06:29.070  C:\Users\user\Documents\Corona Projects\ponytiled-master - Test\com\ponywolf\ponytiled.lua:142: in function ‘gidLookup’

21:06:29.070  C:\Users\user\Documents\Corona Projects\ponytiled-master - Test\com\ponywolf\ponytiled.lua:197: in function ‘new’

21:06:29.070  C:\Users\user\Documents\Corona Projects\ponytiled-master - Test\main.lua:28: in main chunk

Why? I created the map using tiled and exported both lua and json. loaded json map, but am getting this message. But tiled layered is working well, not object oriented. What is the solution?

Thanks, Regards,

VKV

Hi.  This is a high level issue you’ll have to debug on your own.  Fortunately, you can, since you have all the source code for the loader in your project. 

You can follow it from beginning to end, or work your way backwards.  

Did into what this function is doing:

local map = tiled.new(mapData, "maps/objects")

Corona is already telling you where the error is, so working backwards from there seems the most logical.

Just add print statements to the ponywolf code till you understand how it runs and what it is doing.  You’ll eventually figure out what is missing.

That said, It looks like a texture of some kind is needed and not present.

PS - There is nothing wrong with the code by the way.  It is how you are using it and whether you’re supplying the assets correctly that is the issue.  

From the warning " External tilesets only suported for tilesheets" it seems like you may be using a feature of tiled the library doesn’t support.

I’d also  go back and walk through all of PonyWolf’s tutorials, guides, videos etc.  He must mention something about this.

Sorry I can’t just tell you, “here is the problem”, but that is simply the way it goes when you’re using high-level libraries and features.  

local tiled = require "com.ponywolf.ponytiled" local mapData = require "maps.trial.trial" local map = tiled.new(mapData, "maps/trial") -- center the map on screen map.x,map.y = display.contentCenterX - map.designedWidth/2, display.contentCenterY - map.designedHeight/2 -- drag the whole map for fun local dragable = require "com.ponywolf.plugins.dragable" map = dragable.new(map)

This is the solution. Loaded with map.lua file. Pardon me.

Thanks roaminggamer, You are always around, my hearty greetings.

this is the link finally i followed: https://github.com/ponywolf/ponytiled

Right, I will go through it and have a try. The thing is that if am loading ‘trial.json’ then this is the error:

22:00:44.239  Copyright © 2009-2017  C o r o n a   L a b s   I n c .

22:00:44.239  Version: 3.0.0

22:00:44.239  Build: 2017.3184

22:00:44.249  Platform: iPhone / x64 / 6.1 / ATI Radeon HD 5400 Series / 4.5.13399 Compatibility Profile Context 15.200.1062.1004 / 2017.3184 / en_US | US | en_US | en

22:00:44.249  Loading project from:   C:\Users\user\Documents\Corona Projects\ponytiled-master - Test

22:00:44.249  Project sandbox folder: C:\Users\user\AppData\Local\Corona Labs\Corona Simulator\Sandbox\ponytiled-master - test-3D9E7C65AC2A387CA8272061669E75AB\Documents

22:00:44.269  ERROR: Runtime error

22:00:44.269  module ‘maps.trial.trial.json’ not found:

22:00:44.269  no field package.preload[‘maps.trial.trial.json’]

22:00:44.269  no file ‘C:\Users\user\AppData\Roaming\Corona Labs\Corona Simulator\Plugins\maps\trial\trial\json.lua’

22:00:44.269  no file ‘C:\Users\user\Documents\Corona Projects\ponytiled-master - Test\maps\trial\trial\json.lua’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\Resources\maps\trial\trial\json.lua’

22:00:44.269  no file ‘.\maps\trial\trial\json.lua’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\lua\maps\trial\trial\json.lua’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\lua\maps\trial\trial\json\init.lua’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\maps\trial\trial\json.lua’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\maps\trial\trial\json\init.lua’

22:00:44.269  no file ‘C:\Users\user\AppData\Roaming\Corona Labs\Corona Simulator\Plugins\maps\trial\trial\json.dll’

22:00:44.269  no file ‘.\maps\trial\trial\json.dll’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\Resources\maps\trial\trial\json.dll’

22:00:44.269  no file ‘.\maps\trial\trial\json.dll’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\maps\trial\trial\json.dll’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\loadall.dll’

22:00:44.269  no file ‘C:\Users\user\AppData\Roaming\Corona Labs\Corona Simulator\Plugins\maps.dll’

22:00:44.269  no file ‘.\maps.dll’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\Resources\maps.dll’

22:00:44.269  no file ‘.\maps.dll’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\maps.dll’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\loadall.dll’

22:00:44.269  no file ‘C:\Users\user\AppData\Roaming\Corona Labs\Corona Simulator\Plugins\maps.trial.trial.json.dll’

22:00:44.269  no file ‘.\maps.trial.trial.json.dll’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\Resources\maps.trial.trial.json.dll’

22:00:44.269  no file ‘.\maps.trial.trial.json.dll’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\maps.trial.trial.json.dll’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\loadall.dll’

22:00:44.269  stack traceback:

22:00:44.269  [C]: in function ‘require’

22:00:44.269  ?: in function ‘require’

22:00:44.269  C:\Users\user\Documents\Corona Projects\ponytiled-master - Test\main.lua:27: in main chunk

I think only lua format works here. What am thinking is that the json decoding has some issue. I do not know. :-/

Again, I doubt there is an issue with PonyWolf’s code.

Also, I’m not trying to dissuade you from asking for help, but I do want to point out:

  • The ratio of folks who read and answer posts to those who use this specific piece of code may be small.
  • (not an admonishment) This is the danger of using code without understanding how it works.  When it doesn’t work you’re stuck till you understand it.  
  • If this were a paid product you might be able to ask for direct support, but since this is something given for free (and at the expense of paid time on the author’s part)… you’re just going to have to debug it.

That said, it should be a pretty easy debug so I am sure you’ll work it out soon.

Good luck on this.

Cheers,

Ed

Got it. Thanks for the reply. I am basically an architect. I play games, now I want to make one. First I want to learn the software and all methods first. Am trying out. 

Cheers

Have a great day. 

Both formats are working correctly. Look at StickerKnight platformer example. There are json maps generated (You CAN open/save json in Tiled, use this possibility)
 
Look this small attached example

thanks for the example, it is working.

Thanks for the sample. 

Hi.  This is a high level issue you’ll have to debug on your own.  Fortunately, you can, since you have all the source code for the loader in your project. 

You can follow it from beginning to end, or work your way backwards.  

Did into what this function is doing:

local map = tiled.new(mapData, "maps/objects")

Corona is already telling you where the error is, so working backwards from there seems the most logical.

Just add print statements to the ponywolf code till you understand how it runs and what it is doing.  You’ll eventually figure out what is missing.

That said, It looks like a texture of some kind is needed and not present.

PS - There is nothing wrong with the code by the way.  It is how you are using it and whether you’re supplying the assets correctly that is the issue.  

From the warning " External tilesets only suported for tilesheets" it seems like you may be using a feature of tiled the library doesn’t support.

I’d also  go back and walk through all of PonyWolf’s tutorials, guides, videos etc.  He must mention something about this.

Sorry I can’t just tell you, “here is the problem”, but that is simply the way it goes when you’re using high-level libraries and features.  

local tiled = require "com.ponywolf.ponytiled" local mapData = require "maps.trial.trial" local map = tiled.new(mapData, "maps/trial") -- center the map on screen map.x,map.y = display.contentCenterX - map.designedWidth/2, display.contentCenterY - map.designedHeight/2 -- drag the whole map for fun local dragable = require "com.ponywolf.plugins.dragable" map = dragable.new(map)

This is the solution. Loaded with map.lua file. Pardon me.

Thanks roaminggamer, You are always around, my hearty greetings.

this is the link finally i followed: https://github.com/ponywolf/ponytiled

Right, I will go through it and have a try. The thing is that if am loading ‘trial.json’ then this is the error:

22:00:44.239  Copyright © 2009-2017  C o r o n a   L a b s   I n c .

22:00:44.239  Version: 3.0.0

22:00:44.239  Build: 2017.3184

22:00:44.249  Platform: iPhone / x64 / 6.1 / ATI Radeon HD 5400 Series / 4.5.13399 Compatibility Profile Context 15.200.1062.1004 / 2017.3184 / en_US | US | en_US | en

22:00:44.249  Loading project from:   C:\Users\user\Documents\Corona Projects\ponytiled-master - Test

22:00:44.249  Project sandbox folder: C:\Users\user\AppData\Local\Corona Labs\Corona Simulator\Sandbox\ponytiled-master - test-3D9E7C65AC2A387CA8272061669E75AB\Documents

22:00:44.269  ERROR: Runtime error

22:00:44.269  module ‘maps.trial.trial.json’ not found:

22:00:44.269  no field package.preload[‘maps.trial.trial.json’]

22:00:44.269  no file ‘C:\Users\user\AppData\Roaming\Corona Labs\Corona Simulator\Plugins\maps\trial\trial\json.lua’

22:00:44.269  no file ‘C:\Users\user\Documents\Corona Projects\ponytiled-master - Test\maps\trial\trial\json.lua’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\Resources\maps\trial\trial\json.lua’

22:00:44.269  no file ‘.\maps\trial\trial\json.lua’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\lua\maps\trial\trial\json.lua’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\lua\maps\trial\trial\json\init.lua’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\maps\trial\trial\json.lua’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\maps\trial\trial\json\init.lua’

22:00:44.269  no file ‘C:\Users\user\AppData\Roaming\Corona Labs\Corona Simulator\Plugins\maps\trial\trial\json.dll’

22:00:44.269  no file ‘.\maps\trial\trial\json.dll’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\Resources\maps\trial\trial\json.dll’

22:00:44.269  no file ‘.\maps\trial\trial\json.dll’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\maps\trial\trial\json.dll’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\loadall.dll’

22:00:44.269  no file ‘C:\Users\user\AppData\Roaming\Corona Labs\Corona Simulator\Plugins\maps.dll’

22:00:44.269  no file ‘.\maps.dll’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\Resources\maps.dll’

22:00:44.269  no file ‘.\maps.dll’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\maps.dll’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\loadall.dll’

22:00:44.269  no file ‘C:\Users\user\AppData\Roaming\Corona Labs\Corona Simulator\Plugins\maps.trial.trial.json.dll’

22:00:44.269  no file ‘.\maps.trial.trial.json.dll’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\Resources\maps.trial.trial.json.dll’

22:00:44.269  no file ‘.\maps.trial.trial.json.dll’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\maps.trial.trial.json.dll’

22:00:44.269  no file ‘C:\Program Files (x86)\Corona Labs\Corona\loadall.dll’

22:00:44.269  stack traceback:

22:00:44.269  [C]: in function ‘require’

22:00:44.269  ?: in function ‘require’

22:00:44.269  C:\Users\user\Documents\Corona Projects\ponytiled-master - Test\main.lua:27: in main chunk

I think only lua format works here. What am thinking is that the json decoding has some issue. I do not know. :-/

Again, I doubt there is an issue with PonyWolf’s code.

Also, I’m not trying to dissuade you from asking for help, but I do want to point out:

  • The ratio of folks who read and answer posts to those who use this specific piece of code may be small.
  • (not an admonishment) This is the danger of using code without understanding how it works.  When it doesn’t work you’re stuck till you understand it.  
  • If this were a paid product you might be able to ask for direct support, but since this is something given for free (and at the expense of paid time on the author’s part)… you’re just going to have to debug it.

That said, it should be a pretty easy debug so I am sure you’ll work it out soon.

Good luck on this.

Cheers,

Ed

Got it. Thanks for the reply. I am basically an architect. I play games, now I want to make one. First I want to learn the software and all methods first. Am trying out. 

Cheers

Have a great day. 

Both formats are working correctly. Look at StickerKnight platformer example. There are json maps generated (You CAN open/save json in Tiled, use this possibility)
 
Look this small attached example

thanks for the example, it is working.

Thanks for the sample.