Place a schematic

User avatar
Don
Member
 
Posts: 1643
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Place a schematic

by Don » Tue Dec 16, 2014 01:55

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
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
 

User avatar
addi
Member
 
Posts: 659
Joined: Thu Sep 20, 2012 03:16
Location: Black-Forest, Germany
GitHub: adrido

Re: Place a schematic

by addi » Tue Dec 16, 2014 03:17

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:
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...
 

User avatar
Don
Member
 
Posts: 1643
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Place a schematic

by Don » Tue Dec 16, 2014 03:57

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
 

User avatar
Napiophelios
Member
 
Posts: 988
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: Place a schematic

by Napiophelios » Tue Dec 16, 2014 04:29

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
 

User avatar
Don
Member
 
Posts: 1643
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Place a schematic

by Don » Tue Dec 16, 2014 05:45

Napiophelios 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

Thanks
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
 

Sokomine
Member
 
Posts: 3956
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine

Re: Place a schematic

by Sokomine » Sun Dec 28, 2014 18:53

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.
A list of my mods can be found here.
 

User avatar
Don
Member
 
Posts: 1643
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Place a schematic

by Don » Sun Dec 28, 2014 21:54

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
 

User avatar
TenPlus1
Member
 
Posts: 2651
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: Place a schematic

by TenPlus1 » Mon Dec 29, 2014 10:42

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,
})
 

User avatar
Don
Member
 
Posts: 1643
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Place a schematic

by Don » Mon Dec 29, 2014 15:37

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
 


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 3 guests