lua: on_block_interact prevent default feature
This commit is contained in:
@@ -286,8 +286,8 @@ void PlayerController::updateInteraction(){
|
|||||||
}
|
}
|
||||||
if (def && rclick){
|
if (def && rclick){
|
||||||
if (!input.shift && target->rt.funcsset.oninteract) {
|
if (!input.shift && target->rt.funcsset.oninteract) {
|
||||||
scripting::on_block_interact(player, target, x, y, z);
|
if (!scripting::on_block_interact(player, target, x, y, z))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!target->replaceable){
|
if (!target->replaceable){
|
||||||
x = (iend.x)+(norm.x);
|
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);
|
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";
|
std::string name = block->name+".oninteract";
|
||||||
lua_getglobal(L, name.c_str());
|
lua_getglobal(L, name.c_str());
|
||||||
lua_pushivec3(L, x, y, z);
|
lua_pushivec3(L, x, y, z);
|
||||||
lua_pushinteger(L, 1);
|
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) {
|
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 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_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_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_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);
|
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);
|
void load_block_script(std::string prefix, fs::path file, block_funcs_set* funcsset);
|
||||||
|
|||||||
Reference in New Issue
Block a user