summaryrefslogtreecommitdiff
path: root/cans.lua
blob: 280949881a2da415d5779fac2cc4b49ccf251068 (plain)
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
water_can_max_load = 16
lava_can_max_load = 8

minetest.register_craft({
	output = 'technic:water_can 1',
	recipe = {
		{'technic:zinc_ingot', 'technic:rubber','technic:zinc_ingot'},
		{'default:steel_ingot', '', 'default:steel_ingot'},
		{'technic:zinc_ingot', 'default:steel_ingot', 'technic:zinc_ingot'},
	}
})

minetest.register_craft({
	output = 'technic:lava_can 1',
	recipe = {
		{'technic:zinc_ingot', 'technic:stainless_steel_ingot','technic:zinc_ingot'},
		{'technic:stainless_steel_ingot', '', 'technic:stainless_steel_ingot'},
		{'technic:zinc_ingot', 'technic:stainless_steel_ingot', 'technic:zinc_ingot'},
	}
})


minetest.register_tool("technic:water_can", {
	description = "Water Can",
	inventory_image = "technic_water_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.under)
		if n.name == "default:water_source" then
			item=itemstack:to_table()
			local load=tonumber((item["wear"])) 
			if  load==0 then load =65535 end
			load=get_RE_item_load(load,water_can_max_load)
			if load+1<17 then
			minetest.env:add_node(pointed_thing.under, {name="air"})
			 load=load+1;	
			load=set_RE_item_load(load,water_can_max_load)
			item["wear"]=tostring(load)
			itemstack:replace(item)
			end
			return itemstack
		end
		item=itemstack:to_table()
			load=tonumber((item["wear"])) 
			if  load==0 then load =65535 end
			load=get_RE_item_load(load,water_can_max_load)
			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;	
			load=set_RE_item_load(load,water_can_max_load)
			item["wear"]=tostring(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;	
			load=set_RE_item_load(load,water_can_max_load)
			item["wear"]=tostring(load)
			itemstack:replace(item)
			return itemstack
			end		
	end,
})

minetest.register_tool("technic:lava_can", {
	description = "Lava Can",
	inventory_image = "technic_lava_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.under)
		if n.name == "default:lava_source" then
			item=itemstack:to_table()
			local load=tonumber((item["wear"])) 
			if  load==0 then load =65535 end
			load=get_RE_item_load(load,lava_can_max_load)
			if load+1<9 then
			minetest.env:add_node(pointed_thing.under, {name="air"})
			 load=load+1;	
			load=set_RE_item_load(load,lava_can_max_load)
			item["wear"]=tostring(load)
			itemstack:replace(item)
			end
			return itemstack
		end
		item=itemstack:to_table()
			load=tonumber((item["wear"])) 
			if  load==0 then load =65535 end
			load=get_RE_item_load(load,lava_can_max_load)
			if load==0 then return end
			
		if n.name == "default:lava_flowing" then
			minetest.env:add_node(pointed_thing.under, {name="default:lava_source"})
			load=load-1;	
			load=set_RE_item_load(load,lava_can_max_load)
			item["wear"]=tostring(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:lava_source"})
			load=load-1;	
			load=set_RE_item_load(load,lava_can_max_load)
			item["wear"]=tostring(load)
			itemstack:replace(item)
			return itemstack
			end		
	end,
})