convertin mts to lua, replacing wall material and placing schematic

master
Rochambeau 2018-06-26 19:48:08 +02:00
parent 515980c5e1
commit e9253d84dd
6 changed files with 4 additions and 2046 deletions

View File

@ -10,16 +10,9 @@ function settlements.build_schematic(pos)
-- schematic conversion to lua
local schem_lua = minetest.serialize_schematic(building, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}).." return(schematic)"
-- replace material
schem_lua = schem_lua:gsub("default_cobble", material)
schem_lua = schem_lua:gsub("default:cobble", material):gsub("default:dirt_with_grass", balcony_material)
-- format schematic string
local schematic = loadstring(schem_lua)()
-- convert to mts
local schem_mts = minetest.serialize_schematic(schematic, "mts", {})
-- write file
local file, err = io.open(schem_path.."temp.mts", "wb")
file:write(schem_mts)
file:flush()
file:close()
-- place schematic
minetest.place_schematic(pos, schem_path.."temp.mts", "random", nil, true)
minetest.place_schematic(pos, schematic, "random", nil, true)
end

View File

@ -50,8 +50,8 @@ minetest.register_craftitem("settlements:tool", {
on_use = function(itemstack, placer, pointed_thing)
local p = pointed_thing.under
if p then
-- settlements.build_schematic(p)
settlements.convert_mts_to_lua()
settlements.build_schematic(p)
-- settlements.convert_mts_to_lua()
-- settlements.mts_save()
end
end

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@ -88,38 +88,6 @@ function settlements.find_locations(minp, maxp)
return location_list
end
--
-- Function to place a door
--
function settlements.torch(pos)
local p3 = settlements.shallowCopy(pos)
-- find door facedir
local wallmounted
local e = minetest.get_node_or_nil({x=p3.x+1, y=p3.y-1, z=p3.z})
local w = minetest.get_node_or_nil({x=p3.x-1, y=p3.y-1, z=p3.z})
local n = minetest.get_node_or_nil({x=p3.x, y=p3.y-1, z=p3.z+1})
local s = minetest.get_node_or_nil({x=p3.x, y=p3.y-1, z=p3.z-1})
if e and e.name ~= "air" then
-- minetest.chat_send_all('e')
-- minetest.chat_send_all(e.name)
wallmounted = 2
elseif w and w.name ~= "air" then
-- minetest.chat_send_all('w')
-- minetest.chat_send_all(w.name)
wallmounted = 3
elseif n and n.name ~= "air" then
-- minetest.chat_send_all('n')
-- minetest.chat_send_all(n.name)
wallmounted = 4
elseif s and s.name ~= "air" then
-- minetest.chat_send_all('s')
-- minetest.chat_send_all(s.name)
wallmounted = 5
end
-- place door
minetest.set_node(p3,{name = "default:torch_wall", param2 = wallmounted})
end
--
function settlements.convert_mts_to_lua()
local building = schem_path.."hut.mts"
local str = minetest.serialize_schematic(building, "lua", {lua_use_comments = true, lua_num_indent_spaces = 0}).." return(schematic)"