Skip to content

Commit

Permalink
Merge pull request #6348 from Goober5000/hud_gauge_bugfix
Browse files Browse the repository at this point in the history
two HUD fixes
  • Loading branch information
Goober5000 committed Sep 11, 2024
2 parents b6879da + dfe34ec commit f08d82b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion code/hud/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3908,7 +3908,9 @@ void hud_page_in()

HudGauge* hud_get_custom_gauge(const char* name, bool check_all_gauges)
{
auto player_sip = Player_ship->ship_info_index < 0 ? nullptr : &Ship_info[Player_ship->ship_info_index];
ship_info *player_sip = nullptr;
if (Player_ship && Player_ship->ship_info_index >= 0)
player_sip = &Ship_info[Player_ship->ship_info_index];

// go through all gauges for all ships and defaults
if (check_all_gauges) {
Expand Down
2 changes: 1 addition & 1 deletion code/parse/sexp/LuaSEXP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ luacpp::LuaValue LuaSEXP::sexpToLua(int node, int argnum, int parent_node) const
}
case OPF_ANY_HUD_GAUGE: {
auto name = CTEXT(node);
return LuaValue::createValue(_action.getLuaState(), l_HudGauge.Set(hud_get_gauge(name)));
return LuaValue::createValue(_action.getLuaState(), l_HudGauge.Set(hud_get_gauge(name, true)));
}
case OPF_EVENT_NAME: {
auto name = CTEXT(node);
Expand Down
4 changes: 2 additions & 2 deletions code/scripting/api/objs/hudgauge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ADE_FUNC(isCustom, l_HudGauge, nullptr, "Custom HUD Gauge status", "boolean", "R
return ade_set_args(L, "b", gauge->isCustom());
}

ADE_VIRTVAR(Name, l_HudGauge, "string", "Custom HUD Gauge name", "string", "Custom HUD Gauge name, or blank if this is a default gauge, or nil if handle is invalid")
ADE_VIRTVAR(Name, l_HudGauge, "string", "Custom HUD Gauge name", "string", "Custom HUD Gauge name, or nil if this is a default gauge or the handle is invalid")
{
HudGauge* gauge;

Expand All @@ -37,7 +37,7 @@ ADE_VIRTVAR(Name, l_HudGauge, "string", "Custom HUD Gauge name", "string", "Cust
return ade_set_args(L, "s", gauge->getCustomGaugeName());
}

ADE_VIRTVAR(Text, l_HudGauge, "string", "Custom HUD Gauge text", "string", "Custom HUD Gauge text, or blank if this is a default gauge, or nil if handle is invalid")
ADE_VIRTVAR(Text, l_HudGauge, "string", "Custom HUD Gauge text", "string", "Custom HUD Gauge text, or nil if this is a default gauge or the handle is invalid")
{
HudGauge* gauge;
const char* text = nullptr;
Expand Down

0 comments on commit f08d82b

Please sign in to comment.