aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_item.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/cpp_api/s_item.cpp')
-rw-r--r--src/script/cpp_api/s_item.cpp44
1 files changed, 21 insertions, 23 deletions
diff --git a/src/script/cpp_api/s_item.cpp b/src/script/cpp_api/s_item.cpp
index 24955cefc..4e77ad412 100644
--- a/src/script/cpp_api/s_item.cpp
+++ b/src/script/cpp_api/s_item.cpp
@@ -29,8 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "inventory.h"
#include "inventorymanager.h"
-bool ScriptApiItem::item_OnDrop(ItemStack &item,
- ServerActiveObject *dropper, v3f pos)
+bool ScriptApiItem::item_OnDrop(ItemStack &item, ServerActiveObject *dropper, v3f pos)
{
SCRIPTAPI_PRECHECKHEADER
@@ -52,12 +51,12 @@ bool ScriptApiItem::item_OnDrop(ItemStack &item,
throw LuaError(std::string(e.what()) + ". item=" + item.name);
}
}
- lua_pop(L, 2); // Pop item and error handler
+ lua_pop(L, 2); // Pop item and error handler
return true;
}
-bool ScriptApiItem::item_OnPlace(ItemStack &item,
- ServerActiveObject *placer, const PointedThing &pointed)
+bool ScriptApiItem::item_OnPlace(
+ ItemStack &item, ServerActiveObject *placer, const PointedThing &pointed)
{
SCRIPTAPI_PRECHECKHEADER
@@ -84,12 +83,12 @@ bool ScriptApiItem::item_OnPlace(ItemStack &item,
throw LuaError(std::string(e.what()) + ". item=" + item.name);
}
}
- lua_pop(L, 2); // Pop item and error handler
+ lua_pop(L, 2); // Pop item and error handler
return true;
}
-bool ScriptApiItem::item_OnUse(ItemStack &item,
- ServerActiveObject *user, const PointedThing &pointed)
+bool ScriptApiItem::item_OnUse(
+ ItemStack &item, ServerActiveObject *user, const PointedThing &pointed)
{
SCRIPTAPI_PRECHECKHEADER
@@ -104,19 +103,19 @@ bool ScriptApiItem::item_OnUse(ItemStack &item,
objectrefGetOrCreate(L, user);
pushPointedThing(pointed);
PCALL_RES(lua_pcall(L, 3, 1, error_handler));
- if(!lua_isnil(L, -1)) {
+ if (!lua_isnil(L, -1)) {
try {
item = read_item(L, -1, getServer()->idef());
} catch (LuaError &e) {
throw LuaError(std::string(e.what()) + ". item=" + item.name);
}
}
- lua_pop(L, 2); // Pop item and error handler
+ lua_pop(L, 2); // Pop item and error handler
return true;
}
-bool ScriptApiItem::item_OnSecondaryUse(ItemStack &item,
- ServerActiveObject *user, const PointedThing &pointed)
+bool ScriptApiItem::item_OnSecondaryUse(
+ ItemStack &item, ServerActiveObject *user, const PointedThing &pointed)
{
SCRIPTAPI_PRECHECKHEADER
@@ -136,7 +135,7 @@ bool ScriptApiItem::item_OnSecondaryUse(ItemStack &item,
throw LuaError(std::string(e.what()) + ". item=" + item.name);
}
}
- lua_pop(L, 2); // Pop item and error handler
+ lua_pop(L, 2); // Pop item and error handler
return true;
}
@@ -168,7 +167,7 @@ bool ScriptApiItem::item_OnCraft(ItemStack &item, ServerActiveObject *user,
throw LuaError(std::string(e.what()) + ". item=" + item.name);
}
}
- lua_pop(L, 2); // Pop item and error handler
+ lua_pop(L, 2); // Pop item and error handler
return true;
}
@@ -184,7 +183,7 @@ bool ScriptApiItem::item_CraftPredict(ItemStack &item, ServerActiveObject *user,
LuaItemStack::create(L, item);
objectrefGetOrCreate(L, user);
- //Push inventory list
+ // Push inventory list
std::vector<ItemStack> items;
for (u32 i = 0; i < old_craft_grid->getSize(); i++) {
items.push_back(old_craft_grid->getItem(i));
@@ -200,7 +199,7 @@ bool ScriptApiItem::item_CraftPredict(ItemStack &item, ServerActiveObject *user,
throw LuaError(std::string(e.what()) + ". item=" + item.name);
}
}
- lua_pop(L, 2); // Pop item and error handler
+ lua_pop(L, 2); // Pop item and error handler
return true;
}
@@ -210,10 +209,10 @@ bool ScriptApiItem::item_CraftPredict(ItemStack &item, ServerActiveObject *user,
// function onto the stack
// If core.registered_items[name] doesn't exist, core.nodedef_default
// is tried instead so unknown items can still be manipulated to some degree
-bool ScriptApiItem::getItemCallback(const char *name, const char *callbackname,
- const v3s16 *p)
+bool ScriptApiItem::getItemCallback(
+ const char *name, const char *callbackname, const v3s16 *p)
{
- lua_State* L = getStack();
+ lua_State *L = getStack();
lua_getglobal(L, "core");
lua_getfield(L, -1, "registered_items");
@@ -247,8 +246,8 @@ bool ScriptApiItem::getItemCallback(const char *name, const char *callbackname,
}
if (!lua_isnil(L, -1)) {
- errorstream << "Item \"" << name << "\" callback \""
- << callbackname << "\" is not a function" << std::endl;
+ errorstream << "Item \"" << name << "\" callback \"" << callbackname
+ << "\" is not a function" << std::endl;
}
lua_pop(L, 1);
return false;
@@ -256,8 +255,7 @@ bool ScriptApiItem::getItemCallback(const char *name, const char *callbackname,
void ScriptApiItem::pushPointedThing(const PointedThing &pointed, bool hitpoint)
{
- lua_State* L = getStack();
+ lua_State *L = getStack();
push_pointed_thing(L, pointed, false, hitpoint);
}
-