-
Notifications
You must be signed in to change notification settings - Fork 38
/
wire_std.lua
124 lines (112 loc) · 3.29 KB
/
wire_std.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
local S = digilines.S
-- naming scheme: wire:(xp)(zp)(xm)(zm)_on/off
-- The conditions in brackets define whether there is a digiline at that place or not
-- 1 = there is one; 0 = there is none
-- y always means y+
local box_center = {-1/16, -.5, -1/16, 1/16, -.5+1/16, 1/16}
local box_bump1 = { -2/16, -8/16, -2/16, 2/16, -13/32, 2/16 }
local box_bump2 = { -3/32, -13/32, -3/32, 3/32, -12/32, 3/32 }
local box_xp = {1/16, -.5, -1/16, 8/16, -.5+1/16, 1/16}
local box_zp = {-1/16, -.5, 1/16, 1/16, -.5+1/16, 8/16}
local box_xm = {-8/16, -.5, -1/16, -1/16, -.5+1/16, 1/16}
local box_zm = {-1/16, -.5, -8/16, 1/16, -.5+1/16, -1/16}
local box_xpy = {.5-1/16, -.5+1/16, -1/16, .5, .4999+1/16, 1/16}
local box_zpy = {-1/16, -.5+1/16, .5-1/16, 1/16, .4999+1/16, .5}
local box_xmy = {-.5, -.5+1/16, -1/16, -.5+1/16, .4999+1/16, 1/16}
local box_zmy = {-1/16, -.5+1/16, -.5, 1/16, .4999+1/16, -.5+1/16}
for xp=0, 1 do
for zp=0, 1 do
for xm=0, 1 do
for zm=0, 1 do
for xpy=0, 1 do
for zpy=0, 1 do
for xmy=0, 1 do
for zmy=0, 1 do
if (xpy == 1 and xp == 0) or (zpy == 1 and zp == 0)
or (xmy == 1 and xm == 0) or (zmy == 1 and zm == 0) then break end
local groups
local nodeid = tostring(xp )..tostring(zp )..tostring(xm )..tostring(zm )..
tostring(xpy)..tostring(zpy)..tostring(xmy)..tostring(zmy)
local wiredesc
if nodeid == "00000000" then
groups = {dig_immediate = 3}
wiredesc = S("Digiline")
else
groups = {dig_immediate = 3, not_in_creative_inventory = 1}
end
local nodebox = {}
local adjx = false
local adjz = false
if xp == 1 then table.insert(nodebox, box_xp) adjx = true end
if zp == 1 then table.insert(nodebox, box_zp) adjz = true end
if xm == 1 then table.insert(nodebox, box_xm) adjx = true end
if zm == 1 then table.insert(nodebox, box_zm) adjz = true end
if xpy == 1 then table.insert(nodebox, box_xpy) end
if zpy == 1 then table.insert(nodebox, box_zpy) end
if xmy == 1 then table.insert(nodebox, box_xmy) end
if zmy == 1 then table.insert(nodebox, box_zmy) end
local tiles
if adjx and adjz and (xp + zp + xm + zm > 2) then
table.insert(nodebox, box_bump1)
table.insert(nodebox, box_bump2)
tiles = {
"digiline_std_bump.png",
"digiline_std_bump.png",
"digiline_std_vertical.png",
"digiline_std_vertical.png",
"digiline_std_vertical.png",
"digiline_std_vertical.png"
}
else
table.insert(nodebox, box_center)
tiles = {
"digiline_std.png",
"digiline_std.png",
"digiline_std_vertical.png",
"digiline_std_vertical.png",
"digiline_std_vertical.png",
"digiline_std_vertical.png"
}
end
if nodeid == "00000000" then
nodebox = {-8/16, -.5, -1/16, 8/16, -.5+1/16, 1/16}
end
minetest.register_node("digilines:wire_std_"..nodeid, {
description = wiredesc,
drawtype = "nodebox",
tiles = tiles,
inventory_image = "digiline_std_inv.png",
wield_image = "digiline_std_inv.png",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
digilines =
{
wire =
{
basename = "digilines:wire_std_",
use_autoconnect = true
}
},
selection_box = {
type = "fixed",
fixed = {-.5, -.5, -.5, .5, -.5+1/16, .5}
},
node_box = {
type = "fixed",
fixed = nodebox
},
groups = groups,
is_ground_content = false,
walkable = false,
stack_max = 99,
drop = "digilines:wire_std_00000000"
})
end
end
end
end
end
end
end
end