PhysicsTick Event - TechTastic/CC-VS GitHub Wiki

PhysicsTick Event

This event exposes a Lua-wrapped version of PhysShipImpl from the PhysTickEventHandler named LuaPhysShip. This event is queued on every physics tick, hence its name.

Note: This is an opt-in feature of CC: VS 0.1.0 via the new config option and only for computers using ExtendedShipAPI (by default, Command Computers)! Also, any computers placed before the opt-in will NOT receive the event. They will have to be replaced to start receiving the event!

LuaPhysShip

getBuoyantFactor

getBuoyantFactor() -> number

This method grabs the current buoyant factor of the Ship! Useful for those designing Ships out of heavier materials!

while true do
    local event, phys = os.pullEvent("physics_tick")
    print("Buoyant Factor: " + phys.getBuoyantFactor())
end

isStatic

isStatic() -> boolean

This method indicates whether the Ship is static aka affected by physics!

while true do
    local event, phys = os.pullEvent("physics_tick")
    print("Has Ship been frozen by the Physics Engine? " + phys.isStatic())
end

doFluidDrag

doFluidDrag() -> boolean

This method indicates whether the Ship is being affected by fluid drag!

while true do
    local event, phys = os.pullEvent("physics_tick")

    print("Is Ship Affected by Fluid Drag? " + phys.doFluidDrag())
end

getInertia

getInertia() -> table

This method grabs the inertia of a Ship, including the current mass and the Moment of Inertia Tensor!

while true do
    local event, phys = os.pullEvent("physics_tick")
    local inertia = phys.getInertia()

    print("Mass: " + inertia.mass)
    print("Moment of Inertia Tensor: " + textutils.serialize(inertia.momentOfInertiaTensor))
end

getPoseVel

getPoseVel() -> table

This method grabs the PoseVel of a Ship, including Velocity, Omega, Position, and Rotation!

while true do
    local event, phys = os.pullEvent("physics_tick")
    local poseVel = phys.getPoseVel()

    print("Velocity: " + textutils.serialize(poseVel.vel))
    print("Omega: " + textutils.serialize(poseVel.omega))
    print("Position: " + textutils.serialize(poseVel.pos))
    print("Rotation: " + textutils.serialize(poseVel.rot))
end

getForcesInducers

getForcesInducers() -> table

This method grabs the class names of all ForcesInducer instances attached to a Ship!

local event, phys = os.pullEvent("physics_tick")

print("List of ForcesInducers:")
for _, inducer in pairs(phys.getForcesInducers()) do
    print("&nbsp" + inducer)
end