Don wrote:Is there a way to place a node and it places a schematic file. Doesn't matter if it is a .we or .mts
Also, is there a way to use on_punch to place or replace a schematic
yes, shure.
just have a look into my
gates mod. it does something like you want.
partial
code of gates mod:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
local function open_gate(pos)
--local start_time = os.clock()
local meta = minetest.get_meta(pos);
if meta:get_string("state") == "closed" then -- only open the gate if its closed
local pos1 = minetest.string_to_pos(meta:get_string("pos1"))
local pos2 = minetest.string_to_pos(meta:get_string("pos2"))
minetest.create_schematic(pos1, pos2,{}, savedir..minetest.pos_to_string(pos).."_closed.schematic")--save the closed gate before opening
minetest.place_schematic(pos1, savedir..minetest.pos_to_string(pos).."_opend.schematic", nil, nil, true)
meta:set_string("state","opend");
meta:set_string("infotext","opend");
minetest.swap_node(pos, {name="gates:controler_opend"})
end
--local end_time = os.clock()
--elapsed_time = end_time-start_time
--print('start time: ' .. start_time .. 's')
--print('end time: ' .. end_time .. 's')
--print('time elapsed: ' .. elapsed_time .. 's')
end
local function toggle(pos)
local meta = minetest.get_meta(pos);
if meta:get_string("state") == "opend" then
close_gate(pos);
return "closed"
else
open_gate(pos);
return "opend"
end
end
local function punched(pos, node, puncher, pointed_thing)
--print(schematic_exists(pos,"closed"),schematic_exists(pos,"opend"))
local playername = puncher:get_player_name()
if schematic_exists(pos,"closed") and schematic_exists(pos,"opend") then
local status = toggle(pos);
if status == "opend" then
minetest.chat_send_player(playername, "Gate Opened")
elseif status == "closed" then
minetest.chat_send_player(playername, "Gate Closed")
else
minetest.chat_send_player(playername, "ERROR: Unknown state of Gate")
end
end
end
minetest.register_node("gates:controler",{
description ="Gate controller",
tiles = {"gates_bg.png","gates_bg.png","gates_bg.png^gates_unknown.png"},
groups = {oddly_breakable_by_hand = 1},
after_place_node = placed,
on_receive_fields =submitted,
on_punch = punched
})
OT: i dont know how you will place a
*.mts file in a minetest world since its
avchd a video file :-P
so please call your file not *.mts, call it *.shemtic or *.mtsheme or...