capitalex revised this gist 5 months ago. Go to revision
1 file changed, 29 insertions
Export Nova.lua (file created)
| @@ -0,0 +1,29 @@ | |||
| 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 | |
Newer
Older