Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Basic Coding help needed — Gideros Forum

Basic Coding help needed

joelghilljoelghill Member
edited July 2012 in General questions
I feel stupid for asking this, but I'm having trouble with a for loop when loading a tilemap.

for i=1, #map.layers do
local layer = map.layers[i]

local tilemaps = {}
local group = Sprite.new()

7. for y=1, layer.height do -- error here
8. for x=1,layer.width do -- error here
local i = x + (y - 1) * layer.width
local gid = layer.data[i]
local tileset = gid2tileset(map, gid)

---- loop logic




For some reason on line 7 (and 8) I get an error saying "'for' limit must be a number".

I can't figure out what's wrong, as I am able to print the number stored in layer.height and layer.width immediately before the loop! Is the for loop redefining what layer.height is? The crazy part is that I had this working before and now it's magically broken. Sigh.

Big thanks in advance to anyone that can give me a hint!

P.S: Also... how does one display properly formatted code in a forum post? I've seen it around but don't know how it's done....


Sign In or Register to comment.