aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_item.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-08-20 13:30:50 +0200
committerGitHub <noreply@github.com>2017-08-20 13:30:50 +0200
commit1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3 (patch)
tree03dd0c39e323c7f0b1f06014ff30e74f429bfa01 /src/script/cpp_api/s_item.cpp
parent50669cd2822a11570ae462972194eeb2d585a8c1 (diff)
downloaddragonfireclient-1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3.tar.xz
Modernize source code: last part (#6285)
* Modernize source code: last par * Use empty when needed * Use emplace_back instead of push_back when needed * For range-based loops * Initializers fixes * constructors, destructors default * c++ C stl includes
Diffstat (limited to 'src/script/cpp_api/s_item.cpp')
-rw-r--r--src/script/cpp_api/s_item.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/script/cpp_api/s_item.cpp b/src/script/cpp_api/s_item.cpp
index 032018f2f..d48a3aee9 100644
--- a/src/script/cpp_api/s_item.cpp
+++ b/src/script/cpp_api/s_item.cpp
@@ -113,12 +113,12 @@ bool ScriptApiItem::item_OnUse(ItemStack &item,
bool ScriptApiItem::item_OnSecondaryUse(ItemStack &item, ServerActiveObject *user)
{
SCRIPTAPI_PRECHECKHEADER
-
+
int error_handler = PUSH_ERROR_HANDLER(L);
-
+
if (!getItemCallback(item.name.c_str(), "on_secondary_use"))
return false;
-
+
LuaItemStack::create(L, item);
objectrefGetOrCreate(L, user);
PointedThing pointed;
@@ -237,7 +237,9 @@ bool ScriptApiItem::getItemCallback(const char *name, const char *callbackname)
// Should be a function or nil
if (lua_type(L, -1) == LUA_TFUNCTION) {
return true;
- } else if (!lua_isnil(L, -1)) {
+ }
+
+ if (!lua_isnil(L, -1)) {
errorstream << "Item \"" << name << "\" callback \""
<< callbackname << "\" is not a function" << std::endl;
}