Advertisement
NovaYoshi

Aseprite fast palette switch

Mar 12th, 2021
1,656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.05 KB | None | 0 0
  1. function switch_to_palette(fname)
  2.     if fname == "" then return end
  3.  
  4.     local newPalette = Palette{ fromFile=fname }
  5.     if not newPalette then
  6.         print("Could not load palette")
  7.         return
  8.     end
  9.     oldPalette = app.activeSprite.palettes[1]
  10.     if #newPalette < #oldPalette then  -- Never move to a smaller palette, to be safe
  11.         newPalette:resize(#oldPalette)
  12.     end
  13.     app.activeSprite:setPalette(newPalette)
  14. end
  15.  
  16. local dlg = Dialog("Fast Palette Swap")
  17. dlg
  18.   :button{text="1",onclick=function() switch_to_palette(dlg.data.pal1) end}
  19.   :button{text="2",onclick=function() switch_to_palette(dlg.data.pal2) end}
  20.   :button{text="3",onclick=function() switch_to_palette(dlg.data.pal3) end}
  21.   :button{text="4",onclick=function() switch_to_palette(dlg.data.pal4) end}
  22.   :newrow()
  23.   :file{ id="pal1", title="Select a file for palette 1", open=true}
  24.   :file{ id="pal2", title="Select a file for palette 2", open=true}
  25.   :file{ id="pal3", title="Select a file for palette 3", open=true}
  26.   :file{ id="pal4", title="Select a file for palette 4", open=true}
  27.   :show{wait=false}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement