Implement few fluid related registration functions
This commit is contained in:
parent
17a9cab691
commit
d13d2b9dfd
@ -22,6 +22,9 @@ industrialtest.api={
|
|||||||
geothermalGeneratorFuels={},
|
geothermalGeneratorFuels={},
|
||||||
waterMillFuels={},
|
waterMillFuels={},
|
||||||
rotaryMaceratorModifiers={},
|
rotaryMaceratorModifiers={},
|
||||||
|
pumpTargets={},
|
||||||
|
pumpFluids={},
|
||||||
|
compressedFluids={},
|
||||||
storageCells={},
|
storageCells={},
|
||||||
tags={}
|
tags={}
|
||||||
}
|
}
|
||||||
@ -32,6 +35,8 @@ industrialtest.api.hvPowerFlow=10200
|
|||||||
industrialtest.api.evPowerFlow=40800
|
industrialtest.api.evPowerFlow=40800
|
||||||
industrialtest.api.ivPowerFlow=163800
|
industrialtest.api.ivPowerFlow=163800
|
||||||
|
|
||||||
|
industrialtest.api.nodeFluidCapacity=1000
|
||||||
|
|
||||||
function industrialtest.internal.clamp(num,min,max)
|
function industrialtest.internal.clamp(num,min,max)
|
||||||
return math.max(math.min(num,max),min)
|
return math.max(math.min(num,max),min)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -25,6 +25,16 @@ local function createItemFluidStorageText(itemstack)
|
|||||||
return minetest.colorize(color,S("@1 / @2 mB",fluidAmount,fluidCapacity))
|
return minetest.colorize(color,S("@1 / @2 mB",fluidAmount,fluidCapacity))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- \brief Adds fluid storage to node metadata
|
||||||
|
-- \param meta MetaDataRef
|
||||||
|
-- \param capacity number
|
||||||
|
-- \returns nil
|
||||||
|
function industrialtest.api.addFluidStorage(meta,capacity)
|
||||||
|
meta:set_int("industrialtest.fluidCapacity",capacity)
|
||||||
|
meta:set_int("industrialtest.fluidAmount",0)
|
||||||
|
meta:set_string("industrialtest.fluidType","ignore")
|
||||||
|
end
|
||||||
|
|
||||||
-- \brief Check if itemstack contains fluid storage
|
-- \brief Check if itemstack contains fluid storage
|
||||||
-- \param itemstack ItemStack
|
-- \param itemstack ItemStack
|
||||||
-- \returns bool
|
-- \returns bool
|
||||||
|
|||||||
@ -307,6 +307,65 @@ function industrialtest.api.getRotaryMaceratorModifier(name,modifier)
|
|||||||
return industrialtest.api.rotaryMaceratorModifiers[name.." "..modifier]
|
return industrialtest.api.rotaryMaceratorModifiers[name.." "..modifier]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- \brief Registers target node with which Pump can interact
|
||||||
|
-- \param name string
|
||||||
|
-- \param fluidNodes table
|
||||||
|
-- \param direction string
|
||||||
|
-- \return nil
|
||||||
|
function industrialtest.api.registerPumpTarget(name,direction)
|
||||||
|
industrialtest.api.pumpTargets[name]={
|
||||||
|
name=name,
|
||||||
|
direction=direction
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- \brief Returns Pump target info
|
||||||
|
-- \param name string
|
||||||
|
-- \returns table
|
||||||
|
function industrialtest.api.getPumpTarget(name)
|
||||||
|
return industrialtest.api.pumpTargets[name]
|
||||||
|
end
|
||||||
|
|
||||||
|
-- \brief Registers fluid node which can be pumped by pump
|
||||||
|
-- \param name string
|
||||||
|
-- \param texture string
|
||||||
|
-- \returns nil
|
||||||
|
function industrialtest.api.registerPumpFluid(name,texture)
|
||||||
|
industrialtest.api.pumpFluids[name]={
|
||||||
|
name=name,
|
||||||
|
texture=texture
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- \brief Returns registered node which can be pumped by pump
|
||||||
|
-- \param name string
|
||||||
|
-- \returns table
|
||||||
|
function industrialtest.api.getPumpFluid(name)
|
||||||
|
return industrialtest.api.pumpFluids[name]
|
||||||
|
end
|
||||||
|
|
||||||
|
-- \brief Registers fluid which can be pumped into compressor resulting with different item
|
||||||
|
-- \param fluidType string
|
||||||
|
-- \param requiredAmount number
|
||||||
|
-- \param time number
|
||||||
|
-- \param result string
|
||||||
|
-- \returns nil
|
||||||
|
function industrialtest.api.registerCompressedFluid(fluidType,requiredAmount,time,result)
|
||||||
|
industrialtest.api.compressedFluids[fluidType]={
|
||||||
|
fluidType=fluidType,
|
||||||
|
requiredAmount=requiredAmount,
|
||||||
|
time=time,
|
||||||
|
result=result
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- \brief Returns information about fluid which can be pumped into compressor resulting with different item
|
||||||
|
-- \param fluidType string
|
||||||
|
-- \returns table
|
||||||
|
function industrialtest.api.getCompressedFluid(fluidType)
|
||||||
|
return industrialtest.api.compressedFluids[fluidType]
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_on_mods_loaded(function()
|
minetest.register_on_mods_loaded(function()
|
||||||
for _,def in pairs(industrialtest.api.rotaryMaceratorModifiers) do
|
for _,def in pairs(industrialtest.api.rotaryMaceratorModifiers) do
|
||||||
if def.stackLeftover then
|
if def.stackLeftover then
|
||||||
|
|||||||
@ -533,6 +533,9 @@ minetest.register_craftitem("industrialtest:empty_cell",{
|
|||||||
description=S("Empty Cell"),
|
description=S("Empty Cell"),
|
||||||
inventory_image="industrialtest_empty_cell.png",
|
inventory_image="industrialtest_empty_cell.png",
|
||||||
liquids_pointable=true,
|
liquids_pointable=true,
|
||||||
|
groups={
|
||||||
|
_industrialtest_simpleFluidStorage=1
|
||||||
|
},
|
||||||
on_place=function(itemstack,user,pointed)
|
on_place=function(itemstack,user,pointed)
|
||||||
if pointed.type~="node" or not user or not user:is_player() then
|
if pointed.type~="node" or not user or not user:is_player() then
|
||||||
return nil
|
return nil
|
||||||
@ -554,7 +557,9 @@ minetest.register_craftitem("industrialtest:empty_cell",{
|
|||||||
end
|
end
|
||||||
minetest.remove_node(pointed.under)
|
minetest.remove_node(pointed.under)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end,
|
||||||
|
_industrialtest_getResultingFluidStorageItemByNode=industrialtest.api.getStorageCellByNode,
|
||||||
|
_industrialtest_simpleFluidStorageCapacity=1000
|
||||||
})
|
})
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type="shaped",
|
type="shaped",
|
||||||
|
|||||||
@ -125,3 +125,12 @@ if industrialtest.mtgAvailable then
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Pumped fluids
|
||||||
|
if industrialtest.mtgAvailable then
|
||||||
|
industrialtest.api.registerPumpFluid("default:river_water_source","industrialtest_gui_river_water.png")
|
||||||
|
industrialtest.api.registerCompressedFluid("default:river_water_source",industrialtest.api.nodeFluidCapacity/2,5,"default:snow")
|
||||||
|
end
|
||||||
|
industrialtest.api.registerPumpFluid(industrialtest.elementKeys.waterSource,"industrialtest_gui_water.png")
|
||||||
|
industrialtest.api.registerPumpFluid(industrialtest.elementKeys.lavaSource,"industrialtest_gui_lava.png")
|
||||||
|
industrialtest.api.registerCompressedFluid(industrialtest.elementKeys.waterSource,industrialtest.api.nodeFluidCapacity/2,5,industrialtest.elementKeys.snowball)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user