aboutsummaryrefslogtreecommitdiff
path: root/games/devtest/mods/bucket/init.lua
blob: ff58b0669493e7010781b9489dc12c4106a1d128 (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
-- Bucket: Punch liquid source or flowing liquid to collect it

minetest.register_tool("bucket:bucket", {
	description = "Bucket".."\n"..
		"Picks up liquid nodes",
	inventory_image = "bucket.png",
	stack_max = 1,
	liquids_pointable = true,
	groups = { disable_repair = 1 },
	on_use = function(itemstack, user, pointed_thing)
		-- Must be pointing to node
		if pointed_thing.type ~= "node" then
			return
		end
		-- Check if pointing to a liquid
		local n = minetest.get_node(pointed_thing.under)
		local def = minetest.registered_nodes[n.name]
		if def ~= nil and (def.liquidtype == "source" or def.liquidtype == "flowing") then
			minetest.add_node(pointed_thing.under, {name="air"})
			local inv = user:get_inventory()
			if inv then
				inv:add_item("main", ItemStack(n.name))
			end
		end
	end,
})

class="hl opt">, fields, 1) end end) minetest.register_on_player_receive_fields(function(player, formname, fields) if callback_test == 2 then out(player, formname, fields, 2) return true -- Disable the first callback end end) minetest.register_on_player_receive_fields(function(player, formname, fields) if callback_test == 2 then out(player, formname, fields, 3) end end) minetest.register_chatcommand("test_formspec_callbacks", { params = "[ 0 | 1 | 2 ]", description = "Test: Change formspec callbacks testing mode", func = function(name, param) local mode = tonumber(param) if not mode then callback_test = (callback_test + 1 % 3) else callback_test = mode end if callback_test == 1 then minetest.chat_send_player(name, "Formspec callback test mode 1 enabled: Logging only") elseif callback_test == 2 then minetest.chat_send_player(name, "Formspec callback test mode 2 enabled: Three callbacks, disable pre-registered callbacks") else callback_test = 0 minetest.chat_send_player(name, "Formspec callback test disabled!") end end })