Export Nova.lua
· 926 B · Lua
原始文件
Playground
local dialog = Dialog()
dialog:file{
id = "save_location",
label = "Save Location",
title = "Save Nova",
save = true,
filetypes = { "nv" },
}
dialog:button {
id = "save_button",
text = "Save",
onclick = function()
local sprite = app.sprite
local nova = {"||\n"}
for i, slice in ipairs(sprite.slices) do
table.insert(nova, ":slice:\n")
local x, y, w, h = slice.bounds.x, slice.bounds.y, slice.bounds.w, slice.bounds.h
table.insert(nova, (" . dimensions %d %d %d %d\n"):format(x, y, w, h))
table.insert(nova, (" . name %s\n"):format(slice.name))
end
local save_location = dialog.data.save_location
if save_location then
local file = io.open(save_location, "w")
file:write(table.concat(nova))
file:close()
end
end
}
local data = dialog:show().data
1 | local dialog = Dialog() |
2 | dialog:file{ |
3 | id = "save_location", |
4 | label = "Save Location", |
5 | title = "Save Nova", |
6 | save = true, |
7 | filetypes = { "nv" }, |
8 | } |
9 | dialog:button { |
10 | id = "save_button", |
11 | text = "Save", |
12 | onclick = function() |
13 | local sprite = app.sprite |
14 | local nova = {"||\n"} |
15 | for i, slice in ipairs(sprite.slices) do |
16 | table.insert(nova, ":slice:\n") |
17 | local x, y, w, h = slice.bounds.x, slice.bounds.y, slice.bounds.w, slice.bounds.h |
18 | table.insert(nova, (" . dimensions %d %d %d %d\n"):format(x, y, w, h)) |
19 | table.insert(nova, (" . name %s\n"):format(slice.name)) |
20 | end |
21 | local save_location = dialog.data.save_location |
22 | if save_location then |
23 | local file = io.open(save_location, "w") |
24 | file:write(table.concat(nova)) |
25 | file:close() |
26 | end |
27 | end |
28 | } |
29 | local data = dialog:show().data |