IT WORKS!
I can't believe it, it works.
But if you have too much, it taxes the system, so there is some judgement or moderation.
But it's easy to set up!
Here is my sample code:
objects.lua:
Code: Select all
for i=1,360 do
defineObject{
name = "machine_socket_west_"..i,
class = "Alcove",
anchorPos = vec(0.08, 1.765, 0.5),
anchorRotation = vec(90, 0, i),
targetPos = vec(0.08, 1.765, 0.5),
targetSize = vec(0.3, 0.3, 0.3),
placement = "wall",
onInsertItem = function(self, item)
return item.name == "machine_part_west_not" and self:getItemCount() == 0
end,
editorIcon = 92,
}
end
In the dungeon:
Code: Select all
gearTick = 1
function gearAnim()
if gearTick < 361 then
if findEntity("gearSock") ~= nil then
for i in gearSock:containedItems() do
i:destroy()
end
gearSock:destroy()
end
spawn("machine_socket_west_"..gearTick, 1, 2, 24, 1, "gearSock")
:addItem(spawn("machine_part_west_not"))
end
if gearTick == 360 then
gearTick = 0
end
gearTick = gearTick + 1
end
This is using a gear object and socket set up for my custom Cube, but it could work for anything I suppose.
I also just have a pressure plate linked to activate a timer set to 0.01 that ticks the script forever (once it gets to 360, it does the 360, then sets it to 0, then it immediately is set to 1 for the next round)
In the game when I step on the plate I see the gear appear and start to slowly spin around, very smooth and nice!
PS, there is a speed limit on the timers, as 0.01 seems no faster than 0.03, but 0.03 is definitely faster than 0.1
----------------------
EDIT - I've found 120 works smoother (at least for this small gear), with the objects.lua code using i*3 (so i=1,120 gets you from 3 degrees to 360 degrees), then set the ticker timer to 0.1, quite smooth