lua: on_block_interact prevent default feature
This commit is contained in:
parent
f49aa9eab0
commit
7df98f7b35
@ -286,8 +286,8 @@ void PlayerController::updateInteraction(){
|
||||
}
|
||||
if (def && rclick){
|
||||
if (!input.shift && target->rt.funcsset.oninteract) {
|
||||
scripting::on_block_interact(player, target, x, y, z);
|
||||
return;
|
||||
if (!scripting::on_block_interact(player, target, x, y, z))
|
||||
return;
|
||||
}
|
||||
if (!target->replaceable){
|
||||
x = (iend.x)+(norm.x);
|
||||
|
||||
@ -181,12 +181,15 @@ void scripting::on_block_broken(Player* player, const Block* block, int x, int y
|
||||
call_func(L, 4, name);
|
||||
}
|
||||
|
||||
void 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, int x, int y, int z) {
|
||||
std::string name = block->name+".oninteract";
|
||||
lua_getglobal(L, name.c_str());
|
||||
lua_pushivec3(L, x, y, z);
|
||||
lua_pushinteger(L, 1);
|
||||
call_func(L, 4, name);
|
||||
if (call_func(L, 4, name)) {
|
||||
return lua_toboolean(L, -1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool scripting::on_item_use_on_block(Player* player, const ItemDef* item, int x, int y, int z) {
|
||||
|
||||
@ -28,7 +28,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);
|
||||
void on_block_interact(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_item_use_on_block(Player* player, const ItemDef* item, int x, int y, int z);
|
||||
bool on_item_break_block(Player* player, const ItemDef* item, int x, int y, int z);
|
||||
void load_block_script(std::string prefix, fs::path file, block_funcs_set* funcsset);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user