mirror of
https://github.com/minetest-mods/nether.git
synced 2024-12-27 19:30:28 +01:00
Add Minetest 0.4 support
This commit is contained in:
parent
4ebdf7f25f
commit
478684062d
16
init.lua
16
init.lua
@ -19,7 +19,19 @@
|
||||
|
||||
]]--
|
||||
|
||||
local S = minetest.get_translator("nether")
|
||||
local S
|
||||
if minetest.get_translator ~= nil then
|
||||
S = minetest.get_translator("nether")
|
||||
else
|
||||
-- mock the translator function for MT 0.4
|
||||
S = function(str, ...)
|
||||
local args={...}
|
||||
return str:gsub(
|
||||
"@%d+",
|
||||
function(match) return args[tonumber(match:sub(2))] end
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
-- Global Nether namespace
|
||||
nether = {}
|
||||
@ -37,7 +49,7 @@ nether.NETHER_REALM_ENABLED = true -- Setting to false disables the Nethe
|
||||
-- Override default settings with values from the .conf file, if any are present.
|
||||
nether.FASTTRAVEL_FACTOR = tonumber(minetest.settings:get("nether_fasttravel_factor") or nether.FASTTRAVEL_FACTOR)
|
||||
nether.PORTAL_BOOK_LOOT_WEIGHTING = tonumber(minetest.settings:get("nether_portalBook_loot_weighting") or nether.PORTAL_BOOK_LOOT_WEIGHTING)
|
||||
nether.NETHER_REALM_ENABLED = minetest.settings:get_bool("nether_realm_enabled", nether.NETHER_REALM_ENABLED)
|
||||
nether.NETHER_REALM_ENABLED = minetest.settings:get_bool("nether_realm_enabled", nether.NETHER_REALM_ENABLED) or nether.NETHER_REALM_ENABLED
|
||||
|
||||
|
||||
-- Load files
|
||||
|
20
nodes.lua
20
nodes.lua
@ -1,7 +1,9 @@
|
||||
local S = nether.get_translator
|
||||
|
||||
-- Portal node
|
||||
|
||||
minetest.register_node("nether:portal", {
|
||||
description = "Nether Portal",
|
||||
description = S("Nether Portal"),
|
||||
tiles = {
|
||||
"nether_transparent.png",
|
||||
"nether_transparent.png",
|
||||
@ -63,7 +65,7 @@ minetest.register_node("nether:portal", {
|
||||
-- Nether nodes
|
||||
|
||||
minetest.register_node("nether:rack", {
|
||||
description = "Netherrack",
|
||||
description = S("Netherrack"),
|
||||
tiles = {"nether_rack.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky = 3, level = 2},
|
||||
@ -71,7 +73,7 @@ minetest.register_node("nether:rack", {
|
||||
})
|
||||
|
||||
minetest.register_node("nether:sand", {
|
||||
description = "Nethersand",
|
||||
description = S("Nethersand"),
|
||||
tiles = {"nether_sand.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly = 3, level = 2, falling_node = 1},
|
||||
@ -81,7 +83,7 @@ minetest.register_node("nether:sand", {
|
||||
})
|
||||
|
||||
minetest.register_node("nether:glowstone", {
|
||||
description = "Glowstone",
|
||||
description = S("Glowstone"),
|
||||
tiles = {"nether_glowstone.png"},
|
||||
is_ground_content = true,
|
||||
light_source = 14,
|
||||
@ -91,7 +93,7 @@ minetest.register_node("nether:glowstone", {
|
||||
})
|
||||
|
||||
minetest.register_node("nether:brick", {
|
||||
description = "Nether Brick",
|
||||
description = S("Nether Brick"),
|
||||
tiles = {"nether_brick.png"},
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 2, level = 2},
|
||||
@ -102,7 +104,7 @@ local fence_texture =
|
||||
"default_fence_overlay.png^nether_brick.png^default_fence_overlay.png^[makealpha:255,126,126"
|
||||
|
||||
minetest.register_node("nether:fence_nether_brick", {
|
||||
description = "Nether Brick Fence",
|
||||
description = S("Nether Brick Fence"),
|
||||
drawtype = "fencelike",
|
||||
tiles = {"nether_brick.png"},
|
||||
inventory_image = fence_texture,
|
||||
@ -126,8 +128,8 @@ stairs.register_stair_and_slab(
|
||||
"nether:brick",
|
||||
{cracky = 2, level = 2},
|
||||
{"nether_brick.png"},
|
||||
"nether stair",
|
||||
"nether slab",
|
||||
S("Nether stair"),
|
||||
S("Nether slab"),
|
||||
default.node_sound_stone_defaults()
|
||||
)
|
||||
|
||||
@ -136,7 +138,7 @@ stairs.register_stair_and_slab(
|
||||
if minetest.get_modpath("moreblocks") then
|
||||
stairsplus:register_all(
|
||||
"nether", "brick", "nether:brick", {
|
||||
description = "Nether Brick",
|
||||
description = S("Nether Brick"),
|
||||
groups = {cracky = 2, level = 2},
|
||||
tiles = {"nether_brick.png"},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
|
@ -7,14 +7,14 @@ nether.registered_portals = {}
|
||||
-- gives the colour values in nether_portals_palette.png that are used by the wormhole colorfacedir
|
||||
-- hardware colouring.
|
||||
nether.portals_palette = {
|
||||
[0] = {r = 128, g = 0, b = 128}, -- traditional/magenta
|
||||
[1] = {r = 0, g = 0, b = 0}, -- black
|
||||
[2] = {r = 19, g = 19, b = 255}, -- blue
|
||||
[3] = {r = 55, g = 168, b = 0}, -- green
|
||||
[4] = {r = 141, g = 237, b = 255}, -- cyan
|
||||
[5] = {r = 221, g = 0, b = 0}, -- red
|
||||
[6] = {r = 255, g = 240, b = 0}, -- yellow
|
||||
[7] = {r = 255, g = 255, b = 255} -- white
|
||||
[0] = {r = 128, g = 0, b = 128, asString = "#800080"}, -- traditional/magenta
|
||||
[1] = {r = 0, g = 0, b = 0, asString = "#000000"}, -- black
|
||||
[2] = {r = 19, g = 19, b = 255, asString = "#1313FF"}, -- blue
|
||||
[3] = {r = 55, g = 168, b = 0, asString = "#37A800"}, -- green
|
||||
[4] = {r = 141, g = 237, b = 255, asString = "#8DEDFF"}, -- cyan
|
||||
[5] = {r = 221, g = 0, b = 0, asString = "#DD0000"}, -- red
|
||||
[6] = {r = 255, g = 240, b = 0, asString = "#FFF000"}, -- yellow
|
||||
[7] = {r = 255, g = 255, b = 255, asString = "#FFFFFF"} -- white
|
||||
}
|
||||
|
||||
|
||||
@ -1264,7 +1264,7 @@ function run_wormhole(timerPos, time_elapsed)
|
||||
end
|
||||
end
|
||||
|
||||
local p1, p2, frame_node_name
|
||||
local p1, p2, portal_name
|
||||
local meta = minetest.get_meta(timerPos)
|
||||
if meta ~= nil then
|
||||
p1 = minetest.string_to_pos(meta:get_string("p1"))
|
||||
@ -1328,6 +1328,34 @@ local function create_book(item_name, inventory_description, inventory_image, ti
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
local function add_book_as_treasure()
|
||||
-- If the Nether is the only registered portal then lower the amount of these books
|
||||
-- found as treasure, since many players already know the shape of a Nether portal
|
||||
-- and what to build one out of, so would probably prefer other treasures.
|
||||
local portalCount = 0
|
||||
for _ in pairs(nether.registered_portals) do portalCount = portalCount + 1 end
|
||||
|
||||
local weight_adjust = 1
|
||||
if portalCount <= 1 then weight_adjust = 0.5 end
|
||||
|
||||
if minetest.get_modpath("loot") then
|
||||
loot.register_loot({
|
||||
weights = { generic = nether.PORTAL_BOOK_LOOT_WEIGHTING * 1000 * weight_adjust,
|
||||
books = 100 },
|
||||
payload = { stack = "nether:book_of_portals" }
|
||||
})
|
||||
end
|
||||
|
||||
if minetest.get_modpath("dungeon_loot") then
|
||||
dungeon_loot.register({name = "nether:book_of_portals", chance = nether.PORTAL_BOOK_LOOT_WEIGHTING * weight_adjust})
|
||||
end
|
||||
|
||||
-- todo: add to Treasurer mod TRMP https://github.com/poikilos/trmp_minetest_game
|
||||
-- todo: add to help modpack https://forum.minetest.net/viewtopic.php?t=15912
|
||||
end
|
||||
|
||||
|
||||
-- Updates nether:book_of_portals
|
||||
-- A book the player can read to lean how to build the different portals
|
||||
local function create_book_of_portals()
|
||||
@ -1371,6 +1399,8 @@ local function create_book_of_portals()
|
||||
end
|
||||
end
|
||||
|
||||
local previouslyRegistered = minetest.registered_items["nether:book_of_portals"] ~= nil
|
||||
|
||||
create_book(
|
||||
"nether:book_of_portals",
|
||||
S("Book of Portals"),
|
||||
@ -1380,6 +1410,10 @@ local function create_book_of_portals()
|
||||
page1_text,
|
||||
page2_text
|
||||
)
|
||||
|
||||
if not previouslyRegistered and nether.PORTAL_BOOK_LOOT_WEIGHTING > 0 and portalCount > 0 then
|
||||
add_book_as_treasure()
|
||||
end
|
||||
end
|
||||
|
||||
-- This is hack to work around how place_schematic() never invalidates its cache.
|
||||
@ -1538,36 +1572,6 @@ minetest.register_lbm({
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_on_mods_loaded(function()
|
||||
|
||||
-- Make the Book of Portals available as treasure/loot
|
||||
if nether.PORTAL_BOOK_LOOT_WEIGHTING > 0 and minetest.registered_items["nether:book_of_portals"] ~= nil then
|
||||
|
||||
-- All portals should be registered now.
|
||||
-- If the Nether is the only registered portal then lower the amount of these books
|
||||
-- found as treasure, since many players already know the shape of a Nether portal
|
||||
-- and what to build one out of, so would probably prefer other treasures.
|
||||
local portalCount = 0
|
||||
for _ in pairs(nether.registered_portals) do portalCount = portalCount + 1 end
|
||||
local weight_adjust = 1
|
||||
if portalCount <= 1 then weight_adjust = 0.5 end
|
||||
|
||||
if minetest.get_modpath("loot") then
|
||||
loot.register_loot({
|
||||
weights = { generic = nether.PORTAL_BOOK_LOOT_WEIGHTING * 1000 * weight_adjust,
|
||||
books = 100 },
|
||||
payload = { stack = "nether:book_of_portals" }
|
||||
})
|
||||
end
|
||||
|
||||
if minetest.get_modpath("dungeon_loot") then
|
||||
dungeon_loot.register({name = "nether:book_of_portals", chance = nether.PORTAL_BOOK_LOOT_WEIGHTING * weight_adjust})
|
||||
end
|
||||
|
||||
-- todo: add to Treasurer mod TRMP https://github.com/poikilos/trmp_minetest_game
|
||||
-- todo: add to help modpack https://forum.minetest.net/viewtopic.php?t=15912
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
-- Portal API functions --
|
||||
@ -1576,7 +1580,7 @@ end)
|
||||
|
||||
-- The fallback defaults for registered portaldef tables
|
||||
local portaldef_default = {
|
||||
shape = PortalShape_Traditional,
|
||||
shape = nether.PortalShape_Traditional,
|
||||
wormhole_node_name = "nether:portal",
|
||||
wormhole_node_color = 0,
|
||||
frame_node_name = "default:obsidian",
|
||||
@ -1613,8 +1617,7 @@ function nether.register_portal(name, portaldef)
|
||||
if portaldef.particle_color == nil then
|
||||
-- default the particle colours to be the same as the wormhole colour
|
||||
assert(portaldef.wormhole_node_color >= 0 and portaldef.wormhole_node_color < 8, "portaldef.wormhole_node_color must be between 0 and 7 (inclusive)")
|
||||
local rgb = nether.portals_palette[portaldef.wormhole_node_color]
|
||||
portaldef.particle_color = minetest.rgba(rgb.r, rgb.g, rgb.b)
|
||||
portaldef.particle_color = nether.portals_palette[portaldef.wormhole_node_color].asString
|
||||
end
|
||||
if portaldef.particle_texture_colored == nil then
|
||||
-- Combine the particle texture with the particle color unless a particle_texture_colored was specified.
|
||||
@ -1839,4 +1842,4 @@ function nether.find_nearest_working_portal(portal_name, anchorPos, distance_lim
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end
|
@ -44,7 +44,7 @@ local SURFACE_TRAVEL_DISTANCE = 26
|
||||
local FLOATLANDS_ENABLED = false
|
||||
local FLOATLAND_LEVEL = 1280
|
||||
|
||||
if minetest.settings:get_bool("nether_enable_portal_example_floatlands", ENABLE_PORTAL_EXAMPLE_FLOATLANDS) then
|
||||
if minetest.settings:get_bool("nether_enable_portal_example_floatlands", ENABLE_PORTAL_EXAMPLE_FLOATLANDS) or ENABLE_PORTAL_EXAMPLE_FLOATLANDS then
|
||||
|
||||
local floatlands_flavortext = ""
|
||||
if minetest.get_mapgen_setting("mg_name") == "v7" then
|
||||
@ -122,7 +122,7 @@ end
|
||||
local get_moore_distance -- will be function get_moore_distance(cell_count, x, y): integer
|
||||
local get_moore_coords -- will be function get_moore_coords(cell_count, distance): pos2d
|
||||
|
||||
if minetest.settings:get_bool("nether_enable_portal_example_surfacetravel", ENABLE_PORTAL_EXAMPLE_SURFACETRAVEL) then
|
||||
if minetest.settings:get_bool("nether_enable_portal_example_surfacetravel", ENABLE_PORTAL_EXAMPLE_SURFACETRAVEL) or ENABLE_PORTAL_EXAMPLE_SURFACETRAVEL then
|
||||
|
||||
nether.register_portal("surface_portal", {
|
||||
shape = nether.PortalShape_Circular,
|
||||
|
Loading…
Reference in New Issue
Block a user