aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
Diffstat (limited to 'src/script')
-rw-r--r--src/script/common/c_content.cpp20
-rw-r--r--src/script/lua_api/luaapi.cpp11
2 files changed, 21 insertions, 10 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index f9765b655..ca7c7fde9 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -956,8 +956,24 @@ bool read_schematic(lua_State *L, int index, DecoSchematic *dschem, Server *serv
lua_pushnil(L);
while (lua_next(L, -2)) {
- if (i < numnodes)
- schemdata[i] = readnode(L, -1, ndef);
+ if (i < numnodes) {
+ // same as readnode, except param1 default is MTSCHEM_PROB_CONST
+ lua_getfield(L, -1, "name");
+ const char *name = luaL_checkstring(L, -1);
+ lua_pop(L, 1);
+
+ u8 param1;
+ lua_getfield(L, -1, "param1");
+ param1 = !lua_isnil(L, -1) ? lua_tonumber(L, -1) : MTSCHEM_PROB_ALWAYS;
+ lua_pop(L, 1);
+
+ u8 param2;
+ lua_getfield(L, -1, "param2");
+ param2 = !lua_isnil(L, -1) ? lua_tonumber(L, -1) : 0;
+ lua_pop(L, 1);
+
+ schemdata[i] = MapNode(ndef, name, param1, param2);
+ }
i++;
lua_pop(L, 1);
diff --git a/src/script/lua_api/luaapi.cpp b/src/script/lua_api/luaapi.cpp
index 929aa40d0..26fb0c318 100644
--- a/src/script/lua_api/luaapi.cpp
+++ b/src/script/lua_api/luaapi.cpp
@@ -867,7 +867,7 @@ int ModApiBasic::l_create_schematic(lua_State *L)
v3s16 p2 = read_v3s16(L, 2);
sortBoxVerticies(p1, p2);
- std::vector<std::pair<v3s16, s16> > probability_list;
+ std::vector<std::pair<v3s16, u8> > probability_list;
if (lua_istable(L, 3)) {
lua_pushnil(L);
while (lua_next(L, 3)) {
@@ -876,13 +876,8 @@ int ModApiBasic::l_create_schematic(lua_State *L)
v3s16 pos = read_v3s16(L, -1);
lua_pop(L, 1);
- s16 prob = getintfield_default(L, -1, "prob", 0);
- if (prob < -1 || prob >= UCHAR_MAX) {
- errorstream << "create_schematic: probability value of "
- << prob << " at " << PP(pos) << " out of range" << std::endl;
- } else {
- probability_list.push_back(std::make_pair(pos, prob));
- }
+ u8 prob = getintfield_default(L, -1, "prob", 0xFF);
+ probability_list.push_back(std::make_pair(pos, prob));
}
lua_pop(L, 1);