Skip to content

Instantly share code, notes, and snippets.

@edwardrowe
Last active December 6, 2018 01: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 edwardrowe/0d44a1a2997b42bb83842b304ded7471 to your computer and use it in GitHub Desktop.
Save edwardrowe/0d44a1a2997b42bb83842b304ded7471 to your computer and use it in GitHub Desktop.
Tag Navigator for Aseprite
local dlg = Dialog("Hero Tag Navigator")
dlg
:separator{text="Core Animations"}
:button{ text="Idle", onclick=function() selectStartingFrameForTag("IdleLoop_D") end}
:button{ text="Move", onclick=function() selectStartingFrameForTag("MoveLoop_D") end}
:button{ text="Walk", onclick=function() selectStartingFrameForTag("WalkLoop_D") end}
:button{ text="Dash", onclick=function() selectStartingFrameForTag("Dash_D") end}
:button{ text="EdgeJump", onclick=function() selectStartingFrameForTag("EdgeJump_D") end}
:newrow()
:button{ text="Dive", onclick=function() selectStartingFrameForTag("EnterDeepLiquid_D") end}
:button{ text="SwimIdle", onclick=function() selectStartingFrameForTag("SwimIdleLoop_D") end}
:button{ text="SwimMove", onclick=function() selectStartingFrameForTag("SwimMoveLoop_D") end}
:button{ text="PitFall", onclick=function() selectStartingFrameForTag("PitFall") end}
:separator{text="Attacks"}
:newrow()
:button{ text="A", onclick=function() selectStartingFrameForTag("SwingA_D") end}
:button{ text="B", onclick=function() selectStartingFrameForTag("SwingB_D") end}
:button{ text="C", onclick=function() selectStartingFrameForTag("SwingC_D") end}
:button{ text="Charge", onclick=function() selectStartingFrameForTag("HammerCharge_D") end}
:button{ text="Idle", onclick=function() selectStartingFrameForTag("HammerLoop_D") end}
:button{ text="Move", onclick=function() selectStartingFrameForTag("HammerMoveLoop_D") end}
:button{ text="Slam", onclick=function() selectStartingFrameForTag("HammerSlam_D") end}
:separator{text="Hit Reactions"}
:button{ text="Flinch", onclick=function() selectStartingFrameForTag("FlinchLoop_D") end}
:button{ text="Stumble", onclick=function() selectStartingFrameForTag("Stumble_D") end}
:button{ text="Up", onclick=function() selectStartingFrameForTag("KnockbackUp_R") end}
:button{ text="Down", onclick=function() selectStartingFrameForTag("KnockbackDown_R") end}
:button{ text="Land", onclick=function() selectStartingFrameForTag("KnockbackLanded_R") end}
:button{ text="GetUp", onclick=function() selectStartingFrameForTag("KnockbackGetUp_R") end}
:button{ text="Dying", onclick=function() selectStartingFrameForTag("Dying_R") end}
:button{ text="Dead", onclick=function() selectStartingFrameForTag("Dead_R") end}
:separator{text="Gadgets"}
:button{ text="Aim", onclick=function() selectStartingFrameForTag("AimLoop_D") end}
:button{ text="Shrunk Idle", onclick=function() selectStartingFrameForTag("ShrunkIdleLoop_D") end}
:button{ text="Shrunk Move", onclick=function() selectStartingFrameForTag("ShrunkMoveLoop_D") end}
:separator{text="Emotes / Misc"}
:button{ text="Cheer", onclick=function() selectStartingFrameForTag("EmoteCheerStart") end}
:button{ text="Radio", onclick=function() selectStartingFrameForTag("EmoteRadioStart") end}
:show{ wait=false }
function selectStartingFrameForTag(tagName)
local f = getStartingFrameForTag(tagName)
app.activeFrame = f
-- if they are playing an animation, restart it from the newly selected frame
if app.command.PlayAnimation() then
app.command.PlayAnimation()
end
end
function getStartingFrameForTag(tagName)
local tag = getTagByName(tagName)
if(tag ~= nil) then
return tag.fromFrame
else
return 0
end
end
function getTagByName(tagName)
local s = app.activeSprite
local tag = nil
for i = 1,#s.tags do
if s.tags[i].name == tagName then
tag = s.tags[i]
break
end
end
if tag == nil then
app.alert("Could not find tag by the specified name '" .. tostring(tagName) .. "'")
return nil
end
return tag
end
local function getNumTags()
local s = app.activeSprite
local num = 0
for i = 1,#s.tags do
num = num + 1
end
return num
end
local function selectStartingFrameForTag(tagName)
local f = getStartingFrameForTag(tagName)
app.activeFrame = f
-- if they are playing an animation, restart it from the newly selected frame
if app.command.PlayAnimation() then
app.command.PlayAnimation()
end
end
local function getStartingFrameForTag(tagName)
local tag = getTagByName(tagName)
if(tag ~= nil) then
return tag.fromFrame
else
return 0
end
end
local function getTagByName(tagName)
local s = app.activeSprite
local tag = nil
for i = 1,#s.tags do
if s.tags[i].name == tagName then
tag = s.tags[i]
break
end
end
if tag == nil then
app.alert("Could not find tag by the specified name '" .. tostring(tagName) .. "'")
return nil
end
return tag
end
-- Begin "main" --
if getNumTags() == 0 then
app.alert("No tags found in file. Add tags to navigate between them.'")
else
local config_numButtonsPerRow = 5 -- Edit this to suit your needs
local s = app.activeSprite
local dlg = Dialog("Tag Navigator")
for i = 1,#s.tags do
if((i - 1) % config_numButtonsPerRow == 0) then
dlg:newrow()
end
dlg:button{ text = s.tags[i].name, onclick=function() selectStartingFrameForTag(s.tags[i].name) end}
end
dlg:show{ wait=false }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment