-
Notifications
You must be signed in to change notification settings - Fork 6
ShipAPI
I added a new API to computers placed on Ships to allow for greater access to Ship information! It will appear listed as both "ship" and as the Ship's name at the time of startup!
getWorldspacePosition() -> table
This method grabs the central position of a Ship in worldspace!
local pos = ship.getWorldspacePosition()
print("X: " .. pos.x)
print("Y: " .. pos.y)
print("Z: " .. pos.z)getShipyardPosition() -> table
This method grabs the central position of a Ship in the Shipyard!
local pos = ship.getShipyardPosition()
print("X: " .. pos.x)
print("Y: " .. pos.y)
print("Z: " .. pos.z)getScale() -> table
This method grabs the scale of a Ship!
local scale = ship.getScale()
print("X Scale: " .. scale.x)
print("Y Scale: " .. scale.y)
print("Z Scale: " .. scale.z)getQuaternion() -> table
This method grabs the rotation of a Ship as a Quaternion! Note: This is meant to be used in conjuction with the Quaternion API!
local rot = ship.getQuaternion()
print(quaternion.new(vector.new(rot.x, rot.y, rot.z), rot.w)getVelocity() -> table
This method grabs the linear velocity of a Ship!
local vel = ship.getVelocity()
print("X Velocity: " .. vel.x)
print("Y Velcoity: " .. vel.y)
print("Z Velocity: " .. vel.z)geMass() -> number
This method grabs the mass of a Ship!
local mass = ship.getMass()
print("Mass: " .. mass)getId() -> number
This method grabs the ID of a Ship!
local id = ship.getId()
print("Ship ID: " .. id)getOmega() -> table
This method grabs the rotational velocity of a Ship!
local omega = ship.getOmega()
print("X: " .. omega.x)
print("Y: " .. omega.y)
print("Z: " .. omega.z)isStatic() -> boolean
This method tells whether a Ship is static!
local response = "No"
if ship.isStatic() then
response = "Yes"
end
print("Is This Ship Static? " .. response)getMomentOfInertiaTensor() -> table
This method grabs the moment of inertia tensor of a Ship as a 3x3 table!
local tensor = ship.getMomentOfInertiaTensor()
print("Moment of Inertia Tensor")
for i=1,3,1 do
print(textutils.serialize(tensor[i]))
endgetTransformationMatrix() -> table
This method grabs the Ship to World Transformation Matrix as a 4x4 table!
local matrix = ship.getTransformationMatrix()
print("Transform Matrix")
for i=1,4,1 do
print(textutils.serialize(matrix[i]))
endgetSize() -> table
This method grabs the size of a Ship!
local size = ship.getSize()
print("X: " .. size.x)
print("Y: " .. size.y)
print("Z: " .. size.z)getSlug() -> string
This method grabs the slug of a Ship!
local slug = ship.getSlug()
print("Ship Name: " .. slug)setSlug( string )
This method sets the slug of a Ship!
local name = ...
ship.setSlug(name)transformPositionToWorld( vector ) -> table
transformPositionToWorld( number, number, number ) -> table
This method transforms the given position (vector or x, y, z) to the Worldspace position using the given Ship!
local pos = vector.new(...)
local worldPos = ship.transformPositionToWorld(pos)
print("X: " .. worldPos.x)
print("Y: " .. worldPos.y)
print("Z: " .. worldPos.z)getConstraints() -> table
This method gets all current contraints for the given Ship as a list!
local constraints = ship.getConstraints()
for id,con in pairs(constraints) do
print("Constraint ID: " .. id)
print("First Ship ID: " .. con.shipId0)
print("Second Ship ID: " .. con.shipId1)
print("Constraint Type: " .. con.type)
end