objects = {} textitem = nil enabled = true waittime = 0 function onShipEnteredZone(ship, zone, zoneType, zoneId) if waittime <= 0 then if enabled then enabled = false textitem:setText("OFF") for index, object in ipairs(objects) do object:setVel(0, 0) end else textitem:setText("ON") enabled = true end textitem:setGeom(textitem:getGeom()) -- this line is to properly send packUpdate to clients waittime = 500 end end function onTick(timePassed) if waittime >= 0 then waittime = waittime - timePassed end if enabled then for index, object in ipairs(objects) do vel = object:getVel() pos = object:getLoc() a = math.atan2(pos.x, pos.y) object:setVel(vel.x - math.cos(a) * 2 * timePassed, vel.y + math.sin(a) * 2 * timePassed) end end end function main() for a = 1, 100 do objects[a] = ResourceItem.new() objects[a]:setLoc(math.cos(a * 2.3) * (400 + a), math.sin(a * 2.3) * (400 + a)) levelgen:addItem(objects[a]) a=a+1 end textitem = TextItem.new() textitem:setText("ON") textitem:setGeom(-175, 190, -50, 190) levelgen:addItem(textitem) enabled = true waittime = 0 subscribe(Event.tick) subscribe(Event.ShipEnteredZone) end