@@ -20,7 +20,7 @@ bucket.liquids = {}
20
20
21
21
local function check_protection (pos , name , text )
22
22
if minetest .is_protected (pos , name ) then
23
- minetest .log (" action" , name
23
+ minetest .log (" action" , ( name ~= " " and name or " A mod " )
24
24
.. " tried to " .. text
25
25
.. " at protected position "
26
26
.. minetest .pos_to_string (pos )
@@ -62,19 +62,25 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
62
62
if user and not user :get_player_control ().sneak then
63
63
local n = minetest .get_node (pointed_thing .under )
64
64
local nn = n .name
65
- if minetest .registered_nodes [nn ] and minetest .registered_nodes [nn ].on_rightclick then
66
- return minetest .registered_nodes [nn ].on_rightclick (pointed_thing .under , n , user , itemstack ) or itemstack
65
+ local ndef = minetest .registered_nodes [nn ]
66
+ if ndef and ndef .on_rightclick then
67
+ return ndef .on_rightclick (
68
+ pointed_thing .under ,
69
+ n , user ,
70
+ itemstack ) or itemstack
67
71
end
68
72
end
69
73
70
74
local place_liquid = function (pos , node , source , flowing , fullness )
71
75
if check_protection (pos ,
72
- user :get_player_name (),
76
+ user and user :get_player_name () or " " ,
73
77
" place " .. source ) then
74
78
return
75
79
end
76
- if math.floor (fullness / 128 ) == 1 or (not minetest .setting_getbool (" liquid_finite" )) then
77
- minetest .add_node (pos , {name = source , param2 = fullness })
80
+ if math.floor (fullness / 128 ) == 1 or
81
+ not minetest .setting_getbool (" liquid_finite" ) then
82
+ minetest .add_node (pos , {name = source ,
83
+ param2 = fullness })
78
84
return
79
85
elseif node .name == flowing then
80
86
fullness = fullness + node .param2
@@ -83,9 +89,11 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
83
89
end
84
90
85
91
if fullness >= LIQUID_MAX then
86
- minetest .add_node (pos , {name = source , param2 = LIQUID_MAX })
92
+ minetest .add_node (pos , {name = source ,
93
+ param2 = LIQUID_MAX })
87
94
else
88
- minetest .add_node (pos , {name = flowing , param2 = fullness })
95
+ minetest .add_node (pos , {name = flowing ,
96
+ param2 = fullness })
89
97
end
90
98
end
91
99
@@ -96,13 +104,16 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
96
104
97
105
if minetest .registered_nodes [node .name ].buildable_to then
98
106
-- buildable; replace the node
99
- place_liquid (pointed_thing .under , node , source , flowing , fullness )
107
+ place_liquid (pointed_thing .under , node ,
108
+ source , flowing , fullness )
100
109
else
101
110
-- not buildable to; place the liquid above
102
111
-- check if the node above can be replaced
103
112
local node = minetest .get_node (pointed_thing .above )
104
113
if minetest .registered_nodes [node .name ].buildable_to then
105
- place_liquid (pointed_thing .above , node , source , flowing , fullness )
114
+ place_liquid (pointed_thing .above ,
115
+ node , source ,
116
+ flowing , fullness )
106
117
else
107
118
-- do not remove the bucket with the liquid
108
119
return
@@ -127,9 +138,10 @@ minetest.register_craftitem("bucket:bucket_empty", {
127
138
-- Check if pointing to a liquid source
128
139
node = minetest .get_node (pointed_thing .under )
129
140
liquiddef = bucket .liquids [node .name ]
130
- if liquiddef ~= nil and liquiddef .itemname ~= nil and (node .name == liquiddef .source or
131
- (node .name == liquiddef .flowing and minetest .setting_getbool (" liquid_finite" ))) then
132
-
141
+ if liquiddef ~= nil and liquiddef .itemname ~= nil and
142
+ (node .name == liquiddef .source or
143
+ (node .name == liquiddef .flowing and
144
+ minetest .setting_getbool (" liquid_finite" ))) then
133
145
if check_protection (pointed_thing .under ,
134
146
user :get_player_name (),
135
147
" take " .. node .name ) then
@@ -138,8 +150,11 @@ minetest.register_craftitem("bucket:bucket_empty", {
138
150
139
151
minetest .add_node (pointed_thing .under , {name = " air" })
140
152
141
- if node .name == liquiddef .source then node .param2 = LIQUID_MAX end
142
- return ItemStack ({name = liquiddef .itemname , metadata = tostring (node .param2 )})
153
+ if node .name == liquiddef .source then
154
+ node .param2 = LIQUID_MAX
155
+ end
156
+ return ItemStack ({name = liquiddef .itemname ,
157
+ metadata = tostring (node .param2 )})
143
158
end
144
159
end ,
145
160
})
0 commit comments