aboutsummaryrefslogtreecommitdiff
path: root/src/script/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/common')
-rw-r--r--src/script/common/c_content.cpp40
-rw-r--r--src/script/common/c_converter.cpp22
-rw-r--r--src/script/common/c_converter.h1
-rw-r--r--src/script/common/c_internal.cpp46
-rw-r--r--src/script/common/c_internal.h4
5 files changed, 73 insertions, 40 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index cb0253c32..accbb1a87 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -83,7 +83,7 @@ void read_item_definition(lua_State* L, int index,
getboolfield(L, index, "liquids_pointable", def.liquids_pointable);
warn_if_field_exists(L, index, "tool_digging_properties",
- "Deprecated; use tool_capabilities");
+ "Obsolete; use tool_capabilities");
lua_getfield(L, index, "tool_capabilities");
if(lua_istable(L, -1)){
@@ -208,8 +208,6 @@ void read_object_properties(lua_State *L, int index,
getboolfield(L, -1, "physical", prop->physical);
getboolfield(L, -1, "collide_with_objects", prop->collideWithObjects);
- getfloatfield(L, -1, "weight", prop->weight);
-
lua_getfield(L, -1, "collisionbox");
bool collisionbox_defined = lua_istable(L, -1);
if (collisionbox_defined)
@@ -340,8 +338,6 @@ void push_object_properties(lua_State *L, ObjectProperties *prop)
lua_setfield(L, -2, "physical");
lua_pushboolean(L, prop->collideWithObjects);
lua_setfield(L, -2, "collide_with_objects");
- lua_pushnumber(L, prop->weight);
- lua_setfield(L, -2, "weight");
push_aabb3f(L, prop->collisionbox);
lua_setfield(L, -2, "collisionbox");
push_aabb3f(L, prop->selectionbox);
@@ -643,19 +639,19 @@ ContentFeatures read_content_features(lua_State *L, int index)
warningstream << "Node " << f.name.c_str()
<< " has a palette, but not a suitable paramtype2." << std::endl;
- // Warn about some deprecated fields
+ // Warn about some obsolete fields
warn_if_field_exists(L, index, "wall_mounted",
- "Deprecated; use paramtype2 = 'wallmounted'");
+ "Obsolete; use paramtype2 = 'wallmounted'");
warn_if_field_exists(L, index, "light_propagates",
- "Deprecated; determined from paramtype");
+ "Obsolete; determined from paramtype");
warn_if_field_exists(L, index, "dug_item",
- "Deprecated; use 'drop' field");
+ "Obsolete; use 'drop' field");
warn_if_field_exists(L, index, "extra_dug_item",
- "Deprecated; use 'drop' field");
+ "Obsolete; use 'drop' field");
warn_if_field_exists(L, index, "extra_dug_item_rarity",
- "Deprecated; use 'drop' field");
+ "Obsolete; use 'drop' field");
warn_if_field_exists(L, index, "metadata_name",
- "Deprecated; use on_add and metadata callbacks");
+ "Obsolete; use on_add and metadata callbacks");
// True for all ground-like things like stone and mud, false for eg. trees
getboolfield(L, index, "is_ground_content", f.is_ground_content);
@@ -1023,6 +1019,7 @@ void read_server_sound_params(lua_State *L, int index,
params.max_hear_distance = BS*getfloatfield_default(L, index,
"max_hear_distance", params.max_hear_distance/BS);
getboolfield(L, index, "loop", params.loop);
+ getstringfield(L, index, "exclude_player", params.exclude_player);
}
}
@@ -1851,11 +1848,13 @@ void read_hud_element(lua_State *L, HudElement *elem)
elem->size = lua_istable(L, -1) ? read_v2s32(L, -1) : v2s32();
lua_pop(L, 1);
- elem->name = getstringfield_default(L, 2, "name", "");
- elem->text = getstringfield_default(L, 2, "text", "");
- elem->number = getintfield_default(L, 2, "number", 0);
- elem->item = getintfield_default(L, 2, "item", 0);
- elem->dir = getintfield_default(L, 2, "direction", 0);
+ elem->name = getstringfield_default(L, 2, "name", "");
+ elem->text = getstringfield_default(L, 2, "text", "");
+ elem->number = getintfield_default(L, 2, "number", 0);
+ elem->item = getintfield_default(L, 2, "item", 0);
+ elem->dir = getintfield_default(L, 2, "direction", 0);
+ elem->z_index = MYMAX(S16_MIN, MYMIN(S16_MAX,
+ getintfield_default(L, 2, "z_index", 0)));
// Deprecated, only for compatibility's sake
if (elem->dir == 0)
@@ -1921,6 +1920,9 @@ void push_hud_element(lua_State *L, HudElement *elem)
push_v3f(L, elem->world_pos);
lua_setfield(L, -2, "world_pos");
+
+ lua_pushnumber(L, elem->z_index);
+ lua_setfield(L, -2, "z_index");
}
HudElementStat read_hud_change(lua_State *L, HudElement *elem, void **value)
@@ -1978,6 +1980,10 @@ HudElementStat read_hud_change(lua_State *L, HudElement *elem, void **value)
elem->size = read_v2s32(L, 4);
*value = &elem->size;
break;
+ case HUD_STAT_Z_INDEX:
+ elem->z_index = MYMAX(S16_MIN, MYMIN(S16_MAX, luaL_checknumber(L, 4)));
+ *value = &elem->z_index;
+ break;
}
return stat;
}
diff --git a/src/script/common/c_converter.cpp b/src/script/common/c_converter.cpp
index b9d6f0494..3c2f75641 100644
--- a/src/script/common/c_converter.cpp
+++ b/src/script/common/c_converter.cpp
@@ -335,6 +335,28 @@ video::SColor read_ARGB8(lua_State *L, int index)
return color;
}
+bool is_color_table(lua_State *L, int index)
+{
+ // Check whole table in case of missing ColorSpec keys:
+ // This check does not remove the checked value from the stack.
+ // Only update the value if we know we have a valid ColorSpec key pair.
+ if (!lua_istable(L, index))
+ return false;
+
+ bool is_color_table = false;
+ lua_getfield(L, index, "r");
+ if (!is_color_table)
+ is_color_table = lua_isnumber(L, -1);
+ lua_getfield(L, index, "g");
+ if (!is_color_table)
+ is_color_table = lua_isnumber(L, -1);
+ lua_getfield(L, index, "b");
+ if (!is_color_table)
+ is_color_table = lua_isnumber(L, -1);
+ lua_pop(L, 3); // b, g, r values
+ return is_color_table;
+}
+
aabb3f read_aabb3f(lua_State *L, int index, f32 scale)
{
aabb3f box;
diff --git a/src/script/common/c_converter.h b/src/script/common/c_converter.h
index f84494c8d..9620bf75a 100644
--- a/src/script/common/c_converter.h
+++ b/src/script/common/c_converter.h
@@ -110,6 +110,7 @@ v2s32 read_v2s32 (lua_State *L, int index);
video::SColor read_ARGB8 (lua_State *L, int index);
bool read_color (lua_State *L, int index,
video::SColor *color);
+bool is_color_table (lua_State *L, int index);
aabb3f read_aabb3f (lua_State *L, int index, f32 scale);
v3s16 read_v3s16 (lua_State *L, int index);
diff --git a/src/script/common/c_internal.cpp b/src/script/common/c_internal.cpp
index f792b6218..b19af9f82 100644
--- a/src/script/common/c_internal.cpp
+++ b/src/script/common/c_internal.cpp
@@ -47,7 +47,7 @@ int script_exception_wrapper(lua_State *L, lua_CFunction f)
/*
* Note that we can't get tracebacks for LUA_ERRMEM or LUA_ERRERR (without
* hacking Lua internals). For LUA_ERRMEM, this is because memory errors will
- * not execute the the error handler, and by the time lua_pcall returns the
+ * not execute the error handler, and by the time lua_pcall returns the
* execution stack will have already been unwound. For LUA_ERRERR, there was
* another error while trying to generate a backtrace from a LUA_ERRRUN. It is
* presumed there is an error with the internal Lua state and thus not possible
@@ -135,7 +135,27 @@ void script_run_callbacks_f(lua_State *L, int nargs,
lua_remove(L, error_handler);
}
-void log_deprecated(lua_State *L, const std::string &message)
+static void script_log(lua_State *L, const std::string &message,
+ std::ostream &log_to, bool do_error, int stack_depth)
+{
+ lua_Debug ar;
+
+ log_to << message << " ";
+ if (lua_getstack(L, stack_depth, &ar)) {
+ FATAL_ERROR_IF(!lua_getinfo(L, "Sl", &ar), "lua_getinfo() failed");
+ log_to << "(at " << ar.short_src << ":" << ar.currentline << ")";
+ } else {
+ log_to << "(at ?:?)";
+ }
+ log_to << std::endl;
+
+ if (do_error)
+ script_error(L, LUA_ERRRUN, NULL, NULL);
+ else
+ infostream << script_get_backtrace(L) << std::endl;
+}
+
+void log_deprecated(lua_State *L, const std::string &message, int stack_depth)
{
static bool configured = false;
static bool do_log = false;
@@ -152,24 +172,6 @@ void log_deprecated(lua_State *L, const std::string &message)
}
}
- if (do_log) {
- warningstream << message;
- if (L) { // L can be NULL if we get called from scripting_game.cpp
- lua_Debug ar;
-
- if (!lua_getstack(L, 2, &ar))
- FATAL_ERROR_IF(!lua_getstack(L, 1, &ar), "lua_getstack() failed");
- FATAL_ERROR_IF(!lua_getinfo(L, "Sl", &ar), "lua_getinfo() failed");
- warningstream << " (at " << ar.short_src << ":" << ar.currentline << ")";
- }
- warningstream << std::endl;
-
- if (L) {
- if (do_error)
- script_error(L, LUA_ERRRUN, NULL, NULL);
- else
- infostream << script_get_backtrace(L) << std::endl;
- }
- }
+ if (do_log)
+ script_log(L, message, warningstream, do_error, stack_depth);
}
-
diff --git a/src/script/common/c_internal.h b/src/script/common/c_internal.h
index d2131d1ad..d8cf3fe76 100644
--- a/src/script/common/c_internal.h
+++ b/src/script/common/c_internal.h
@@ -103,4 +103,6 @@ int script_exception_wrapper(lua_State *L, lua_CFunction f);
void script_error(lua_State *L, int pcall_result, const char *mod, const char *fxn);
void script_run_callbacks_f(lua_State *L, int nargs,
RunCallbacksMode mode, const char *fxn);
-void log_deprecated(lua_State *L, const std::string &message);
+
+void log_deprecated(lua_State *L, const std::string &message,
+ int stack_depth=1);