]> git.lizzy.rs Git - Crafter.git/blob - mods/walls/init.lua
remove server debug
[Crafter.git] / mods / walls / init.lua
1 local fence_collision_extra = 4/8
2
3 --create fences for all solid nodes
4 for name,def in pairs(minetest.registered_nodes) do
5         if def.drawtype == "normal" and string.match(name, "main:") then
6         
7                 --set up fence
8                 local def2 = table.copy(def)
9                 local newname = "walls:"..string.gsub(name, "main:", "").."_fence"
10                 def2.mod_origin = "walls"
11                 def2.name = newname
12                 def2.description = def.description.." Fence"
13                 def2.drop = newname
14                 def2.paramtype = "light"
15                 def2.drawtype = "nodebox"
16                 def2.on_dig = nil
17                 def2.node_box = {
18                         type = "connected",
19                         fixed = {-1/8, -1/2, -1/8, 1/8, 1/2, 1/8},
20                         -- connect_top =
21                         -- connect_bottom =
22                         connect_front = {{-1/16,  3/16, -1/2,   1/16,  5/16, -1/8 },
23                                          {-1/16, -5/16, -1/2,   1/16, -3/16, -1/8 }},
24                         connect_left =  {{-1/2,   3/16, -1/16, -1/8,   5/16,  1/16},
25                                          {-1/2,  -5/16, -1/16, -1/8,  -3/16,  1/16}},
26                         connect_back =  {{-1/16,  3/16,  1/8,   1/16,  5/16,  1/2 },
27                                          {-1/16, -5/16,  1/8,   1/16, -3/16,  1/2 }},
28                         connect_right = {{ 1/8,   3/16, -1/16,  1/2,   5/16,  1/16},
29                                          { 1/8,  -5/16, -1/16,  1/2,  -3/16,  1/16}}
30                 }
31                 def2.collision_box = {
32                         type = "connected",
33                         fixed = {-1/8, -1/2, -1/8, 1/8, 1/2 + fence_collision_extra, 1/8},
34                         -- connect_top =
35                         -- connect_bottom =
36                         connect_front = {-1/8, -1/2, -1/2,  1/8, 1/2 + fence_collision_extra, -1/8},
37                         connect_left =  {-1/2, -1/2, -1/8, -1/8, 1/2 + fence_collision_extra,  1/8},
38                         connect_back =  {-1/8, -1/2,  1/8,  1/8, 1/2 + fence_collision_extra,  1/2},
39                         connect_right = { 1/8, -1/2, -1/8,  1/2, 1/2 + fence_collision_extra,  1/8}
40                 }
41                 def2.connects_to = {"group:fence", "group:wood", "group:tree", "group:wall", "group:stone", "group:sand"}
42                 def2.sunlight_propagates = true
43                 minetest.register_node(newname,def2)
44                 
45                 minetest.register_craft({
46                         output = newname .. " 16",
47                         recipe = {
48                                 { name, 'main:stick', name },
49                                 { name, 'main:stick', name },
50                         }
51                 })
52                 
53         end
54 end
55
56 --create wall posts
57 for name,def in pairs(minetest.registered_nodes) do
58         if def.drawtype == "normal" and string.match(name, "main:") then
59         
60                 --set up wall
61                 local def2 = table.copy(def)
62                 local newname = "walls:"..string.gsub(name, "main:", "").."_wall_post"
63                 def2.description = def.description.." Wall"
64                 def2.mod_origin = "walls"
65                 def2.name = newname
66                 def2.drop = newname
67                 def2.paramtype = "light"
68                 def2.drawtype = "nodebox"
69                 def2.on_dig = nil
70                 --def2.on_place = function(itemstack, placer, pointed_thing)
71                 --      minetest.item_place(itemstack, placer, pointed_thing)
72                 --      wall_placing(pointed_thing.above,newname)
73                 --end
74                 def2.node_box = {
75                         type = "connected",
76                         disconnected_sides  = {-4/16, -1/2, -4/16, 4/16, 9/16, 4/16},
77                         -- connect_top =
78                         -- connect_bottom =
79                         connect_front = {-2/16,  -1/2, -1/2,   2/16,  1/2, 2/16 },
80                         connect_left =  {-1/2,   -1/2, -2/16, 2/16,   1/2,  2/16},
81                         connect_back =  {-2/16,  -1/2,  -2/16,   2/16,  1/2,  1/2 },
82                         connect_right = { -2/16,   -1/2, -2/16,  1/2,   1/2,  2/16},
83                 }
84                 def2.collision_box = {
85                         type = "connected",
86                         fixed = {-1/8, -1/2, -1/8, 1/8, 1/2 + fence_collision_extra, 1/8},
87                         -- connect_top =
88                         -- connect_bottom =
89                         connect_front = {-2/16,  -1/2, -1/2,   2/16,1/2 + fence_collision_extra, 2/16 },
90                         connect_left =  {-1/2,   -1/2, -2/16, 2/16,    1/2 + fence_collision_extra,  2/16},
91                         connect_back =  {-2/16,  -1/2,  -2/16,   2/16,  1/2 + fence_collision_extra,  1/2 },
92                         connect_right = {-2/16,   -1/2, -2/16,  1/2,   1/2 + fence_collision_extra,  2/16},
93                 }
94                 def2.groups["fence"] = 1
95                 def2.connects_to = {"group:fence", "group:wood", "group:tree", "group:wall", "group:stone", "group:sand"}
96                 def2.sunlight_propagates = true
97                 minetest.register_node(newname,def2)
98                 
99                 minetest.register_craft({
100                         output = newname .. " 16",
101                         recipe = {
102                                 { name, 'main:iron', name },
103                                 { name, name       , name },
104                         }
105                 })
106                 
107         end
108 end
109
110 --create window
111 local def = minetest.registered_nodes["main:glass"]
112
113 --set up wall
114 local def2 = table.copy(def)
115 local newname = "walls:window"
116 def2.description = "Window"
117 def2.mod_origin = "walls"
118 def2.name = newname
119 def2.drop = ""
120 def2.paramtype = "light"
121 def2.drawtype = "nodebox"
122 def2.on_dig = nil
123 --def2.on_place = function(itemstack, placer, pointed_thing)
124 --      minetest.item_place(itemstack, placer, pointed_thing)
125 --      wall_placing(pointed_thing.above,newname)
126 --end
127 def2.node_box = {
128         type = "connected",
129         disconnected_sides  = {
130         {-1/16,  -1/2, -1/2,   1/16,  1/2, 1/16 },
131         {-1/2,   -1/2, -1/16, 1/16,   1/2,  1/16},
132         {-1/16,  -1/2,  -1/16,   1/16,  1/2,  1/2 },
133         { -1/16,   -1/2, -1/16,  1/2,   1/2,  1/16},
134         },
135         -- connect_top =
136         -- connect_bottom =
137         connect_front = {-1/16,  -1/2, -1/2,   1/16,  1/2, 1/16 },
138         connect_left =  {-1/2,   -1/2, -1/16, 1/16,   1/2,  1/16},
139         connect_back =  {-1/16,  -1/2,  -1/16,   1/16,  1/2,  1/2 },
140         connect_right = { -1/16,   -1/2, -1/16,  1/2,   1/2,  1/16},
141 }
142
143 def2.connects_to = {"group:fence", "group:wood", "group:wall", "group:stone", "group:sand","group:glass"}
144 def2.sunlight_propagates = true
145 minetest.register_node(newname,def2)
146
147 minetest.register_craft({
148         output = newname .. " 16",
149         recipe = {
150                 { "main:glass", "main:glass" },
151                 { "main:glass", "main:glass" },
152         }
153 })
154
155
156
157