Some fixes in Machine and ActivatedMachine
This commit is contained in:
parent
442d3a42b1
commit
d799b10242
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user