mirror of
https://github.com/diasurgical/DevilutionX.git
synced 2026-06-20 05:44:36 +00:00
8bffbedcb4
Introduces a new `devilutionx.dev` Lua module, automatically loaded in the console prelude. Arguments and basic help are shown in autocompletion.
32 lines
761 B
C++
32 lines
761 B
C++
#include "lua/modules/render.hpp"
|
|
|
|
#include <sol/sol.hpp>
|
|
|
|
#include "effects.h"
|
|
#include "lua/metadoc.hpp"
|
|
|
|
namespace devilution {
|
|
|
|
namespace {
|
|
|
|
bool IsValidSfx(int16_t psfx)
|
|
{
|
|
return psfx >= 0 && psfx <= static_cast<int16_t>(SfxID::LAST);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
sol::table LuaAudioModule(sol::state_view &lua)
|
|
{
|
|
sol::table table = lua.create_table();
|
|
SetWithSignature(table,
|
|
"playSfx", "(id: number)",
|
|
[](int16_t psfx) { if (IsValidSfx(psfx)) PlaySFX(static_cast<SfxID>(psfx)); });
|
|
SetWithSignature(table,
|
|
"playSfxLoc", "(id: number, x: number, y: number)",
|
|
[](int16_t psfx, int x, int y) { if (IsValidSfx(psfx)) PlaySfxLoc(static_cast<SfxID>(psfx), { x, y }); });
|
|
return table;
|
|
}
|
|
|
|
} // namespace devilution
|