mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
[CSM] add on_item_use
(#5544)
This commit is contained in:
parent
6658ad3d94
commit
5ebf8f9450
6 changed files with 34 additions and 1 deletions
|
@ -207,6 +207,23 @@ bool ScriptApiClient::on_placenode(const PointedThing &pointed, const ItemDefini
|
|||
return lua_toboolean(L, -1);
|
||||
}
|
||||
|
||||
bool ScriptApiClient::on_item_use(const ItemStack &item, const PointedThing &pointed)
|
||||
{
|
||||
SCRIPTAPI_PRECHECKHEADER
|
||||
|
||||
// Get core.registered_on_item_use
|
||||
lua_getglobal(L, "core");
|
||||
lua_getfield(L, -1, "registered_on_item_use");
|
||||
|
||||
// Push data
|
||||
LuaItemStack::create(L, item);
|
||||
push_pointed_thing(L, pointed);
|
||||
|
||||
// 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