forked from Gerold55/ma_pops_furniture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tools.lua
129 lines (119 loc) · 3.71 KB
/
tools.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
125
126
127
128
129
local USES = 200 --how many times you can use the tool before it breaks.
minetest.register_tool('ma_pops_furniture:hammer', {
description = 'Hammer',
inventory_image = 'mp_hammer.png',
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= 'node' then
return
end
local pos = pointed_thing.under
local node = minetest.get_node(pos)
local sofa_table = {
{'black'},
{'blue'},
{'brown'},
{'cyan'},
{'dark_green'},
{'dark_grey'},
{'green'},
{'grey'},
{'magenta'},
{'orange'},
{'pink'},
{'red'},
{'violet'},
{'white'},
{'yellow'},
}
for i in ipairs (sofa_table) do
local color = sofa_table[i][1]
if node.name == 'ma_pops_furniture:sofa_'..color then
minetest.set_node(pos,{name = 'ma_pops_furniture:sofa_r_'..color, param2=node.param2})
end
if node.name == 'ma_pops_furniture:sofa_r_'..color then
minetest.set_node(pos,{name = 'ma_pops_furniture:sofa_m_'..color, param2=node.param2})
end
if node.name == 'ma_pops_furniture:sofa_m_'..color then
minetest.set_node(pos,{name = 'ma_pops_furniture:sofa_l_'..color, param2=node.param2})
end
if node.name == 'ma_pops_furniture:sofa_l_'..color then
minetest.set_node(pos,{name = 'ma_pops_furniture:sofa_c_'..color, param2=node.param2})
end
if node.name == 'ma_pops_furniture:sofa_c_'..color then
minetest.set_node(pos,{name = 'ma_pops_furniture:sofa_'..color, param2=node.param2})
end
end
if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535 / (USES - 1))
end
return itemstack
end,
on_place = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= 'node' then
return
end
local pos = pointed_thing.under
local node = minetest.get_node(pos).name
local para = minetest.get_node(pos).param2
local newpara = para + 1
if newpara > 3 then
newpara = 0
end
minetest.set_node(pos,{name = ""..node, param2 = newpara})
if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535 / (USES - 1))
end
return itemstack
end,
})
minetest.register_tool('ma_pops_furniture:shears', {
description = 'Shears',
inventory_image = 'mp_shears.png',
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= 'node' then
return
end
local pos = pointed_thing.under
local node = minetest.get_node(pos)
local hedge_table = { --material
{'leaves'},
{'pine_needles'},
{'jungleleaves'},
{'aspen_leaves'},
{'acacia_leaves'}
}
for i in ipairs (hedge_table) do
local mat = hedge_table[i][1]
if node.name == 'ma_pops_furniture:hedge_'..mat then
minetest.set_node(pos,{name = 'ma_pops_furniture:hedge_t_'..mat, param2=node.param2})
end
if node.name == 'ma_pops_furniture:hedge_t_'..mat then
minetest.set_node(pos,{name = 'ma_pops_furniture:hedge_c_'..mat, param2=node.param2})
end
if node.name == 'ma_pops_furniture:hedge_c_'..mat then
minetest.set_node(pos,{name = 'ma_pops_furniture:hedge_'..mat, param2=node.param2})
end
end
if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535 / (USES - 1))
end
return itemstack
end,
on_place = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= 'node' then
return
end
local pos = pointed_thing.under
local node = minetest.get_node(pos).name
local para = minetest.get_node(pos).param2
local newpara = para + 1
if newpara > 3 then
newpara = 0
end
minetest.set_node(pos,{name = ""..node, param2 = newpara})
if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535 / (USES - 1))
end
return itemstack
end,
})