VE Lua Documentation

Press F to search!

addPlanet

Definition


-- @/lua/vehicle/beamstate.lua:624

local function addPlanet(center, radius, mass, dt)
  if dt ~= nil then
    for pt = 1, #planetTimers do
      local i = planetTimers[pt][1]
      if planets[i] == center.x and planets[i + 1] == center.y and planets[i + 2] == center.z and planets[i + 3] == radius and planets[i + 4] == mass then
        if dt == 0 then
          delPlanetI(i)
          obj:setPlanets(planets)
        else
          planetTimers[pt][2] = dt
        end
        return
      end
    end

    if dt == 0 then
      return
    end
    table.insert(planetTimers, {#planets + 1, dt})
  end
  table.insert(planets, center.x)
  table.insert(planets, center.y)
  table.insert(planets, center.z)
  table.insert(planets, radius)
  table.insert(planets, mass)
  obj:setPlanets(planets)
end

Callers