mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
feat: throw exception in headless mode if player id is not passed to player.* functions
This commit is contained in:
parent
3acb9f7409
commit
f1cf5c43e6
1 changed files with 8 additions and 0 deletions
|
|
@ -10,10 +10,18 @@
|
|||
#include "physics/Hitbox.hpp"
|
||||
#include "window/Camera.hpp"
|
||||
#include "world/Level.hpp"
|
||||
#include "engine/Engine.hpp"
|
||||
|
||||
using namespace scripting;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue