Files
fs2open.github.com/code/scripting/api/objs/background_element.cpp
T
asarium f63e18957b Add scripting API for manipulating mission background
This adds a scripting API which can be used for adding and removing
background from a mission similarly to the existing SEXPs but with full
support for floating point numbers.

This was requested by Axem on Discord.
2018-06-30 23:22:07 +02:00

27 lines
728 B
C++

//
//
#include "background_element.h"
namespace scripting {
namespace api {
ADE_OBJ(l_BackgroundElement, background_el_h, "background_element", "Background element handle");
background_el_h::background_el_h(BackgroundType in_type, int in_id) : type(in_type), id(in_id) {}
bool background_el_h::isValid() const { return id >= 0 && type != BackgroundType::Invalid; }
ADE_FUNC(isValid, l_BackgroundElement, nullptr, "Determines if this handle is valid", "boolean",
"true if valid, false if not.")
{
background_el_h* el = nullptr;
if (!ade_get_args(L, "o", l_BackgroundElement.GetPtr(&el))) {
return ADE_RETURN_FALSE;
}
return ade_set_args(L, "b", el->isValid());
}
} // namespace api
} // namespace scripting