ShipAPI - TechTastic/CC-VS GitHub Wiki
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!
Functions
getWorldspacePosition
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
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
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
getQuaternion() -> table
This method grabs the rotation of a Ship as a Quaternion!
local rot = ship.getQuaternion()
print("X: " .. rot.x)
print("Y: " .. rot.y)
print("Z: " .. rot.z)
print("W: " .. rot.w)
getRoll
getRoll() -> number
This method grabs the roll of a Ship!
local roll = ship.getRoll()
print("Roll: " .. roll)
getPitch
getPitch() -> number
This method grabs the pitch of a Ship!
local pitch = ship.getPitch()
print("Pitch: " .. pitch)
getYaw
getYaw() -> number
This method grabs the yaw of a Ship!
local yaw = ship.getYaw()
print("Yaw: " .. yaw)
getVelocity
getVelocity() -> table
This method grabs the velocity of a Ship!
local vel = ship.getVelocity()
print("X Velocity: " .. vel.x)
print("Y Velcoity: " .. vel.y)
print("Z Velocity: " .. vel.z)
getMass
geMass() -> number
This method grabs the mass of a Ship!
local mass = ship.getMass()
print("Mass: " .. mass)
getId
getId() -> number
This method grabs the ID of a Ship!
local id = ship.getId()
print("Ship ID: " .. id)
getOmega
getOmega() -> table
This method grabs the omega of a Ship!
local omega = ship.getOmega()
print("X: " .. omega.x)
print("Y: " .. omega.y)
print("Z: " .. omega.z)
isStatic
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
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]))
end
getRotationMatrix
getRotationMatrix() -> table
This method grabs the Ship to World Rotation Matrix as a 4x4 table!
local matrix = ship.getRotationMatrix()
print("Rotation Matrix")
for i=1,4,1 do
print(textutils.serialize(matrix[i]))
end
getSize
getSize() -> 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)
getName
getName() -> string
This method grabs the name of a Ship!
local name = ship.getName()
print("Ship Name: " .. name)
setName
setName(name)
This method sets the name of a Ship!
local name = ...
ship.setName(name)