-
Notifications
You must be signed in to change notification settings - Fork 0
/
containers.lua
191 lines (162 loc) · 4.11 KB
/
containers.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
local oil_drum_max_load = 55
-- oil drum
-- gas can
-- lpg bottle (steel bottle + regulator)
-- large storage containers
-- very large storage container, possibly arbitrarily constructable like nuke reactor
--[[ NEED:
textures:
steel drum
medium lpg bottle
pipes
inv textures:
plastic gas can
small lpg bottle
lpg regulator
pipes
sounds:
metal sounds
filling sounds
craft items:
^ lpg regulator
small lpg bottle
gas can
pipes
register tool:
gas can
small lpg bottle
register node:
oil drum
medium lpg bottle
large lpg bottle sections
pipes
box models:
medium lpg bottle
large lpg bottle sections
oil drum
pipes
]]
bitumen.containers = {}
bitumen.containers.max_fill = {
{oil_drum = 200},
{gas_can = 20},
}
-- gas can is a tool
minetest.register_tool("bitumen:gas_can", {
description = "Gas Can",
inventory_image = "bitumen_gas_can.png",
stack_max = 1,
-- liquids_pointable = true,
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then
return end
n = minetest.env:get_node(pointed_thing)
-- only operate on oil givers
if n.group.oilpipe_give ~= 1 then
return end
item=itemstack:to_table()
local fill=nil
if item["metadata"]=="" then fill=0
else fill=tonumber(item["metadata"])
end
-- can is empty
if fill <= 0 then return end
-- if n.name == "default:water_source" then
-- if load+1<17 then
-- minetest.env:add_node(pointed_thing.under, {name="air"})
-- load=load+1;
-- item["metadata"]=tostring(load)
-- technic.set_RE_wear(item,load,water_can_max_load)
-- itemstack:replace(item)
-- end
-- return itemstack
-- end
item=itemstack:to_table()
if load==0 then return end
if n.name == "default:water_flowing" then
minetest.env:add_node(pointed_thing.under, {name="default:water_source"})
load=load-1;
item["metadata"]=tostring(load)
technic.set_RE_wear(item,load,water_can_max_load)
itemstack:replace(item)
return itemstack
end
n = minetest.env:get_node(pointed_thing.above)
if n.name == "air" then
minetest.env:add_node(pointed_thing.above, {name="default:water_source"})
load=load-1;
item["metadata"]=tostring(load)
technic.set_RE_wear(item,load,water_can_max_load)
itemstack:replace(item)
return itemstack
end
end,
})
minetest.register_node(":bitumen:oil_drum", {
description = "Oil Drum",
tiles = {"bitumen_drum_top.png", "bitumen_drum_bottom.png", "bitumen_drum_side.png",
"bitumen_drum_side.png", "bitumen_drum_side.png", "bitumen_drum_side.png"},
paramtype2 = "facedir",
-- inventory_image = "bitumen_oil_drum.png",
groups = {
cracky=2,
oddly_breakable_by_hand=2,
oilpipe=1,
oilpipe_receive=1,
oil_container = 1
},
paramtype = "light",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
--11.25
{-0.49, -0.5, -0.10, 0.49, 0.5, 0.10},
{-0.10, -0.5, -0.49, 0.10, 0.5, 0.49},
--22.5
{-0.46, -0.5, -0.19, 0.46, 0.5, 0.19},
{-0.19, -0.5, -0.46, 0.19, 0.5, 0.46},
-- 33.75
{-0.416, -0.5, -0.28, 0.416, 0.5, 0.28},
{-0.28, -0.5, -0.416, 0.28, 0.5, 0.416},
--45
{-0.35, -0.5, -0.35, 0.35, 0.5, 0.35},
},
},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
},
-- stack_max = 99,
-- tube = tubes_properties,legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "Oil Drum (Empty)")
meta:set_string("oiltype", "Empty")
meta:set_int("filllevel", "0")
-- meta:set_string("fillmax", "200") -- 55 US Gal, 44 Imp. Gal, 200 L
local inv = meta:get_inventory()
inv:set_size("main", 10*4)
end,
can_dig = function(pos, player)
local meta = minetest.env:get_meta(pos)
if meta:get_int('filllevel') > 0 then
return false
end
return true
end,
})
-- minetest.register_tool("bitumen:oil_drum", {
-- description = "55 Gallon Oil Drum",
-- inventory_image = "technic_battery.png",
-- tool_capabilities = {
-- charge = 0,
-- max_drop_level = 0,
-- groupcaps = {
-- fleshy = {times={}, uses=10000, maxlevel=0}
-- }
-- }
-- })