From 3bfc37172a2939ee7aab16dbaa9e3d8bd6deed51 Mon Sep 17 00:00:00 2001 From: mjn-mixael Date: Sun, 14 Jan 2024 22:21:52 -0600 Subject: [PATCH] Expose unloading a player and campaign file --- code/scripting/api/libs/ui.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/code/scripting/api/libs/ui.cpp b/code/scripting/api/libs/ui.cpp index 6a90eda85f0..11d7e4e1ec0 100644 --- a/code/scripting/api/libs/ui.cpp +++ b/code/scripting/api/libs/ui.cpp @@ -393,6 +393,23 @@ ADE_FUNC( return ade_set_args(L, "b", player_create_new_pilot(callsign, is_multi, copy_from)); } +ADE_FUNC(unloadPilot, + l_UserInterface_PilotSelect, + nullptr, + "Unloads a player file & associated campaign file. Can not be used outside of pilot select!", + "boolean", + "Returns true if successful, false otherwise") +{ + if (gameseq_get_state() == GS_STATE_INITIAL_PLAYER_SELECT) { + Player = nullptr; + Campaign.filename[0] = '\0'; + + return ADE_RETURN_TRUE; + } + + return ADE_RETURN_FALSE; +} + ADE_FUNC(isAutoselect, l_UserInterface_PilotSelect, nullptr, "Determines if the pilot selection screen should automatically select the default user.", "boolean", "true if autoselect is enabled, false otherwise")