Just started with defold. Can’t figure out what I am doing wrong here.
tilemap.set_tile("#grid", “layer1”, 0,0, 1)
I get: ERROR:GAMESYS: Could not get the tile since the supplied tile was out of range.
My tile source is a 120 x 120 image with tile width=60 and tile height=60 i.e.divided into 4 frames, out of which the first 2 frames are coloured red and yellow while the other two are completely transparent.
Remember that your tilemap needs to have defined bounds, it can’t be completely empty. Put dummy tiles at least in the corners of the area that you wish to manipulate using set_tile().
I have a question about this - because the current Error statement:
Is pretty clear, but it doesn’t show the place when set_tile() or get_tile() was invoked - is it possible to add such info to the error message, preferably with a direct link to the place?
In one case I used way too much and had problems debugging, just time consuming But yeah, I was just wondering, but if it would break things, it’s unacceptable. It’s better to search for those calls then
It is usually very quick to monkey patch a Lua function and print callstack every time the function is invoked. It is a very quick way to debug when and from where functions are called.
-- save reference to original function
local tilemap_set_tile = tilemap.set_tile
-- replace with our custom function
tilemap.set_tile = function(...)
-- print stacktrace
print(debug.traceback())
-- call original function
return tilemap_set_tile(...)
end
This makes me realize it is possible to detect where in files things are being print() and pprint() if people have the habit of putting them in places and commenting them instead of deleting them thus making it harder to find…
-- save reference to original function
local local_print = print
-- replace with our custom function
print = function(...)
-- print stacktrace
local_print(debug.traceback())
-- call original function
local_print(...)
end
print("test")
stack traceback:
input:7: in function 'print'
input:12: in main chunk
[C]: in function 'pcall'
demo.lua:60: in main chunk
[C]: in ?
test