forked from mrkubax10/industrialtest
Refactor item fluid storage
This commit is contained in:
parent
84ff508056
commit
63960f3de1
@ -802,23 +802,3 @@ industrialtest.api.registerCompressorRecipe({
|
|||||||
recipe="industrialtest:plantball",
|
recipe="industrialtest:plantball",
|
||||||
time=5
|
time=5
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("industrialtest:fuel_can",{
|
|
||||||
description=S("Fuel Can"),
|
|
||||||
inventory_image="industrialtest_fuel_can.png",
|
|
||||||
groups={
|
|
||||||
_industrialtest_fueled=1,
|
|
||||||
_industrialtest_fuel=1,
|
|
||||||
_industrialtest_fluidStorage=1
|
|
||||||
},
|
|
||||||
_industrialtest_fluidCapacity=10000
|
|
||||||
})
|
|
||||||
minetest.register_craft({
|
|
||||||
type="shaped",
|
|
||||||
output="industrialtest:fuel_can",
|
|
||||||
recipe={
|
|
||||||
{"","industrialtest:tin_plate","industrialtest:tin_plate"},
|
|
||||||
{"industrialtest:tin_plate","","industrialtest:tin_plate"},
|
|
||||||
{"industrialtest:tin_plate","industrialtest:tin_plate","industrialtest:tin_plate"}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
1
init.lua
1
init.lua
@ -78,6 +78,7 @@ dofile(modpath.."/tools/electric_chainsaw.lua")
|
|||||||
dofile(modpath.."/tools/electric_drill.lua")
|
dofile(modpath.."/tools/electric_drill.lua")
|
||||||
dofile(modpath.."/tools/electric_hoe.lua")
|
dofile(modpath.."/tools/electric_hoe.lua")
|
||||||
dofile(modpath.."/tools/electric_saber.lua")
|
dofile(modpath.."/tools/electric_saber.lua")
|
||||||
|
dofile(modpath.."/tools/fluid_storage.lua")
|
||||||
dofile(modpath.."/tools/jetpack.lua")
|
dofile(modpath.."/tools/jetpack.lua")
|
||||||
dofile(modpath.."/tools/mining_laser.lua")
|
dofile(modpath.."/tools/mining_laser.lua")
|
||||||
dofile(modpath.."/tools/nano_suit.lua")
|
dofile(modpath.."/tools/nano_suit.lua")
|
||||||
|
@ -188,7 +188,7 @@ function industrialtest.CanningMachine.shouldDeactivate(self,pos)
|
|||||||
return fuelSlot:is_empty() or targetSlot:is_empty() or meta:get_int("industrialtest.powerAmount")<self._opPower or
|
return fuelSlot:is_empty() or targetSlot:is_empty() or meta:get_int("industrialtest.powerAmount")<self._opPower or
|
||||||
(industrialtest.api.itemHasFluidStorage(fuelSlot) and industrialtest.api.isItemFluidStorageEmpty(fuelSlot)) or
|
(industrialtest.api.itemHasFluidStorage(fuelSlot) and industrialtest.api.isItemFluidStorageEmpty(fuelSlot)) or
|
||||||
industrialtest.api.isItemFluidStorageFull(targetSlot) or
|
industrialtest.api.isItemFluidStorageFull(targetSlot) or
|
||||||
targetMeta:get_int("industrialtest.fluidCapacity")-targetMeta:get_int("industrialtest.fluidAmount")<fuelDef._industrialtest_fuelAmount or
|
targetMeta:get_int("industrialtest.fluidCapacity")-targetMeta:get_int("industrialtest.fluidAmount")<(fuelDef._industrialtest_fuelAmount or 0) or
|
||||||
(fuelDef._industrialtest_emptyVariant and not leftoverSlot:item_fits(ItemStack(fuelDef._industrialtest_emptyVariant)))
|
(fuelDef._industrialtest_emptyVariant and not leftoverSlot:item_fits(ItemStack(fuelDef._industrialtest_emptyVariant)))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
45
tools/fluid_storage.lua
Normal file
45
tools/fluid_storage.lua
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
-- IndustrialTest
|
||||||
|
-- Copyright (C) 2025 mrkubax10
|
||||||
|
|
||||||
|
-- This program is free software: you can redistribute it and/or modify
|
||||||
|
-- it under the terms of the GNU General Public License as published by
|
||||||
|
-- the Free Software Foundation, either version 3 of the License, or
|
||||||
|
-- (at your option) any later version.
|
||||||
|
|
||||||
|
-- This program is distributed in the hope that it will be useful,
|
||||||
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
-- GNU General Public License for more details.
|
||||||
|
|
||||||
|
-- You should have received a copy of the GNU General Public License
|
||||||
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
local S=minetest.get_translator("industrialtest")
|
||||||
|
|
||||||
|
industrialtest.FuelCan=table.copy(industrialtest.FluidContainerItem)
|
||||||
|
industrialtest.internal.unpackTableInto(industrialtest.FuelCan,{
|
||||||
|
name="industrialtest:fuel_can",
|
||||||
|
description=S("Fuel Can"),
|
||||||
|
inventoryImage="industrialtest_fuel_can.png",
|
||||||
|
capacity=10000
|
||||||
|
})
|
||||||
|
|
||||||
|
function industrialtest.FuelCan.createDefinitionTable(self)
|
||||||
|
local def=industrialtest.FluidContainerItem.createDefinitionTable(self)
|
||||||
|
def.groups._industrialtest_fueled=1
|
||||||
|
def.groups._industrialtest_fuel=1
|
||||||
|
return def
|
||||||
|
end
|
||||||
|
|
||||||
|
industrialtest.FuelCan:register()
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
type="shaped",
|
||||||
|
output="industrialtest:fuel_can",
|
||||||
|
recipe={
|
||||||
|
{"","industrialtest:tin_plate","industrialtest:tin_plate"},
|
||||||
|
{"industrialtest:tin_plate","","industrialtest:tin_plate"},
|
||||||
|
{"industrialtest:tin_plate","industrialtest:tin_plate","industrialtest:tin_plate"}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user