diff --git a/machines/activated_machine.lua b/machines/activated_machine.lua index dff2841..f6c5553 100644 --- a/machines/activated_machine.lua +++ b/machines/activated_machine.lua @@ -43,13 +43,21 @@ function industrialtest.ActivatedMachine.createActiveDefinitionTable(self) local def=self:createDefinitionTable() def.description=nil def.drop=def.drop or self.name + + if self.active then + def.tiles=self.active.tiles or def.tiles + def.light_source=self.active.lightSource + end + def.on_timer=function(pos,elapsed) return self:activeOnTimer(pos,elapsed) end + if industrialtest.mclAvailable then def.groups.not_in_creative_inventory=1 def._doc_items_create_entry=false end + return def end diff --git a/machines/machine.lua b/machines/machine.lua index 00a39e8..b28ddb4 100644 --- a/machines/machine.lua +++ b/machines/machine.lua @@ -17,6 +17,7 @@ industrialtest.Machine={} function industrialtest.Machine.onConstruct(self,pos) + local meta=minetest.get_meta(pos) meta:set_string("formspec",self:getFormspec(pos)) minetest.get_node_timer(pos):start(industrialtest.updateDelay) end @@ -96,9 +97,42 @@ function industrialtest.Machine.allowMetadataInventoryPut(self,pos,listname,inde return stack:get_count() end +function industrialtest.Machine.allowMetadataInventoryTake(self,pos,listname,index,stack,player) + return stack:get_count() +end + +function industrialtest.Machine.onMetadataInventoryMove(self,pos,fromList,fromIndex,toList,toIndex,count) + if toList=="upgrades" then + local meta=minetest.get_meta(pos) + local inv=meta:get_inventory() + local stack=inv:get_stack(fromList,fromIndex) + industrialtest.internal.applyUpgrade(pos,meta,stack) + elseif fromList=="upgrades" then + local meta=minetest.get_meta(pos) + local inv=meta:get_inventory() + local stack=inv:get_stack(fromList,fromIndex) + industrialtest.internal.removeUpgrade(pos,meta,stack) + end +end + +function industrialtest.Machine.onMetadataInventoryPut(self,pos,listname,index,stack) + if listname=="upgrades" then + local meta=minetest.get_meta(pos) + industrialtest.internal.applyUpgrade(pos,meta,stack) + end +end + +function industrialtest.Machine.onMetadataInventoryTake(self,pos,listname,index,stack) + if listname=="upgrades" then + local meta=minetest.get_meta(pos) + industrialtest.internal.removeUpgrade(pos,meta,stack) + end +end + function industrialtest.Machine.createDefinitionTable(self) local def={ description=self.description, + tiles=self.tiles, on_construct=function(pos) self:onConstruct(pos) end, @@ -181,6 +215,11 @@ function industrialtest.Machine.createDefinitionTable(self) def.drop="industrialtest:machine_block" end + if self.facedir then + def.paramtype2="facedir" + def.legacy_facedir_simple=true + end + return def end @@ -190,34 +229,6 @@ function industrialtest.Machine.register(self) industrialtest.api.addTag(self.name,"usesTimer") end -function industrialtest.Machine.onMetadataInventoryMove(pos,fromList,fromIndex,toList,toIndex,count) - if toList=="upgrades" then - local meta=minetest.get_meta(pos) - local inv=meta:get_inventory() - local stack=inv:get_stack(fromList,fromIndex) - industrialtest.internal.applyUpgrade(pos,meta,stack) - elseif fromList=="upgrades" then - local meta=minetest.get_meta(pos) - local inv=meta:get_inventory() - local stack=inv:get_stack(fromList,fromIndex) - industrialtest.internal.removeUpgrade(pos,meta,stack) - end -end - -function industrialtest.Machine.onMetadataInventoryPut(pos,listname,index,stack) - if listname=="upgrades" then - local meta=minetest.get_meta(pos) - industrialtest.internal.applyUpgrade(pos,meta,stack) - end -end - -function industrialtest.Machine.onMetadataInventoryTake(pos,listname,index,stack) - if listname=="upgrades" then - local meta=minetest.get_meta(pos) - industrialtest.internal.removeUpgrade(pos,meta,stack) - end -end - function industrialtest.Machine.allowMoveToUpgradeSlot(pos,toIndex,stack) local def=minetest.registered_items[stack:get_name()] if not def or not def.groups or not def.groups._industrialtest_machineUpgrade then