Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Multiple tilesets in with Tilemap question — Gideros Forum

Multiple tilesets in with Tilemap question

GreywineGreywine Member
edited July 2015 in Game & application design
Hi,
@atilim posted some code that's supposed to handle multiple tilesets...

http://giderosmobile.com/forum/discussion/699/using-tiled/p1

But when I tried to add an additional tileset in his code, I get the following error:

tilemapmultiple.lua:14: attempt to call a nil value
stack traceback:
tilemapmultiple.lua:14: in function 'init'
[string "property.lua"]:52: in function '__new'
[string "property.lua"]:59: in function 'new'
main.lua:2: in main chunk

Since this code is designed to load multiple tilesets and multiple layers, I'm not sure why it's failing at the beginning when it loads the platformer.lua file when there is an additional tileset there.

Any ideas? The code is attached.

Comments

  • Accepted Answer
    After trying the code, i found that platformer.lua does not return table, it is missing some { and }.

    Try this:
    return { version = "1.1", 
    		luaversion = "5.1", 
    		orientation = "orthogonal", 
    		width = 20, 
    		height = 10, 
    		tilewidth = 32, 
    		tileheight = 32, 
    		properties = {}, 
    tilesets = { 
    			{ 	name = "tileset-platformer", 
    				firstgid = 1, 
    				tilewidth = 32, 
    				tileheight = 32, 
    				spacing = 0, 
    				margin = 0, 
    				image = "tileset-platformer.png", 
    				imagewidth = 192, 
    				imageheight = 544, 
    				properties = {}, 
    				tiles = {} 
    			}, 
    			{ 	name = "monster_tileset", 
    				firstgid = 103, 
    				tilewidth = 25, 
    				tileheight = 25, 
    				spacing = 0, 
    				margin = 0, 
    				image = "monster_tileset.png", 
    				imagewidth = 250, 
    				imageheight = 250, 
    				properties = {}, 
    				tiles = {} 
    				}, 
    			},
    layers = { { type = "tilelayer", name = "background", x = 0, y = 0, width = 20, height = 10, visible = true, opacity = 1, properties = {}, 
    encoding = "lua", data = { 	0, 0, 0, 51, 52, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    							0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 52, 53, 0, 0, 0, 64, 0, 0, 0, 0, 
    							0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 0, 
    							0, 0, 58, 0, 58, 0, 0, 0, 59, 0, 59, 0, 0, 0, 0, 65, 0, 0, 0, 0, 
    							0, 1, 2, 2, 2, 3, 0, 4, 5, 5, 5, 5, 6, 0, 13, 14, 15, 0, 0, 0, 
    							0, 7, 8, 8, 8, 9, 0, 10, 11, 11, 11, 11, 12, 0, 19, 20, 21, 0, 
    							0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    							0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    							0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    							0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
    							}
    							}
     
    							}
    I also fix the bug where image name is monster_tileset.png not monster-tileset.png

    Now there is known bug that when user click on the screen :) I do not know maybe because of changing platformer.lua or not ...
    zip
    zip
    054044a4f2e37d5aeb69526d62cfa4.zip
    85K
    Coming soon
  • Thanks so much. I'm making progress in understanding TileMap, GiderosMobile and Lua in general.
    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.