on_add_node
This commit is contained in:
parent
ce0ab6cc16
commit
3d64507ac3
@ -71,3 +71,5 @@ core.registered_on_dignode, core.register_on_dignode = make_registration()
|
||||
core.registered_on_punchnode, core.register_on_punchnode = make_registration()
|
||||
core.registered_on_placenode, core.register_on_placenode = make_registration()
|
||||
core.registered_on_item_use, core.register_on_item_use = make_registration()
|
||||
|
||||
core.registered_on_add_node, core.register_on_add_node = make_registration()
|
||||
|
@ -639,6 +639,7 @@ Minetest namespace reference
|
||||
### Global callback registration functions
|
||||
Call these functions only at load time!
|
||||
|
||||
* `minetest.register_on_add_node(func(pos, node))`
|
||||
* `minetest.register_globalstep(func(dtime))`
|
||||
* Called every client environment step, usually interval of 0.1s
|
||||
* `minetest.register_on_shutdown(func())`
|
||||
|
@ -1404,6 +1404,8 @@ MapNode Client::getNode(v3s16 p, bool *is_valid_position)
|
||||
|
||||
void Client::addNode(v3s16 p, MapNode n, bool remove_metadata)
|
||||
{
|
||||
if(moddingEnabled()) getScript()->on_add_node(p, n);
|
||||
|
||||
//TimeTaker timer1("Client::addNode()");
|
||||
|
||||
std::map<v3s16, MapBlock*> modified_blocks;
|
||||
|
@ -170,6 +170,21 @@ bool ScriptApiClient::on_dignode(v3s16 p, MapNode node)
|
||||
return lua_toboolean(L, -1);
|
||||
}
|
||||
|
||||
void ScriptApiClient::on_add_node(v3s16 p, MapNode node)
|
||||
{
|
||||
SCRIPTAPI_PRECHECKHEADER
|
||||
|
||||
INodeDefManager *ndef = getClient()->ndef();
|
||||
|
||||
lua_getglobal(L, "core");
|
||||
lua_getfield(L, -1, "registered_on_add_node");
|
||||
|
||||
push_v3s16(L, p);
|
||||
pushnode(L, node, ndef);
|
||||
|
||||
runCallbacks(2, RUN_CALLBACKS_MODE_OR);
|
||||
}
|
||||
|
||||
bool ScriptApiClient::on_punchnode(v3s16 p, MapNode node)
|
||||
{
|
||||
SCRIPTAPI_PRECHECKHEADER
|
||||
|
@ -58,6 +58,8 @@ public:
|
||||
bool on_placenode(const PointedThing &pointed, const ItemDefinition &item);
|
||||
bool on_item_use(const ItemStack &item, const PointedThing &pointed);
|
||||
|
||||
void on_add_node(v3s16 p, MapNode node);
|
||||
|
||||
void setEnv(ClientEnvironment *env);
|
||||
};
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user