I’m trying to determine how to update this function to randomly generate different images to spawn. I’ve tried numerous ways that I can think of… and have gotten it to rotate through the different images however I’m still confused as everything I’ve found doesn’t match this use.
It generates different images to a grid, and fills the grid with an image after x timer. I tried setting a math.random / math.randomseem variable but somehow it didn’t work correctly still. I also tried a function within the function however it returns more than 60 chars so it errors out…
Hopefully that’s enough info for someone to help me?
Let me know if not.
Current:
local function bunnyAnimation()
for i, obj in pairs(bunny) do
if bunny[i].hit < bunny[i].hit_q then bunny[i].timer = bunny[i].timer + tDelta
else bunny[i].timer = bunny[i].timer - tDelta end
if bunny[i].timer < 0 then
killObj(bunny[i])
end
step = 30
if bunny[i].timer >= 0 and bunny[i].timer < step then bunny[i].fill = {type=“image”, filename=“Images/base/bunny1.png”}
elseif bunny[i].timer >= step and bunny[i].timer < 2*step then bunny[i].fill = {type=“image”, filename=“Images/base/bunny2.png”}
elseif bunny[i].timer >= 2*step and bunny[i].timer < 3*step then bunny[i].fill = {type=“image”, filename=“Images/base/bunny3.png”}
elseif bunny[i].timer >= 3*step then bunny[i].fill = {type=“image”, filename=“Images/base/bunny4.png”}
end
if bunny[i].timer>=1000 then
bunny[i].hit = 5
bunny[i].status = “idle”
bunny[i].timer = 3*step
end
end
end