refactor: PlayerController
This commit is contained in:
@@ -134,10 +134,10 @@ static int l_player_set_noclip(lua_State* L) {
|
||||
|
||||
static int l_player_get_selected_block(lua_State* L) {
|
||||
if (auto player = get_player(L, 1)) {
|
||||
if (player->selectedVoxel.id == BLOCK_VOID) {
|
||||
if (player->selection.vox.id == BLOCK_VOID) {
|
||||
return 0;
|
||||
}
|
||||
const glm::ivec3 pos = player->selectedBlockPosition;
|
||||
const glm::ivec3 pos = player->selection.position;
|
||||
lua_pushinteger(L, pos.x);
|
||||
lua_pushinteger(L, pos.y);
|
||||
lua_pushinteger(L, pos.z);
|
||||
|
||||
@@ -192,10 +192,10 @@ void scripting::on_block_broken(Player* player, const Block* block, int x, int y
|
||||
});
|
||||
}
|
||||
|
||||
bool scripting::on_block_interact(Player* player, const Block* block, int x, int y, int z) {
|
||||
bool scripting::on_block_interact(Player* player, const Block* block, glm::ivec3 pos) {
|
||||
std::string name = block->name + ".interact";
|
||||
return state->emit_event(name, [x, y, z, player] (lua::LuaState* state) {
|
||||
state->pushivec3(x, y, z);
|
||||
return state->emit_event(name, [pos, player] (lua::LuaState* state) {
|
||||
state->pushivec3(pos.x, pos.y, pos.z);
|
||||
state->pushinteger(player->getId());
|
||||
return 4;
|
||||
});
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace scripting {
|
||||
void random_update_block(const Block* block, int x, int y, int z);
|
||||
void on_block_placed(Player* player, const Block* block, int x, int y, int z);
|
||||
void on_block_broken(Player* player, const Block* block, int x, int y, int z);
|
||||
bool on_block_interact(Player* player, const Block* block, int x, int y, int z);
|
||||
bool on_block_interact(Player* player, const Block* block, glm::ivec3 pos);
|
||||
|
||||
/// @brief Called on RMB click with the item selected
|
||||
/// @return true if prevents default action
|
||||
|
||||
Reference in New Issue
Block a user