From 1ca2e852f9c39d860da96a3a704de1d125fb3882 Mon Sep 17 00:00:00 2001 From: Mike Nelson Date: Sat, 14 Mar 2026 12:43:06 -0500 Subject: [PATCH 1/2] lua isDockLeader function --- code/scripting/api/objs/ship.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/code/scripting/api/objs/ship.cpp b/code/scripting/api/objs/ship.cpp index 6611f534963..c34161cc4cf 100644 --- a/code/scripting/api/objs/ship.cpp +++ b/code/scripting/api/objs/ship.cpp @@ -2884,6 +2884,23 @@ ADE_FUNC(jettison, l_Ship, "number jettison_speed, [ship... dockee_ships /* All return jettison_helper(L, docker_objh, jettison_speed, 2); } +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") +{ + object_h* objh = nullptr; + + if (!ade_get_args(L, "o", l_Ship.GetPtr(&objh))) + return ADE_RETURN_NIL; + + if (objh == nullptr || !objh->isValid()) + return ADE_RETURN_NIL; + + if (!object_is_docked(objh->objp())) + return ADE_RETURN_FALSE; + + auto shipp = &Ships[objh->objp()->instance]; + return shipp->flags[Ship::Ship_Flags::Dock_leader] ? ADE_RETURN_TRUE : ADE_RETURN_FALSE; +} + ADE_FUNC(AddElectricArc, l_Ship, "vector firstPoint, vector secondPoint, number duration, number width, [number segment_depth, boolean persistent_points]", "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, " "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.", From 421edb98c537f51979cf6d3d5b50dcc2db69edd1 Mon Sep 17 00:00:00 2001 From: Mike Nelson Date: Mon, 16 Mar 2026 13:52:13 -0500 Subject: [PATCH 2/2] address nitpicks --- code/scripting/api/objs/ship.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/scripting/api/objs/ship.cpp b/code/scripting/api/objs/ship.cpp index c34161cc4cf..37e97d6fcc3 100644 --- a/code/scripting/api/objs/ship.cpp +++ b/code/scripting/api/objs/ship.cpp @@ -2884,7 +2884,7 @@ ADE_FUNC(jettison, l_Ship, "number jettison_speed, [ship... dockee_ships /* All return jettison_helper(L, docker_objh, jettison_speed, 2); } -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") +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") { object_h* objh = nullptr;