mirror of
https://github.com/minetest-mods/pontoons.git
synced 2025-04-30 13:21:40 -04:00
Improve mcl2 compatibility code
This commit is contained in:
parent
04faa1a1b7
commit
39c0cef782
1 changed files with 27 additions and 40 deletions
65
init.lua
65
init.lua
|
@ -1,26 +1,33 @@
|
||||||
|
-- internationalization boilerplate
|
||||||
local S = minetest.get_translator("pontoons")
|
local S = minetest.get_translator("pontoons")
|
||||||
|
local default_modpath = minetest.get_modpath("default")
|
||||||
|
local mineclone_path = core.get_modpath("mcl_core") and mcl_core
|
||||||
|
|
||||||
-- MCL2 compatibility
|
-- compatibility layer
|
||||||
local moditems = {}
|
local moditems = {}
|
||||||
|
|
||||||
if core.get_modpath("mcl_core") and mcl_core then -- means MineClone 2 is loaded, this is its core mod
|
if mineclone_path then -- means MineClone 2 is loaded, this is its core mod
|
||||||
moditems.IRON_ITEM = "mcl_core:iron_ingot" -- MCL iron
|
moditems.iron_item = "mcl_core:iron_ingot" -- MCL iron
|
||||||
|
moditems.sounds_wood = mcl_sounds.node_sound_wood_defaults
|
||||||
else -- fallback, assume default (MineTest Game) is loaded, otherwise it will error anyway here.
|
else -- fallback, assume default (MineTest Game) is loaded, otherwise it will error anyway here.
|
||||||
moditems.IRON_ITEM = "default:steel_ingot" -- MCL iron
|
moditems.iron_item = "default:steel_ingot" -- default iron
|
||||||
|
moditems.sounds_wood = default.node_sound_wood_defaults
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- load settings from minetest
|
||||||
|
|
||||||
local pontoons_override_logs = minetest.settings:get_bool("pontoons_override_logs") -- default false
|
local pontoons_override_logs = minetest.settings:get_bool("pontoons_override_logs") -- default false
|
||||||
|
if pontoons_override_logs == nil then pontoons_override_logs = false end
|
||||||
|
|
||||||
local pontoons_override_wood = minetest.settings:get_bool("pontoons_override_wood") -- default false
|
local pontoons_override_wood = minetest.settings:get_bool("pontoons_override_wood") -- default false
|
||||||
|
if pontoons_override_wood == nil then pontoons_override_wood = false end
|
||||||
|
|
||||||
local pontoons_wood_pontoons = minetest.settings:get_bool("pontoons_wood_pontoons")
|
local pontoons_wood_pontoons = minetest.settings:get_bool("pontoons_wood_pontoons") -- default true
|
||||||
if pontoons_wood_pontoons == nil then pontoons_wood_pontoons = true end -- default true
|
if pontoons_wood_pontoons == nil then pontoons_wood_pontoons = true end
|
||||||
|
|
||||||
local pontoons_steel_pontoons = minetest.settings:get_bool("pontoons_steel_pontoons")
|
local pontoons_steel_pontoons = minetest.settings:get_bool("pontoons_steel_pontoons") -- default true
|
||||||
if pontoons_steel_pontoons == nil then pontoons_steel_pontoons = true end -- default true
|
if pontoons_steel_pontoons == nil then pontoons_steel_pontoons = true end
|
||||||
|
|
||||||
local default_modpath = minetest.get_modpath("default")
|
|
||||||
|
|
||||||
if pontoons_override_logs or pontoons_override_wood then
|
if pontoons_override_logs or pontoons_override_wood then
|
||||||
local override_def = {liquids_pointable = true}
|
local override_def = {liquids_pointable = true}
|
||||||
|
@ -36,16 +43,8 @@ if pontoons_override_logs or pontoons_override_wood then
|
||||||
end
|
end
|
||||||
|
|
||||||
if pontoons_wood_pontoons then
|
if pontoons_wood_pontoons then
|
||||||
local default_sound
|
local wood_burn_time = minetest.get_craft_result({method="fuel", width=1, items={ItemStack("group:wood")}}).time
|
||||||
local wood_burn_time
|
|
||||||
if default_modpath then
|
|
||||||
if mcl_sounds then
|
|
||||||
default_sound = mcl_sounds.node_sound_wood_defaults()
|
|
||||||
else
|
|
||||||
default_sound = default.node_sound_wood_defaults()
|
|
||||||
end
|
|
||||||
wood_burn_time = minetest.get_craft_result({method="fuel", width=1, items={ItemStack("group:wood")}}).time
|
|
||||||
end
|
|
||||||
if not wood_burn_time then wood_burn_time = 7 end
|
if not wood_burn_time then wood_burn_time = 7 end
|
||||||
|
|
||||||
minetest.register_node("pontoons:wood_pontoon", {
|
minetest.register_node("pontoons:wood_pontoon", {
|
||||||
|
@ -57,7 +56,7 @@ if pontoons_wood_pontoons then
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
liquids_pointable = true,
|
liquids_pointable = true,
|
||||||
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1},
|
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1},
|
||||||
sounds = default_sound,
|
sounds = moditems.sounds_wood(),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- modify recipe, if "airtank" mod is loaded as it has similar recipe and conflicts with pontoons.
|
-- modify recipe, if "airtank" mod is loaded as it has similar recipe and conflicts with pontoons.
|
||||||
|
@ -91,18 +90,6 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
if pontoons_steel_pontoons then
|
if pontoons_steel_pontoons then
|
||||||
local default_sound
|
|
||||||
if default_modpath then
|
|
||||||
if mcl_sounds then
|
|
||||||
default_sound = mcl_sounds.node_sound_metal_defaults()
|
|
||||||
else
|
|
||||||
if default.node_sound_metal_defaults then
|
|
||||||
default_sound = default.node_sound_metal_defaults()
|
|
||||||
else
|
|
||||||
default_sound = default.node_sound_wood_defaults()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node("pontoons:steel_pontoon", {
|
minetest.register_node("pontoons:steel_pontoon", {
|
||||||
description = S("Steel Pontoon"),
|
description = S("Steel Pontoon"),
|
||||||
|
@ -112,7 +99,7 @@ if pontoons_steel_pontoons then
|
||||||
liquids_pointable = true,
|
liquids_pointable = true,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {cracky = 1, level = 2},
|
groups = {cracky = 1, level = 2},
|
||||||
sounds = default_sound,
|
sounds = moditems.sounds_wood(),
|
||||||
})
|
})
|
||||||
|
|
||||||
if default_modpath then
|
if default_modpath then
|
||||||
|
@ -120,18 +107,18 @@ if pontoons_steel_pontoons then
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'pontoons:steel_pontoon',
|
output = 'pontoons:steel_pontoon',
|
||||||
recipe = {
|
recipe = {
|
||||||
{"",moditems.IRON_ITEM,""},
|
{"",moditems.iron_item,""},
|
||||||
{moditems.IRON_ITEM,"",moditems.IRON_ITEM},
|
{moditems.iron_item,"",moditems.iron_item},
|
||||||
{"","",moditems.IRON_ITEM},
|
{"","",moditems.iron_item},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'pontoons:steel_pontoon',
|
output = 'pontoons:steel_pontoon',
|
||||||
recipe = {
|
recipe = {
|
||||||
{"",moditems.IRON_ITEM,""},
|
{"",moditems.iron_item,""},
|
||||||
{moditems.IRON_ITEM,"",moditems.IRON_ITEM},
|
{moditems.iron_item,"",moditems.iron_item},
|
||||||
{"",moditems.IRON_ITEM,""},
|
{"",moditems.iron_item,""},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue