tile.lua 654 B

1234567891011121314151617181920212223242526272829303132
  1. --[[
  2. @module Sled:tileCmd
  3. ]]
  4. local Command = require "command"
  5. return Command("tile", {
  6. { "%", function (x, y)
  7. if not tonumber(x) or not tonumber(y) then return "bad input" end
  8. local x1, y1 = x or 1, y or 1
  9. local _x, _y = tonumber(x1)-1, tonumber(y1)-1
  10. local tx, ty = _x * Sled.tile_size, _y * Sled.tile_size
  11. Sled:tile(tx, ty):select()
  12. return string.format("x:%i y:%i selected", tx, ty)
  13. end
  14. },
  15. {
  16. "clear", function ()
  17. local tile = Sled.current_tile or Sled:tile(1, 1):select()
  18. tile:clear()
  19. end
  20. },
  21. {
  22. "flip", function (dir)
  23. local tile = Sled.current_tile or Sled:tile(1, 1):select()
  24. return tile:flip(dir)
  25. end
  26. },
  27. })