Skip to content

Instantly share code, notes, and snippets.

@dacap
Created June 13, 2022 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacap/292d0fb10cc1bf5de0e4086173de4229 to your computer and use it in GitHub Desktop.
Save dacap/292d0fb10cc1bf5de0e4086173de4229 to your computer and use it in GitHub Desktop.
Creates a new tilemap layer with one tile per grid cell
local spr = app.activeSprite
if not spr then
return app.alert "You need to create a sprite first"
end
app.transaction(
function()
app.command.NewLayer{ name="Tilemap", tilemap=true }
local grid = spr.gridBounds
for y=grid.y,spr.height,grid.width do
for x=grid.x,spr.width,grid.width do
app.useTool{
tool='pencil',
brush=Brush(1),
color=Color{ index=1 },
tilemapMode=TilemapMode.PIXELS,
tilesetMode=TilesetMode.STACK,
points={ Point(x, y) }}
app.useTool{
tool='pencil',
brush=Brush(1),
color=spr.transparentColor,
tilemapMode=TilemapMode.PIXELS,
tilesetMode=TilesetMode.MANUAL,
points={ Point(x, y) }}
end
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment