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
Place a schematic
Place a schematic
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!
A list of my mods can be found here
A list of my mods can be found here
- addi
- Member
- Posts: 666
- Joined: Thu Sep 20, 2012 03:16
- GitHub: adrido
- Location: Black-Forest, Germany
Re: Place a schematic
yes, shure.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
just have a look into my gates mod. it does something like you want.
partial code of gates mod:
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
})
so please call your file not *.mts, call it *.shemtic or *.mtsheme or...
Re: Place a schematic
Thanks. I will look this over in the morning
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!
A list of my mods can be found here
A list of my mods can be found here
- Napiophelios
- Member
- Posts: 1035
- Joined: Mon Jul 07, 2014 01:14
- GitHub: Napiophelios
- IRC: Nappi
- In-game: Nappi
Re: Place a schematic
You should check out DeployNodes by cornernote
its not new but it still works and there are plenty of examples to study from
Also Maze by echo and HedgeMaze by thefamilygrog66
both kinda similar and both still work
its not new but it still works and there are plenty of examples to study from
Also Maze by echo and HedgeMaze by thefamilygrog66
both kinda similar and both still work
Re: Place a schematic
ThanksNapiophelios wrote:You should check out DeployNodes by cornernote
its not new but it still works and there are plenty of examples to study from
Also Maze by echo and HedgeMaze by thefamilygrog66
both kinda similar and both still work
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!
A list of my mods can be found here
A list of my mods can be found here
-
- Member
- Posts: 4289
- Joined: Sun Sep 09, 2012 17:31
- GitHub: Sokomine
- IRC: Sokomine
- In-game: Sokomine
Re: Place a schematic
My apartments mod uses .mts files for placing schematics. Just give yourshelf an apartment:build_chest, place it in the world, and spawn any schematic you like and which you have placed in the mod's schems/ folder. It also takes care of orientation and will spawn the building rotated according to the building spawner's facedir.
The mod can be found via the link in my signature.
The mod can be found via the link in my signature.
A list of my mods can be found here.
Re: Place a schematic
Thanks. I am busy over the holidays but hope to work on my mods lots in January.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!
A list of my mods can be found here
A list of my mods can be found here
Re: Place a schematic
Here is a quick example of a node, when placed that loads a schematic file:
Code: Select all
-- Schematic Block
minetest.register_node("test:schemblock", {
description = "Schematic Block",
tiles = {"default_grass.png"},
groups = {crumbly=3},
on_construct = function(pos)
-- Remove Schematic Block
minetest.remove_node(pos)
-- Define Schematic File
local schem = minetest.get_modpath("test").."/schems/build1.mts"
-- Define Placecment Coords
local spos = {x=pos.x-3,y=pos.y,z=pos.z-3}
-- Place Schematic
minetest.place_schematic(spos,schem,"0",{},false)
end,
})
Re: Place a schematic
Exactly what I needed. Thank you!
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!
A list of my mods can be found here
A list of my mods can be found here
Who is online
Users browsing this forum: No registered users and 3 guests