pontoons/init.lua

137 lines
4.5 KiB
Lua
Raw Normal View History

2020-04-10 06:29:59 +02:00
-- internationalization boilerplate
local S = minetest.get_translator("pontoons")
2020-04-11 07:39:38 +02:00
local default_modpath = core.get_modpath("default") and default
2020-04-10 06:29:59 +02:00
local mineclone_path = core.get_modpath("mcl_core") and mcl_core
2017-02-12 13:01:46 -07:00
2020-04-10 06:29:59 +02:00
-- compatibility layer
2018-10-11 16:57:56 +02:00
local moditems = {}
2020-04-10 06:29:59 +02:00
if mineclone_path then -- means MineClone 2 is loaded, this is its core mod
moditems.iron_item = "mcl_core:iron_ingot" -- MCL iron
moditems.sounds_wood = mcl_sounds.node_sound_wood_defaults
moditems.sounds_metal = mcl_sounds.node_sound_metal_defaults
2020-04-11 07:39:38 +02:00
moditems.wood_block_group = { pickaxey=1, axey=1, swordy=1, handy=1, flammable=1, destroy_by_lava_flow=1, dig_by_water=0 }
moditems.metal_block_group = { pickaxey=1, axey=1, swordy=1, handy=1, flammable=0, destroy_by_lava_flow=0, dig_by_water=0 }
elseif default_modpath then -- fallback, assume default (MineTest Game) is loaded, otherwise it will error anyway here.
2020-04-10 06:29:59 +02:00
moditems.iron_item = "default:steel_ingot" -- default iron
moditems.sounds_wood = default.node_sound_wood_defaults
moditems.sounds_metal = default.node_sound_metal_defaults
2020-04-11 07:39:38 +02:00
moditems.wood_block_group = { choppy=2, oddly_breakable_by_hand=2, flammable=2, wood=1}
moditems.metal_block_group = { cracky=1, level= 2}
end
2020-04-10 06:29:59 +02:00
-- load settings from minetest
2018-05-29 21:12:33 -06:00
local pontoons_override_logs = minetest.settings:get_bool("pontoons_override_logs") -- default false
2020-04-10 06:29:59 +02:00
if pontoons_override_logs == nil then pontoons_override_logs = false end
2017-02-12 13:01:46 -07:00
2018-05-29 21:12:33 -06:00
local pontoons_override_wood = minetest.settings:get_bool("pontoons_override_wood") -- default false
2020-04-10 06:29:59 +02:00
if pontoons_override_wood == nil then pontoons_override_wood = false end
2017-02-12 13:01:46 -07:00
2020-04-10 06:29:59 +02:00
local pontoons_wood_pontoons = minetest.settings:get_bool("pontoons_wood_pontoons") -- default true
if pontoons_wood_pontoons == nil then pontoons_wood_pontoons = true end
2017-02-12 13:01:46 -07:00
2020-04-10 06:29:59 +02:00
local pontoons_steel_pontoons = minetest.settings:get_bool("pontoons_steel_pontoons") -- default true
if pontoons_steel_pontoons == nil then pontoons_steel_pontoons = true end
2017-02-12 13:01:46 -07:00
if pontoons_override_logs or pontoons_override_wood then
local override_def = {liquids_pointable = true}
2017-02-12 13:01:46 -07:00
for node_name, node_def in pairs(minetest.registered_nodes) do
if pontoons_override_logs and minetest.get_item_group(node_name, "tree") > 0 then
minetest.override_item(node_name, override_def)
2017-02-12 13:01:46 -07:00
end
if pontoons_override_wood and minetest.get_item_group(node_name, "wood") > 0 then
minetest.override_item(node_name, override_def)
2017-02-12 13:01:46 -07:00
end
end
end
if pontoons_wood_pontoons then
2020-04-10 06:29:59 +02:00
local wood_burn_time = minetest.get_craft_result({method="fuel", width=1, items={ItemStack("group:wood")}}).time
2017-02-12 13:01:46 -07:00
if not wood_burn_time then wood_burn_time = 7 end
minetest.register_node("pontoons:wood_pontoon", {
description = S("Wood Pontoon"),
_doc_items_longdesc = S("A hollow wooden block designed to be built on the surface of liquids."),
tiles = {"pontoon_wood.png"},
paramtype2 = "facedir",
place_param2 = 0,
is_ground_content = false,
liquids_pointable = true,
2020-04-11 07:39:38 +02:00
groups = moditems.wood_block_group,
2020-04-10 06:29:59 +02:00
sounds = moditems.sounds_wood(),
2020-04-11 07:39:38 +02:00
_mcl_blast_resistance = 5,
_mcl_hardness = 0.5,
2017-02-12 13:01:46 -07:00
})
-- modify recipe, if "airtank" mod is loaded as it has similar recipe and conflicts with pontoons.
if core.get_modpath("airtanks") and airtanks then
minetest.register_craft({
output = 'pontoons:wood_pontoon 4',
recipe = {
{"group:wood","group:wood","group:wood"},
{"","",""},
{"","","group:wood"},
}
})
else
2017-02-12 13:01:46 -07:00
minetest.register_craft({
output = 'pontoons:wood_pontoon 4',
recipe = {
{"","group:wood",""},
{"group:wood","","group:wood"},
{"","group:wood",""},
}
})
end
2017-02-12 13:01:46 -07:00
minetest.register_craft({
type = "fuel",
recipe = "pontoons:wood_pontoon",
burntime = wood_burn_time,
})
end
if pontoons_steel_pontoons then
2020-04-10 06:29:59 +02:00
2017-02-12 13:01:46 -07:00
minetest.register_node("pontoons:steel_pontoon", {
description = S("Steel Pontoon"),
_doc_items_longdesc = S("A hollow steel block designed to be built on the surface of liquids. Magma-safe."),
is_ground_content = false,
tiles = {"pontoon_steel.png"},
liquids_pointable = true,
groups = moditems.metal_block_group,
sounds = moditems.sounds_metal(),
_mcl_blast_resistance = 30,
_mcl_hardness = 5,
2017-02-12 13:01:46 -07:00
})
2020-04-11 07:39:38 +02:00
if core.get_modpath("airtanks") and airtanks then
minetest.register_craft({
output = 'pontoons:steel_pontoon',
recipe = {
{"",moditems.iron_item,""},
{moditems.iron_item,"",moditems.iron_item},
{"","",moditems.iron_item},
}
})
else
minetest.register_craft({
output = 'pontoons:steel_pontoon',
recipe = {
{"",moditems.iron_item,""},
{moditems.iron_item,"",moditems.iron_item},
{"",moditems.iron_item,""},
}
})
2017-02-12 13:01:46 -07:00
end
2020-04-11 07:39:38 +02:00
2017-06-18 21:03:54 +02:00
end