Files
fs2open.github.com/code/scripting/api/objs/hudgauge.cpp
T
2018-09-26 19:15:42 +02:00

46 lines
992 B
C++

//
//
#include "hudgauge.h"
namespace scripting {
namespace api {
ADE_OBJ(l_HudGauge, HudGauge*, "HudGauge", "HUD Gauge handle");
ADE_VIRTVAR(Name, l_HudGauge, "string", "Custom HUD Gauge name", "string", "Custom HUD Gauge name, or nil if handle is invalid")
{
HudGauge* gauge;
if (!ade_get_args(L, "o", l_HudGauge.Get(&gauge)))
return ADE_RETURN_NIL;
if (gauge->getObjectType() != HUD_OBJECT_CUSTOM)
return ADE_RETURN_NIL;
return ade_set_args(L, "s", gauge->getCustomGaugeName());
}
ADE_VIRTVAR(Text, l_HudGauge, "string", "Custom HUD Gauge text", "string", "Custom HUD Gauge text, or nil if handle is invalid")
{
HudGauge* gauge;
const char* text = nullptr;
if (!ade_get_args(L, "o|s", l_HudGauge.Get(&gauge), &text))
return ADE_RETURN_NIL;
if (gauge->getObjectType() != HUD_OBJECT_CUSTOM)
return ADE_RETURN_NIL;
if (ADE_SETTING_VAR && text != NULL)
{
gauge->updateCustomGaugeText(text);
}
return ade_set_args(L, "s", gauge->getCustomGaugeText());
}
}
}