--- So. The main problem with this approach is... it is LOUD local girders = {} local clusters = {} local lastClusterTick = 0 local direction = 1 local SeqLeft = 0 local SeqRight = 0 local CurrPos = 0 -- uses milliseconds but could obviously be once a turn or whatever. local StepTime = 2000 local PlatWidth = 5 local hogs = {} local balls = {} -- This test is just using short horizontal right now -- it is LOUD so considering adding lua access to tunnel/circle erasure function removeGirder(g) if g.type == 0 then for i = -36,36,6 do clusters[AddGear(g.x+i,g.y+6,gtCluster,gstCollision,0,0,10)]=1 clusters[AddGear(g.x+i,g.y-6,gtCluster,gstCollision,0,0,10)]=1 end lastClusterTick = GameTime end end function onAddGear(g) if GetGearType(g) == gtHedgehog then hogs[g] = 1 end end function onGameStart() PlaceGirder(LeftX+82,TopY+100,4) PlaceGirder(RightX-82,TopY+100,4) -- Locate a sequence width that is 80, for prettiness. local w = div(RightX-LeftX-160,80)*80 local o = div(RightX-LeftX-160-w,2) SeqLeft = LeftX+80+o SeqRight = RightX-80-o SeqTop = TopY+150 CurrPos = SeqLeft local vg = AddVisualGear(SeqLeft-40, SeqTop, vgtStraightShot, 0, true) g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vg) g3 = 0 g4 = 0 --g5 = 90 -- angle g6 = 3 -- frame g7 = 999999999 -- frameticks g8 = 143 -- sprite SetVisualGearValues(vg,g1, g2, g3, g4, g5, g6, g7, g8, g9, g10) vg = AddVisualGear(SeqRight+40, SeqTop, vgtStraightShot, 0, true) g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vg) g3 = 0 g4 = 0 --g5 = 270 g6 = 1 -- frame g7 = 999999999 -- frameticks g8 = 143 SetVisualGearValues(vg,g1, g2, g3, g4, g5, g6, g7, g8, g9, g10) end -- figured scheduled deletes could be useful for various opening and closing gates and whatnot. function onGameTick20() -- this obv requires a StepTime divisible by 20 if GameTime % StepTime == 0 then if (direction == 1 and CurrPos < SeqRight) or (direction == -1 and CurrPos > SeqLeft) then PlaceGirder(CurrPos,SeqTop,0) girders[#girders+1] = {x=CurrPos,y=SeqTop,type=0, deleteMe=GameTime+10000} CurrPos = CurrPos + 80*direction end end -- thought here was to allow more complex animations than this simple "one a time" for c,g in pairs(girders) do if GameTime > g.deleteMe then -- experiment shoving hogs along out of removegirder danger area -- didn't seem to shove, and would probably need to find something that sets all gears to active -- for h,i in pairs(hogs) do -- dx,dy = GetGearVelocity(h) -- if dx < 1000 and dy < 1000 and -- ((direction == 1 and gearIsInBox(h, g.x, g.y-50,300,50)) or -- (direction == -1 and gearIsInBox(h, g.x-160, g.y-50,300,50))) then -- AddCaption("Shoving a hog") -- SetGearVelocity(h,dx+100000*direction,dy) -- end -- end removeGirder(g) if (direction == -1 and g.x < SeqLeft+80) or (direction == 1 and g.x > SeqRight-80) then direction = direction * -1 end girders[c] = nil end end if GameTime > lastClusterTick then for c,i in pairs(clusters) do DeleteGear(c) clusters[c]=nil end end end