Marioman2007 wrote: ↑Mon Jan 01, 2024 6:40 am
LunarCatUSA wrote: ↑Mon Jan 01, 2024 3:50 am
Alright, so I've done all of this and it seems to generally function but now the frames count up to non-existent numbers when moving or standing still.
The code I have:
Code: Select all
v.animationFrame = npcutils.getFrameByFramestyle(v, {frame = v.data.frame, frames = DummehSettings.frames})
if status == 0 then
function OnTickEndNPC()
v.animationFrame = math.floor(lunatime.tick() / 8) % 2 + 2 --For the looking & standing frames
end
end
if status ~= 0 then
function OnTickEndNPC()
v.animationFrame = math.floor(lunatime.tick() / 8) % 2 --For walking frames
end
end
That's not how onTickEndNPC works, it's a function that needs to registered to the npc library using npcManager.registerEvent.
Code: Select all
function sampleNPC.onInitAPI()
npcManager.registerEvent(npcID, sampleNPC, "onTickEndNPC")
end
function sampleNPC.onTickEndNPC(v)
local extraFrames = 0 -- For walking frames
if status == 0 then
extraFrames = 2 -- For the looking & standing frames
end
local currentFrame = (math.floor(lunatime.tick() / 8) % 2) + extraFrames
v.animationFrame = npcutils.getFrameByFramestyle(v, {frame = currentFrame, frames = DummehSettings.frames})
end
Okay so I made the code this after initializing the onTickEndNPC(v) in the code further above
Code: Select all
function Dummeh.onTickEndNPC(v)
local extraFrames = 0 -- For walking frames
if status == 0 then
extraFrames = 2 -- For the looking & standing frames
end
local currentFrame = (math.floor(lunatime.tick() / 8) % 2) + extraFrames
v.animationFrame = npcutils.getFrameByFramestyle(v, {frame = currentFrame, frames = DummehSettings.frames})
end
And this is what happens with the npc, it works fine going to the left but frame breaks going right. I have a gif showing what happens but when going to the RIGHT moving, it alternates between frames 8 and 9, which do not exist so the npc is invisible.
Added in 4 hours 45 minutes 21 seconds:
AH HA! I fixed it! I just had to set the frames number to 4 to limit the frame loop to one direction.
Thanks so much for the help everyone!