Class Ship
The main ship meta class.
Initialisation
For creating and Initialising ShipCompass object.
-
Ship:new (_instanceName)
line 20
-
Creates a new intance of the Ship class.
Parameters:
- _instanceName
string
, should be identical to variable instance is assigned to.
Returns:
table
A new instance of the Ship class.
Usage:
thisShip = Ship:new()
Repair methods
Methods to handle repairing.
-
Ship:runAutorepair ()
line 75
-
Runs autorepair routine, and issues repair orders if necessary.
Immediately returns if already repairing, so can be called on every prompt.
Check functionality on this. Ugly, but it should work.
Usage:
thisShip:runAutorepair()
-
Ship:getAutorepairType ()
line 113
-
Gets the current autorepair type for the ship.
Returns:
int
0 = no repair, 1 = hull repair, 2 = all repair
Usage:
local autorepairType = Ship:getAutorepairType()
-
Ship:getRepairCooldown ()
line 120
-
True if on cooldown between repair attempts.
Returns:
bool
True, if on cooldown.
Usage:
local repairCooldown = Ship:getRepairCooldown()
-
Ship:isRepairingHull ()
line 127
-
True if crew is repairing hull.
Returns:
bool
True, if repairing hull.
Usage:
local repairingHull = Ship:isRepairingHull()
-
Ship:isRepairingSails ()
line 134
-
True if crew is repairing sails.
Returns:
bool
True, if repairing sails.
Usage:
local repairingSails = Ship:isRepairingSails()
-
Ship:setAutorepairType (autorepairType)
line 141
-
Sets the autorepair type for the ship.
Parameters:
- autorepairType
int
0 = repair none, 1 = repair hull, 2 = repair both
Usage:
outShip:setAutorepairType(1)
-
Ship:setRepairCooldown (_cooldown)
line 149
-
Enable or disable autorepair cooldown.
Will automatically disable itself after three seconds enabled.
Parameters:
- _cooldown
bool
true to enable crew cooldown timer, false to disable it early.
-
Ship:repairHull (_keepRepairing)
line 156
-
Set if crew is repairing hull.
Parameters:
- _keepRepairing
bool
True, if repairing hull.
-
Ship:repairSails (_keepRepairing)
line 162
-
Set if crew is repairing sails.
Parameters:
- _keepRepairing
bool
True, if repairing sails.
Prompt methods
Methods to handle the various ship prompts.
-
Ship:processPrompt (_promptString)
line 181
-
Processes a ship prompt line in-object, instead of using complex triggers.
Reads both Battle and Cryptic prompts, and populates the instance's attributes accordingly.
To enable, simply use a trigger to pass the prompt
Parameters:
- _promptString
string
The full ship prompt line from the game.
Returns:
event,table
Raises ship prompt processed
event. Prompt data passed along as a table.
Queries
Methods to query about various states within the ship.
-
Ship:isAnchorRaised ()
line 253
-
Retrieves anchor state.
Returns:
bool
True if anchor raised, false if anchor lowered.
Usage:
if not thisShip:isAnchorRaised() then send("ship raise anchor") end
-
Ship:isDocked ()
line 259
-
Returns if ship is docked.
Returns:
bool
True, if ship is docked.
-
Ship:isGangplankRaised ()
line 280
-
Retrieves gangplank state.
Returns:
bool
True if gangplank raised, false if gangplank lowered.
Usage:
if not thisShip:isGangplankRaised() then send("ship raise gangplank") end
-
Ship:isGrappled ()
line 288
-
Returns if ship is grappled.
Returns:
-
bool
True, if ship is grappled.
-
table
Key/value table containing grapplers and hooks per.
-
Ship:isLeaking ()
line 295
-
Returns if ship is leaking.
Returns:
bool
True, if ship is leaking.
-
Ship:isOnFire ()
line 301
-
Returns if ship is on fire.
Returns:
int or bool
false = no fire, 1 = deck fire, 2 = sails fire, 3 = deck and sails on fire.
-
Ship:isRowing ()
line 310
-
True if ship is rowing.
Returns:
bool
-
Ship:isSailing ()
line 317
-
True if ship is sailing.
"Sailing" is defined as any sail setter beyond furled.
Returns:
bool
-
Ship:isSinking ()
line 324
-
Returns if ship is sinking.
Returns:
bool
True, if ship is sinking.
-
Ship:isTurning ()
line 330
-
Returns if ship is turning.
Returns:
bool or string
False, if not turning. Ordered course as string, otherwise.
Get methods
Methods to retrieve various points of information about the ship.
-
Ship:getCourse ()
line 346
-
Gets the current course of the ship.
Returns:
string
Course as compass direction
-
Ship:getCrewBalance ()
line 352
-
Gets the crew balance for the ship.
Returns:
bool
True, if have crew balance.
-
Ship:getHullHealth ()
line 358
-
Gets the current hull health for the ship.
Returns:
int
Hull health, 1-100.
-
Ship:getSailHealth ()
line 364
-
Gets the current sail health for the ship.
Returns:
int
Sail health, 1-100.
-
Ship:getSailSetting ()
line 370
-
Gets the current sail setting for the ship.
Returns:
int
Sail setting, 0-100.
-
Ship:getSeaState ()
line 376
-
Gets the current sea state around the ship.
Returns:
int
Sea state, 1-9.
-
Ship:getSpeed ()
line 382
-
Gets the current speed of the ship.
Returns:
int
Ship's current speed, in knots.
-
Ship:getWindSpeed ()
line 388
-
Gets the current sea state around the ship.
Returns:
int
Sea state, 1-9.
-
Ship:getWindDirection ()
line 394
-
Gets the current speed of the ship.
Returns:
int
Ship's current speed, in knots.
Set methods
Methods to retrieve various points of information about the ship.
-
Ship:setAnchorRaised (_isRaised)
line 412
-
Sets whether the anchor is currently raised.
Parameters:
- _isRaised
bool
True if anchor raised, false if anchor lowered.
Usage:
thisShip:setAnchorRaised(true)
-
Ship:setCrewBalance (_onBalance)
line 419
-
Sets whether the crew is on balance.
Parameters:
- _onBalance
bool
True, if crew on balance.
Usage:
thisShip:setCrewBalance(false)
-
Ship:setCourse (_captureGroup)
line 427
-
Sets the current course of the Ship object.
Intended to simply document, after the prompt is processed.
Parameters:
- _captureGroup
string
Direction as short compass heading.
Returns:
bool
True if successful.
-
Ship:setGangplankRaised (_isRaised)
line 461
-
Sets whether the gangplank is currently raised.
Parameters:
- _isRaised
bool
True if gangplank raised, false if gangplank lowered.
Usage:
thisShip:setGangplankRaised(false)
Internal functions
Internal stuff. Not for external stuff.
-
Ship:setHullHealth (_captureGroup)
line 480
-
Sets the current hull health of the Ship object.
Can accept prompt symbols, integer percenage strings, and raw numbers.
Parameters:
- _captureGroup
string or int
The argument to pass into the function. Strings such as ++ okay.
Returns:
-
bool
True, if successful
-
string
The capture group passed into the function.
-
Ship:setRequestedCourse (_captureGroup)
line 508
-
Sets the current rowing state of the Ship object.
Parameters:
- _captureGroup
string
Capture Either full ship prompt line, or substring that would contain rowing flag.
-
Ship:setRowing (_captureGroup)
line 519
-
Sets the current rowing state of the Ship object.
Parameters:
- _captureGroup
string
Capture Either full ship prompt line, or substring that would contain rowing flag.
-
Ship:setSailHealth (_captureGroup)
line 535
-
Sets the current sail health of the Ship object.
Can accept prompt symbols, integer percenage strings, and raw numbers.
Possible input examples:
++
, --
, or
int`.
Parameters:
- _captureGroup
string or int
The argument to pass into the function. Strings such as ++ okay.
Returns:
-
bool
True, if successful
-
string
The capture group passed into the function.
-
Ship:setSailSetting (_captureGroup)
line 567
-
Sets the current sail setting of the Ship object.
Can accept prompt symbols, integer percenage strings, and raw numbers.
Possible input examples:
++
, --
, or
int`.
Parameters:
- _captureGroup
string or int
The argument to pass into the function. Strings such as ++ okay.
Returns:
-
bool
True, if successful
-
string
The capture group passed into the function.
-
Ship:setSeaState (_captureGroup)
line 598
-
Sets the current sea state of the Ship object.
Parameters:
- _captureGroup
string or int
Sea state as either descriptor or Roman numerals as string, or raw number input.
Returns:
-
bool
True, if successful
-
string
The capture group passed into the function.
-
Ship:setSpeed (_captureGroup)
line 631
-
Sets the current speed of the Ship object.
Parameters:
-
Ship:setWindDirection (_captureGroup)
line 640
-
Sets the current wind direction of the Ship object.
Parameters:
- _captureGroup
string
String direction to pass to the Navigator.
Returns:
bool True if successful.
-
Ship:setWindSpeed (_captureGroup)
line 674
-
Sets the current wind speed of the Ship object.
Parameters: