@@ -139,7 +139,7 @@ function circular_saw:reset(pos)
139139 end
140140
141141 inv :set_list (" input" , {})
142- -- inv:set_list("micro", {})
142+ inv :set_list (" micro" , {})
143143
144144 local microblockcount = inv :get_stack (" micro" ,1 ):get_count ()
145145 meta :set_int (" anz" , microblockcount )
@@ -169,20 +169,19 @@ function circular_saw:update_inventory(pos, amount)
169169 local stack = inv :get_stack (" input" , 1 )
170170 local microstack = inv :get_stack (" micro" ,1 )
171171
172- -- At least one "normal" block is necessary to see what kind of stairs are requested.
172+ -- At least one (micro) block is necessary to see what kind of stairs are requested.
173173 if stack :is_empty () and microstack :is_empty () then
174- -- Any microblocks not taken out yet are now lost.
175- -- (covers material loss in the machine)
174+
176175 self :reset (pos )
177176 return
178177
179178 end
180179
181- local node_name = stack :get_name () or " " -- planned to extract from microblock TODO
180+ local node_name = circular_saw . microblocks [ microstack : get_name ()] or stack :get_name () or " "
182181 local node_def = stack :get_definition ()
183182 local name_parts = circular_saw .known_nodes [node_name ] or " "
184- local modname = name_parts [1 ] or circular_saw . microblocks [ microstack : get_name ()][ 1 ]
185- local material = name_parts [2 ] or circular_saw . microblocks [ microstack : get_name ()][ 2 ]
183+ local modname = name_parts [1 ]
184+ local material = name_parts [2 ]
186185 local owned_by = meta :get_string (" owner" )
187186
188187 if owned_by and owned_by ~= " " then
@@ -243,11 +242,11 @@ function circular_saw.allow_metadata_inventory_move(
243242end
244243
245244
246- -- Only input- and recycle-slot are intended as input slots:
245+ -- Only input- and recycle-slot (and microblock slot when empty) are intended as input slots:
247246function circular_saw .allow_metadata_inventory_put (
248247 pos , listname , index , stack , player )
249248 -- The player is not allowed to put something in there:
250- if listname == " output" or listname == " micro " then
249+ if listname == " output" then
251250 return 0
252251 end
253252
@@ -295,6 +294,16 @@ function circular_saw.allow_metadata_inventory_put(
295294 end
296295 return 0
297296 end
297+
298+ if listname == " micro" then
299+ if not (inv :is_empty (" input" ) and inv :is_empty (" micro" )) then return 0 end
300+ for name , t in pairs (circular_saw .microblocks ) do
301+ if name == stackname and inv :room_for_item (" input" , stack ) then
302+ return count
303+ end
304+ end
305+ return 0
306+ end
298307end
299308
300309-- Taking is allowed from all slots (even the internal microblock slot).
@@ -314,6 +323,8 @@ function circular_saw.on_metadata_inventory_put(
314323 if listname == " input" then
315324 -- Each new block is worth 8 microblocks:
316325 circular_saw :update_inventory (pos , 8 * count )
326+ elseif listname == " micro" then
327+ circular_saw :update_inventory (pos , count )
317328 elseif listname == " recycle" then
318329 -- Lets look which shape this represents:
319330 local cost = circular_saw :get_cost (inv , stackname )
0 commit comments