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.cpp10
-rw-r--r--src/script/common/c_converter.cpp29
-rw-r--r--src/script/common/c_converter.h3
3 files changed, 37 insertions, 5 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index 4d8cdd352..1bbfac25f 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -1586,13 +1586,13 @@ bool read_noiseparams(lua_State *L, int index, NoiseParams *np)
void push_noiseparams(lua_State *L, NoiseParams *np)
{
lua_newtable(L);
- lua_pushnumber(L, np->offset);
+ push_float_string(L, np->offset);
lua_setfield(L, -2, "offset");
- lua_pushnumber(L, np->scale);
+ push_float_string(L, np->scale);
lua_setfield(L, -2, "scale");
- lua_pushnumber(L, np->persist);
+ push_float_string(L, np->persist);
lua_setfield(L, -2, "persistence");
- lua_pushnumber(L, np->lacunarity);
+ push_float_string(L, np->lacunarity);
lua_setfield(L, -2, "lacunarity");
lua_pushnumber(L, np->seed);
lua_setfield(L, -2, "seed");
@@ -1603,7 +1603,7 @@ void push_noiseparams(lua_State *L, NoiseParams *np)
np->flags);
lua_setfield(L, -2, "flags");
- push_v3f(L, np->spread);
+ push_v3_float_string(L, np->spread);
lua_setfield(L, -2, "spread");
}
diff --git a/src/script/common/c_converter.cpp b/src/script/common/c_converter.cpp
index 8f88aeb60..e81cecac8 100644
--- a/src/script/common/c_converter.cpp
+++ b/src/script/common/c_converter.cpp
@@ -51,6 +51,15 @@ if (value < F1000_MIN || value > F1000_MAX) { \
#define CHECK_POS_TAB(index) CHECK_TYPE(index, "position", LUA_TTABLE)
+void push_float_string(lua_State *L, float value)
+{
+ std::stringstream ss;
+ std::string str;
+ ss << value;
+ str = ss.str();
+ lua_pushstring(L, str.c_str());
+}
+
void push_v3f(lua_State *L, v3f p)
{
lua_newtable(L);
@@ -71,6 +80,26 @@ void push_v2f(lua_State *L, v2f p)
lua_setfield(L, -2, "y");
}
+void push_v3_float_string(lua_State *L, v3f p)
+{
+ lua_newtable(L);
+ push_float_string(L, p.X);
+ lua_setfield(L, -2, "x");
+ push_float_string(L, p.Y);
+ lua_setfield(L, -2, "y");
+ push_float_string(L, p.Z);
+ lua_setfield(L, -2, "z");
+}
+
+void push_v2_float_string(lua_State *L, v2f p)
+{
+ lua_newtable(L);
+ push_float_string(L, p.X);
+ lua_setfield(L, -2, "x");
+ push_float_string(L, p.Y);
+ lua_setfield(L, -2, "y");
+}
+
v2s16 read_v2s16(lua_State *L, int index)
{
v2s16 p;
diff --git a/src/script/common/c_converter.h b/src/script/common/c_converter.h
index 18b8f6531..7827d8146 100644
--- a/src/script/common/c_converter.h
+++ b/src/script/common/c_converter.h
@@ -99,6 +99,9 @@ std::vector<aabb3f> read_aabb3f_vector (lua_State *L, int index, f32 scale);
size_t read_stringlist (lua_State *L, int index,
std::vector<std::string> *result);
+void push_float_string (lua_State *L, float value);
+void push_v3_float_string(lua_State *L, v3f p);
+void push_v2_float_string(lua_State *L, v2f p);
void push_v2s16 (lua_State *L, v2s16 p);
void push_v2s32 (lua_State *L, v2s32 p);
void push_v3s16 (lua_State *L, v3s16 p);