Skip to content

Commit

Permalink
Prevent lua errors when loading certain Noteskins in NSPreview
Browse files Browse the repository at this point in the history
related to some bad calculation for frame states, whatever
  • Loading branch information
poco0317 committed Mar 31, 2021
1 parent 0a62dac commit 4b01e2c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Themes/_fallback/Scripts/09 SimNSkinPreview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ function LoadNSkinPreview(Noteskin, Button, Element)
if TexY > 0 then
for _, i in pairs(SimChild(self, "Sprite")) do
local ani = i:GetNumStates()
local maxframes = i:GetTexture():GetNumFrames()
local Skip = 1
local TexY2 = (TexY * 64)
local StateF = {}
Expand All @@ -109,7 +110,9 @@ function LoadNSkinPreview(Noteskin, Button, Element)
end
for timer = 1, TexY2, Skip do
for frame = (ani * timer) - ani, (ani * timer) - 1 do
StateF[#StateF + 1] = {Frame = frame, Delay = 4 / ((TexY * 64) * ani)}
if frame < maxframes then
StateF[#StateF + 1] = {Frame = frame, Delay = 4 / ((TexY * 64) * ani)}
end
end
end
i:SetStateProperties(StateF)
Expand Down

0 comments on commit 4b01e2c

Please sign in to comment.