TIC-80
TIC-80 copied to clipboard
Add colorkey return value to remap callback for map()
For the purpose of using custom transparency on certain tiles, or make a tile opaque.
I guess you can do it using flags
I don't understand where we can get this color from?
Why does there need to be an input? The remap callback could just be:
-- (tile, x, y) -> tile, colorkey, flip, rotate
local function remap(tile,x,y)
local colorkey = math.random(0,15)
return tile, colorkey, false, false
end
map(0, 0, 30, 17, 0, 0, -1, 1, remap)
Or if you want an input, just pass through what was provided to map:
-- (tile, x, y) -> tile, colorkey, flip, rotate
local function remap(tile, colorkey, x, y)
colorkey = math.random(0,15)
return tile, colorkey, false, false
end
map(0, 0, 30, 17, 0, 0, -1, 1, remap) -- the colorkey passed to "remap" will be -1
I got it, thanks. Let's try adding this, of course if it won't break compatibility.
Thought: I think we should consider map
is/was (originally?) intended just meant to be a simple "easy to get started" helper (no?), it doesn't need to do everything under the sun. If someone wants to write a custom map
function it's just a few lines of code...
Other than that thought, no other real objections to this - seems a useful utility - I just think it can be done easily enough without needing to be part of the core. :)
- I don't think there are any binary compatibility issues with this since WASM doesn't implement
remap
yet... - Obviously we can't add a middle param though, it would have to be the last param for backwards compatibility