At the moment I’m trying to create a custom animation plugin however I have run into an issue; In my for loop I’m looping from 0,Specified animation length. However the issue with this is that it skips the last iteration (Code below)
local function round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end
local function getDecimals(n)
if type(n) ~= "number" then return end
n = tostring(n)
local _,End = string.find(n,"%.")
End += 1
local rest = string.sub(n,End,#n)
return rest
end
-------------------
self.animationData = {
["timelineLength"] = 1,
["timelineIncrement"] = 0.01,
["required"] = turnNodesIntoRequired(BasisNodes,TargetingNodes),
["timeline"] = generateEmptyTimeline(TimelineLength),
}
-------------------
for t = 0,self.animationData.timelineLength,self.animationData.timelineIncrement do
t = round(t,#getDecimals(self.animationData.timelineIncrement))
t = tostring(t)
print(t)
end
Output:
(Don’t mind the error that’s from the plugin being run in-game)
Any help is appreciated!