feat: throw exception in headless mode if player id is not passed to player.* functions
This commit is contained in:
parent
3acb9f7409
commit
f1cf5c43e6
@ -10,10 +10,18 @@
|
|||||||
#include "physics/Hitbox.hpp"
|
#include "physics/Hitbox.hpp"
|
||||||
#include "window/Camera.hpp"
|
#include "window/Camera.hpp"
|
||||||
#include "world/Level.hpp"
|
#include "world/Level.hpp"
|
||||||
|
#include "engine/Engine.hpp"
|
||||||
|
|
||||||
using namespace scripting;
|
using namespace scripting;
|
||||||
|
|
||||||
inline Player* get_player(lua::State* L, int idx) {
|
inline Player* get_player(lua::State* L, int idx) {
|
||||||
|
if (!lua::isnumber(L, idx)) {
|
||||||
|
if (engine->isHeadless()) {
|
||||||
|
throw std::runtime_error(
|
||||||
|
"player id required as argument #" + std::to_string(idx)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
return level->players->get(lua::tointeger(L, idx));
|
return level->players->get(lua::tointeger(L, idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user