Introduce compatibility with mcl_rubber mod

Closes #1
This commit is contained in:
mrkubax10 2024-02-26 17:06:11 +01:00
parent 7df191097d
commit d2346f65aa
7 changed files with 334 additions and 309 deletions

View File

@ -160,16 +160,16 @@ minetest.register_craft({
output="industrialtest:insulated_tin_cable",
recipe={
"industrialtest:tin_cable",
"industrialtest:rubber"
industrialtest.elementKeys.rubber
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:insulated_tin_cable 6",
recipe={
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"},
{industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber},
{industrialtest.elementKeys.tinIngot,industrialtest.elementKeys.tinIngot,industrialtest.elementKeys.tinIngot},
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"}
{industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber}
}
})
industrialtest.api.registerCableFormerRecipe({
@ -191,16 +191,16 @@ minetest.register_craft({
output="industrialtest:insulated_copper_cable",
recipe={
"industrialtest:copper_cable",
"industrialtest:rubber"
industrialtest.elementKeys.rubber
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:insulated_copper_cable 6",
recipe={
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"},
{industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber},
{industrialtest.elementKeys.copperIngot,industrialtest.elementKeys.copperIngot,industrialtest.elementKeys.copperIngot},
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"}
{industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber}
}
})
industrialtest.api.registerCableFormerRecipe({
@ -221,16 +221,16 @@ minetest.register_craft({
output="industrialtest:insulated_gold_cable",
recipe={
"industrialtest:gold_cable",
"industrialtest:rubber"
industrialtest.elementKeys.rubber
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:insulated_gold_cable 6",
recipe={
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"},
{industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber},
{industrialtest.elementKeys.goldIngot,industrialtest.elementKeys.goldIngot,industrialtest.elementKeys.goldIngot},
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"}
{industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber}
}
})
industrialtest.api.registerCableFormerRecipe({
@ -251,16 +251,16 @@ minetest.register_craft({
output="industrialtest:insulated_iron_cable",
recipe={
"industrialtest:iron_cable",
"industrialtest:rubber"
industrialtest.elementKeys.rubber
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:insulated_iron_cable 6",
recipe={
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"},
{industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber},
{"industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot"},
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"}
{industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber}
}
})
industrialtest.api.registerCableFormerRecipe({

View File

@ -33,7 +33,14 @@ for _,mod in ipairs(requiredMclModules) do
end
end
if industrialtest.mtgAvailable and not minetest.get_modpath("3d_armor") then
industrialtest.mods={}
if industrialtest.mtgAvailable then
industrialtest.mods._3dArmor=minetest.get_modpath("3d_armor")
elseif industrialtest.mclAvailable then
industrialtest.mods.mclRubber=minetest.get_modpath("mcl_rubber")
end
if industrialtest.mtgAvailable and not industrialtest then
error("IndustrialTest requires 3D Armor when used with Minetest Game")
end
@ -552,6 +559,11 @@ if industrialtest.mclAvailable then
industrialtest.elementKeys.cactus="mcl_core:cactus"
industrialtest.elementKeys.groupSapling="group:sapling"
industrialtest.elementKeys.groupLeaves="group:leaves"
industrialtest.elementKeys.stickyResin=(industrialtest.mods.mclRubber and "mcl_rubber:rubber_raw" or "industrialtest:sticky_resin")
industrialtest.elementKeys.rubber=(industrialtest.mods.mclRubber and "mcl_rubber:rubber" or "industrialtest:rubber")
industrialtest.elementKeys.rubberWood=(industrialtest.mods.mclRubber and "mcl_rubber:rubbertree" or "industrialtest:rubber_wood")
industrialtest.elementKeys.rubberSapling=(industrialtest.mods.mclRubber and "mcl_rubber:rubbersapling" or "industrialtest:rubber_sapling")
industrialtest.elementKeys.treetap=(industrialtest.mods.mclRubber and "mcl_rubber:treetap" or "industrialtest:treetap")
-- register required minerals that are not available in MCL
industrialtest.registerMetal("tin","Tin",3,3)
@ -781,6 +793,11 @@ elseif industrialtest.mtgAvailable then
industrialtest.elementKeys.cactus="default:cactus"
industrialtest.elementKeys.groupSapling="group:sapling"
industrialtest.elementKeys.groupLeaves="group:leaves"
industrialtest.elementKeys.stickyResin="industrialtest:sticky_resin"
industrialtest.elementKeys.rubber="industrialtest:rubber"
industrialtest.elementKeys.rubberWood="industrialtest:rubber_wood"
industrialtest.elementKeys.rubberSapling="industrialtest:rubber_sapling"
industrialtest.elementKeys.treetap="industrialtest:treetap"
else
error("No compatible games found!")
end

View File

@ -117,31 +117,33 @@ minetest.register_craft({
}
})
minetest.register_craftitem("industrialtest:sticky_resin",{
if not industrialtest.mods.mclRubber then
minetest.register_craftitem("industrialtest:sticky_resin",{
description=S("Sticky Resin"),
inventory_image="industrialtest_sticky_resin.png"
})
})
minetest.register_craftitem("industrialtest:rubber",{
minetest.register_craftitem("industrialtest:rubber",{
description=S("Rubber"),
inventory_image="industrialtest_rubber.png"
})
minetest.register_craft({
})
minetest.register_craft({
type="cooking",
output="industrialtest:rubber",
recipe="industrialtest:sticky_resin"
})
end
industrialtest.api.registerExtractorRecipe({
output=industrialtest.elementKeys.rubber,
recipe=industrialtest.elementKeys.rubberWood
})
industrialtest.api.registerExtractorRecipe({
output="industrialtest:rubber",
recipe="industrialtest:rubber_wood"
output=industrialtest.elementKeys.rubber,
recipe=industrialtest.elementKeys.rubberSapling
})
industrialtest.api.registerExtractorRecipe({
output="industrialtest:rubber",
recipe="industrialtest:rubber_sapling"
})
industrialtest.api.registerExtractorRecipe({
output="industrialtest:rubber 3",
recipe="industrialtest:sticky_resin"
output=industrialtest.elementKeys.rubber.." 3",
recipe=industrialtest.elementKeys.stickyResin
})
minetest.register_craftitem("industrialtest:raw_carbon_fibre",{

View File

@ -31,7 +31,7 @@ minetest.register_craft({
type="shaped",
output="industrialtest:extractor",
recipe={
{"industrialtest:treetap","industrialtest:machine_block","industrialtest:treetap"},
{"industrialtest:treetap","industrialtest:electronic_circuit","industrialtest:treetap"}
{industrialtest.elementKeys.treetap,"industrialtest:machine_block",industrialtest.elementKeys.treetap},
{industrialtest.elementKeys.treetap,"industrialtest:electronic_circuit",industrialtest.elementKeys.treetap}
}
})

View File

@ -15,7 +15,7 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
minetest.register_on_generated(function(minp,maxp,seed)
if industrialtest.random:next(1,100)>40 then
if industrialtest.mods.mclRubber or industrialtest.random:next(1,100)>40 then
return
end
local center=vector.new((maxp.x-minp.x)/2+ minp.x,(maxp.y-minp.y)/2+minp.y,(maxp.z-minp.z)/2+minp.z)

View File

@ -66,7 +66,8 @@ minetest.register_craft({
}
})
definition={
if not industrialtest.mods.mclRubber then
definition={
description=S("Rubber Wood"),
tiles={
"industrialtest_rubber_wood_top.png",
@ -74,8 +75,8 @@ definition={
"industrialtest_rubber_wood_side.png"
},
paramtype2="4dir"
}
if industrialtest.mtgAvailable then
}
if industrialtest.mtgAvailable then
definition.sounds=default.node_sound_wood_defaults()
definition.groups={
tree=1,
@ -83,7 +84,7 @@ if industrialtest.mtgAvailable then
oddly_breakable_by_hand=1,
flammable=2
}
elseif industrialtest.mclAvailable then
elseif industrialtest.mclAvailable then
definition.sounds=mcl_sounds.node_sound_wood_defaults()
definition.groups={
handy=1,
@ -98,26 +99,26 @@ elseif industrialtest.mclAvailable then
definition.after_destruct=mcl_core.update_leaves
definition._mcl_blast_resistance=1.8
definition._mcl_hardness=1.8
end
definition.groups._industrialtest_rubberWood=1
minetest.register_node("industrialtest:rubber_wood",definition)
definition=table.copy(definition)
definition.description=nil
definition.tiles={
end
definition.groups._industrialtest_rubberWood=1
minetest.register_node("industrialtest:rubber_wood",definition)
definition=table.copy(definition)
definition.description=nil
definition.tiles={
"industrialtest_rubber_wood_top.png",
"industrialtest_rubber_wood_top.png",
"industrialtest_rubber_wood_side.png",
"industrialtest_rubber_wood_side.png",
"industrialtest_rubber_wood_side_with_rubber.png",
"industrialtest_rubber_wood_side.png"
}
definition.drop="industrialtest:rubber_wood"
if industrialtest.mclAvailable then
}
definition.drop="industrialtest:rubber_wood"
if industrialtest.mclAvailable then
definition.groups.not_in_creative_inventory=1
definition._doc_items_create_entry=false
end
minetest.register_node("industrialtest:rubber_wood_with_rubber",definition)
minetest.register_abm({
end
minetest.register_node("industrialtest:rubber_wood_with_rubber",definition)
minetest.register_abm({
label="Rubber forming",
nodenames={"industrialtest:rubber_wood"},
interval=120,
@ -141,13 +142,13 @@ minetest.register_abm({
param2=industrialtest.random:next(0,3)
})
end
})
minetest.register_craft({
})
minetest.register_craft({
type="shapeless",
output=industrialtest.elementKeys.junglePlanks.." 3",
recipe={"group:_industrialtest_rubberWood"}
})
definition={
})
definition={
description=S("Rubber Leaves"),
drawtype="allfaces_optional",
tiles={"industrialtest_rubber_leaves.png"},
@ -155,8 +156,8 @@ definition={
paramtype="light",
sunlight_propagates=true,
waving=1
}
if industrialtest.mtgAvailable then
}
if industrialtest.mtgAvailable then
definition.sounds=default.node_sound_leaves_defaults()
definition.groups={
snappy=3,
@ -175,7 +176,7 @@ if industrialtest.mtgAvailable then
}
}
definition.after_place_node=default.after_place_leaves
elseif industrialtest.mclAvailable then
elseif industrialtest.mclAvailable then
local saplingChances={20,16,12,10}
local stickChances={50,45,30,35,10}
-- Taken and adapted from https://git.minetest.land/MineClone2/MineClone2/src/branch/master/mods/ITEMS/mcl_core/nodes_trees.lua#L157
@ -220,16 +221,16 @@ elseif industrialtest.mclAvailable then
definition._mcl_hardness=0.2
definition._mcl_silk_touch_drop=true
definition._mcl_fortune_drop={getDrops(1),getDrops(2),getDrops(3),getDrops(4)}
end
minetest.register_node("industrialtest:rubber_leaves",definition)
if industrialtest.mtgAvailable then
end
minetest.register_node("industrialtest:rubber_leaves",definition)
if industrialtest.mtgAvailable then
default.register_leafdecay({
trunks={"industrialtest:rubber_wood"},
leaves={"industrialtest:rubber_leaves"},
radius=2
})
end
if industrialtest.mclAvailable then
end
if industrialtest.mclAvailable then
definition=table.copy(definition)
definition._doc_items_create_entry=false
definition.groups.not_in_creative_inventory=1
@ -237,8 +238,8 @@ if industrialtest.mclAvailable then
definition._mcl_shears_drop={"industrialtest:rubber_leaves"}
definition._mcl_silk_touch_drop={"industrialtest:rubber_leaves"}
minetest.register_node("industrialtest:rubber_leaves_orphan",definition)
end
industrialtest.makeRubberTree=function(pos)
end
industrialtest.makeRubberTree=function(pos)
-- FIXME: Replace this with placing schematic
-- Taken and adapted from https://github.com/minetest/minetest_game/blob/master/mods/default/trees.lua#L182
local height=industrialtest.random:next(4,5)
@ -297,8 +298,8 @@ industrialtest.makeRubberTree=function(pos)
manip:set_data(data)
manip:write_to_map()
manip:update_map()
end
definition={
end
definition={
description=S("Rubber Sapling"),
inventory_image="industrialtest_rubber_sapling.png",
wield_image="industrialtest_rubber_sapling.png",
@ -333,8 +334,8 @@ definition={
return false
end
}
if industrialtest.mtgAvailable then
}
if industrialtest.mtgAvailable then
definition.sounds=default.node_sound_leaves_defaults()
definition.groups={
snappy=2,
@ -343,7 +344,7 @@ if industrialtest.mtgAvailable then
definition.on_construct=function(pos)
minetest.get_node_timer(pos):start(industrialtest.random:next(300,1500))
end
elseif industrialtest.mclAvailable then
elseif industrialtest.mclAvailable then
definition.sounds=mcl_sounds.node_sound_leaves_defaults()
definition.groups={
plant=1,
@ -358,12 +359,12 @@ elseif industrialtest.mclAvailable then
local meta=minetest.get_meta(pos)
meta:set_int("stage",0)
end
end
definition.groups.attached_node=1
definition.groups.dig_immediate=3
definition.groups.sapling=1
minetest.register_node("industrialtest:rubber_sapling",definition)
if industrialtest.mtgAvailable then
end
definition.groups.attached_node=1
definition.groups.dig_immediate=3
definition.groups.sapling=1
minetest.register_node("industrialtest:rubber_sapling",definition)
if industrialtest.mtgAvailable then
minetest.register_lbm({
name="industrialtest:rubber_sapling_lbm",
nodenames={"industrialtest:rubber_sapling"},
@ -371,4 +372,5 @@ if industrialtest.mtgAvailable then
minetest.get_node_timer(pos):start(industrialtest.random:next(300,1500))
end
})
end
end

View File

@ -14,6 +14,10 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
if industrialtest.mods.mclRubber then
return
end
local S=minetest.get_translator("industrialtest")
local function onTreetapUse(user,pointed)