mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
[CSM] Add event on_place_node API lua (#5548)
* [CSM] Add event on_place_node API lua
This commit is contained in:
parent
ecf08255b0
commit
dc5bc6cac7
12 changed files with 88 additions and 37 deletions
|
@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "client.h"
|
||||
#include "common/c_converter.h"
|
||||
#include "common/c_content.h"
|
||||
#include "s_item.h"
|
||||
|
||||
void ScriptApiClient::on_shutdown()
|
||||
{
|
||||
|
@ -189,6 +190,23 @@ bool ScriptApiClient::on_punchnode(v3s16 p, MapNode node)
|
|||
return blocked;
|
||||
}
|
||||
|
||||
bool ScriptApiClient::on_placenode(const PointedThing &pointed, const ItemDefinition &item)
|
||||
{
|
||||
SCRIPTAPI_PRECHECKHEADER
|
||||
|
||||
// Get core.registered_on_placenode
|
||||
lua_getglobal(L, "core");
|
||||
lua_getfield(L, -1, "registered_on_placenode");
|
||||
|
||||
// Push data
|
||||
push_pointed_thing(L, pointed);
|
||||
push_item_definition(L, item);
|
||||
|
||||
// Call functions
|
||||
runCallbacks(2, RUN_CALLBACKS_MODE_OR);
|
||||
return lua_toboolean(L, -1);
|
||||
}
|
||||
|
||||
void ScriptApiClient::setEnv(ClientEnvironment *env)
|
||||
{
|
||||
ScriptApiBase::setEnv(env);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue