Extract side API functions to separate file

This commit is contained in:
2024-09-08 22:31:26 +02:00
parent 9436c7033b
commit cb41e76742
3 changed files with 50 additions and 32 deletions

32
api.lua
View File

@@ -16,32 +16,6 @@
local S=minetest.get_translator("industrialtest")
-- \brief Takes rotated node and side and outputs normalized side that can be used for ioConfig lookups
-- \param pos Vector with node position
-- \param side Node side. See industrialtest.api.addPowerStorage for possible values
-- \returns Normalized side or in case of failure side argument back
industrialtest.api.normalizeSide=function(pos,side)
local node=minetest.get_node(pos)
-- FIXME: improve code quality there
local translation={
[0]={
1,2,3,4,5,6
},
[1]={
5,6,3,4,2,1
},
[2]={
2,1,3,4,6,5
},
[3]={
6,5,3,4,1,2
}
}
if node.param2>3 then
return side
end
return translation[node.param2][side]
end
-- \brief Sets uses metadata value depending on item's definition
-- \param itemstack ItemStack which should be altered
-- \returns true if value was successfully added, false otherwise
@@ -430,12 +404,6 @@ industrialtest.api.getNetwork=function(meta)
return minetest.deserialize(meta:get_string("industrialtest.network"))
end
-- \brief Returns opposite side of provided one
-- \param side Side number. See industrialtest.api.addPowerStorage for order
-- \returns Opposite side
industrialtest.api.getOppositeSide=function(side)
return (side%2==0 and side-1 or side+1)
end
-- \brief Returns connections of node with power storage. If direction is "i" only input connections will be returned, if direction is "o" only output connections
-- will be returned, if it's not provided all connections will be returned.
-- \param pos Vector