Events and Exports
Server events
Other resources can listen to the end of every delivery. Both events are triggered on the server with TriggerEvent.
luxu_porters:delivered
A delivery was completed and counted.
AddEventHandler('luxu_porters:delivered', function(source, missionId, result)
print(('%s delivered %s in condition %d, paid %d'):format(source, missionId, result.condition, result.pay))
end)luxu_porters:failed
A delivery failed: it was cancelled, ran out of time, was destroyed or the porter was killed.
AddEventHandler('luxu_porters:failed', function(source, missionId, result)
print(('%s failed %s: %s'):format(source, missionId, result.failure))
end)The result
Both events pass the same result table.
| Field | What it is |
|---|---|
cargo |
The title of the mission. |
size |
The size of the load. |
traits |
The traits of the cargo. |
destination |
The label of the destination. |
distance |
The distance of the mission. |
condition |
The condition of the cargo, 0 to 100. Always 0 on a failed delivery. |
time |
Seconds the delivery took. |
limit |
The time limit, if the mission has one. |
pay |
What was paid. Always 0 on a failed delivery. |
failure |
nil on a delivery that counted. 'cancelled', 'out of time', 'destroyed' or 'killed' on a failed one. |
urgent |
true if the mission was urgent. |
repeatShare |
The share of the pay a repeat delivery earned, 1.0 when there was no cut. |
best |
Only on luxu_porters:delivered. The porter's best time for this mission before this delivery, in seconds, or nil if it is their first. |
Server exports
getStack
local stack = exports.luxu_porters:getStack(source)Returns what a porter carries and the condition of each item, bottom first, or nil if they carry nothing. It is meant for tests and for reading the state of a porter, and it does not change anything.