Skip to content

Commit ca1634b

Browse files
authored
Lua isDockLeader function (#7286)
* lua isDockLeader function * address nitpicks
1 parent 7b4b544 commit ca1634b

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

code/scripting/api/objs/ship.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2884,6 +2884,23 @@ ADE_FUNC(jettison, l_Ship, "number jettison_speed, [ship... dockee_ships /* All
28842884
return jettison_helper(L, docker_objh, jettison_speed, 2);
28852885
}
28862886

2887+
ADE_FUNC(isDockLeader, l_Ship, nullptr, "Returns whether this ship is currently docked and is the dock leader for its docked group", "boolean", "True if this ship is docked and is the dock leader, false otherwise, nil if ship handle is invalid")
2888+
{
2889+
object_h* objh = nullptr;
2890+
2891+
if (!ade_get_args(L, "o", l_Ship.GetPtr(&objh)))
2892+
return ADE_RETURN_NIL;
2893+
2894+
if (objh == nullptr || !objh->isValid())
2895+
return ADE_RETURN_NIL;
2896+
2897+
if (!object_is_docked(objh->objp()))
2898+
return ADE_RETURN_FALSE;
2899+
2900+
auto shipp = &Ships[objh->objp()->instance];
2901+
return shipp->flags[Ship::Ship_Flags::Dock_leader] ? ADE_RETURN_TRUE : ADE_RETURN_FALSE;
2902+
}
2903+
28872904
ADE_FUNC(AddElectricArc, l_Ship, "vector firstPoint, vector secondPoint, number duration, number width, [number segment_depth, boolean persistent_points]",
28882905
"Creates an electric arc on the ship between two points in the ship's reference frame, for the specified duration in seconds, and the specified width in meters. Optionally, "
28892906
"specify the segment depth (the number of times the spark is divided) and whether to generate a set of arc points that will persist from frame to frame.",

0 commit comments

Comments
 (0)