Optimize and tidy code.
This commit is contained in:
parent
94873618b1
commit
ad7b63b869
@ -16,7 +16,8 @@ Ethereal v7 Mapgen mod for Minetest
|
||||
- Dirt with dry grass turns into green grass when near water
|
||||
- Ice or snow above sea level melts into river water
|
||||
- Disabling ethereal biomes no longer shows error messages
|
||||
- Fire Flowers re-generate, can also be made into Fire Dust
|
||||
- Fire Flowers re-generate, can also be made into Fire Dust and both are fuel
|
||||
- Optimize and tidy code
|
||||
|
||||
### 1.18
|
||||
|
||||
|
8
dirt.lua
8
dirt.lua
@ -42,7 +42,7 @@ dirt.type = {
|
||||
{"Crystal"}, {"Mushroom"}, {"Fiery"}, {"Gray"},
|
||||
}
|
||||
|
||||
for _, row in ipairs(dirt.type) do
|
||||
for _, row in pairs(dirt.type) do
|
||||
|
||||
local desc = row[1]
|
||||
local name = desc:lower()
|
||||
@ -89,7 +89,7 @@ minetest.register_abm({
|
||||
"group:ethereal_grass")
|
||||
local n
|
||||
-- count new grass nodes
|
||||
for _,p in ipairs(positions) do
|
||||
for _,p in pairs(positions) do
|
||||
n = minetest.get_node_or_nil(p)
|
||||
if n and n.name then
|
||||
count_grasses[n.name] = (count_grasses[n.name] or 0) + 1
|
||||
@ -100,7 +100,7 @@ minetest.register_abm({
|
||||
end
|
||||
end
|
||||
end
|
||||
minetest.set_node(pos, {name = curr_type})
|
||||
minetest.swap_node(pos, {name = curr_type})
|
||||
end
|
||||
})
|
||||
|
||||
@ -125,7 +125,7 @@ minetest.register_abm({
|
||||
if name ~= "ignore" and nodedef and not ((nodedef.sunlight_propagates or
|
||||
nodedef.paramtype == "light") and
|
||||
nodedef.liquidtype == "none") then
|
||||
minetest.set_node(pos, {name = "default:dirt"})
|
||||
minetest.swap_node(pos, {name = "default:dirt"})
|
||||
end
|
||||
end
|
||||
})
|
||||
|
16
extra.lua
16
extra.lua
@ -97,7 +97,7 @@ minetest.register_node("ethereal:glostone", {
|
||||
description = "Glo Stone",
|
||||
tiles = {"glostone.png"},
|
||||
groups = {cracky = 3},
|
||||
light_source = default.LIGHT_MAX - 1,
|
||||
light_source = 13,
|
||||
drop = "ethereal:glostone",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
@ -290,8 +290,9 @@ minetest.register_tool("ethereal:light_staff", {
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if node then node = node.name else return end
|
||||
|
||||
if node == "default:stone" then
|
||||
minetest.set_node(pos, {name="ethereal:glostone"})
|
||||
if node == "default:stone"
|
||||
or node == "default:desert_stone" then
|
||||
minetest.swap_node(pos, {name="ethereal:glostone"})
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535 / 149) -- 150 uses
|
||||
end
|
||||
@ -318,13 +319,14 @@ minetest.register_on_generated(function(minp, maxp)
|
||||
local bpos
|
||||
for key, pos in pairs(minetest.find_nodes_in_area_under_air(minp, maxp, "default:stone_with_coal")) do
|
||||
bpos = {x = pos.x, y = pos.y + 1, z = pos.z }
|
||||
if minetest.get_node(bpos).name == "air" then
|
||||
if math.random(1, 2) == 1
|
||||
and minetest.get_node(bpos).name == "air" then
|
||||
if bpos.y > -3000 and bpos.y < -2000 then
|
||||
minetest.set_node(bpos, {name = "ethereal:illumishroom3"})
|
||||
minetest.swap_node(bpos, {name = "ethereal:illumishroom3"})
|
||||
elseif bpos.y > -2000 and bpos.y < -1000 then
|
||||
minetest.set_node(bpos, {name = "ethereal:illumishroom2"})
|
||||
minetest.swap_node(bpos, {name = "ethereal:illumishroom2"})
|
||||
elseif bpos.y > -1000 and bpos.y < -30 then
|
||||
minetest.set_node(bpos, {name = "ethereal:illumishroom"})
|
||||
minetest.swap_node(bpos, {name = "ethereal:illumishroom"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -13,7 +13,7 @@ local fences = {
|
||||
{"birch", "Birch Wood", "moretrees_birch_wood.png", "ethereal:birch_wood"},
|
||||
}
|
||||
|
||||
for _, row in ipairs(fences) do
|
||||
for _, row in pairs(fences) do
|
||||
|
||||
minetest.register_node("ethereal:fence_"..row[1], {
|
||||
description = row[2].." Fence",
|
||||
|
@ -39,7 +39,7 @@ minetest.register_abm({
|
||||
|
||||
grass.y = grass.y + 1
|
||||
|
||||
minetest.set_node(grass, {name = "ethereal:crystal_spike"})
|
||||
minetest.swap_node(grass, {name = "ethereal:crystal_spike"})
|
||||
end
|
||||
end
|
||||
|
||||
@ -54,7 +54,7 @@ minetest.register_abm({
|
||||
local fflower = minetest.find_nodes_in_area_under_air(
|
||||
pos0, pos1, {"ethereal:fire_flower"})
|
||||
|
||||
if #grass > 4
|
||||
if #grass > 5
|
||||
and #fflower < 1 then
|
||||
|
||||
grass = grass[math.random(#grass)]
|
||||
@ -65,7 +65,7 @@ minetest.register_abm({
|
||||
|
||||
grass.y = grass.y + 1
|
||||
|
||||
minetest.set_node(grass, {name = "ethereal:fire_flower"})
|
||||
minetest.swap_node(grass, {name = "ethereal:fire_flower"})
|
||||
end
|
||||
end
|
||||
|
||||
@ -91,7 +91,7 @@ minetest.register_abm({
|
||||
end
|
||||
|
||||
if minetest.get_node(seedling).name == "air" then
|
||||
minetest.set_node(seedling, {name = node.name})
|
||||
minetest.swap_node(seedling, {name = node.name})
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
30
gates.lua
30
gates.lua
@ -15,18 +15,19 @@ local nb_pil = {
|
||||
|
||||
-- Open/Close Gates
|
||||
function gate_rightclick(pos, node)
|
||||
local gate, open = unpack(string.split(node.name, "_", 2))
|
||||
local gate = gate.."_"
|
||||
local sound, name
|
||||
if open == "open" then
|
||||
|
||||
local split = string.split(node.name, "_")
|
||||
local sound = "open"
|
||||
local name = "open"
|
||||
|
||||
if split[3] == "open" then
|
||||
sound = "close"
|
||||
name = "closed"
|
||||
else
|
||||
sound = "open"
|
||||
name = "open"
|
||||
end
|
||||
node.name = gate..name
|
||||
minetest.set_node(pos, node)
|
||||
|
||||
node.name = split[1] .. "_" .. split[2] .. "_" .. name
|
||||
minetest.swap_node(pos, node)
|
||||
|
||||
minetest.sound_play("doors_door_"..sound, {
|
||||
pos = pos,
|
||||
gain = 0.3,
|
||||
@ -52,7 +53,7 @@ local gates = {
|
||||
|
||||
for _, row in pairs(gates) do
|
||||
|
||||
minetest.register_node("ethereal:"..row[1].."gate_open", {
|
||||
minetest.register_node("ethereal:fencegate_"..row[1].."_open", {
|
||||
tiles = {row[3]},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
@ -60,7 +61,7 @@ minetest.register_node("ethereal:"..row[1].."gate_open", {
|
||||
is_ground_content = false,
|
||||
walkable = true,
|
||||
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, not_in_inventory = 1},
|
||||
drop = "ethereal:"..row[1].."gate_closed",
|
||||
drop = "ethereal:fencegate_"..row[1].."_closed",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -87,7 +88,9 @@ minetest.register_node("ethereal:"..row[1].."gate_open", {
|
||||
on_rightclick = gate_rightclick,
|
||||
})
|
||||
|
||||
minetest.register_node("ethereal:"..row[1].."gate_closed", {
|
||||
minetest.register_alias("ethereal:"..row[1].."gate_open", "ethereal:fencegate_"..row[1].."_open")
|
||||
|
||||
minetest.register_node("ethereal:fencegate_"..row[1].."_closed", {
|
||||
description = row[2].." Gate",
|
||||
tiles = {row[3]},
|
||||
inventory_image = "default_gate_overlay.png^"..row[3].."^default_gate_overlay.png^[makealpha:255,126,126",
|
||||
@ -114,9 +117,10 @@ minetest.register_node("ethereal:"..row[1].."gate_closed", {
|
||||
},
|
||||
on_rightclick = gate_rightclick,
|
||||
})
|
||||
minetest.register_alias("ethereal:"..row[1].."gate_closed", "ethereal:fencegate_"..row[1].."_closed")
|
||||
|
||||
minetest.register_craft({
|
||||
output = "ethereal:"..row[1].."gate_closed",
|
||||
output = "ethereal:fencegate_"..row[1].."_closed",
|
||||
recipe = {
|
||||
{"group:stick", row[4], "group:stick"},
|
||||
{"group:stick", row[4], "group:stick"},
|
||||
|
@ -360,7 +360,7 @@ add_node({"ethereal:crystal_dirt"}, 0.02, {"frost"}, 1, 100, {"ethereal:crystal_
|
||||
add_node({"ethereal:fiery_dirt"}, 0.12, {"fiery"}, 1, 100, {"ethereal:dry_shrub"}, nil, nil, nil, ethereal.fiery)
|
||||
|
||||
-- fire flower
|
||||
add_node({"ethereal:fiery_dirt"}, 0.02, {"fiery"}, 1, 100, {"ethereal:fire_flower"}, nil, nil, nil, ethereal.fiery)
|
||||
--add_node({"ethereal:fiery_dirt"}, 0.02, {"fiery"}, 1, 100, {"ethereal:fire_flower"}, nil, nil, nil, ethereal.fiery)
|
||||
|
||||
-- snowy grass
|
||||
add_node({"ethereal:gray_dirt"}, 0.05, {"grayness"}, 1, 100, {"ethereal:snowygrass"}, nil, nil, nil, ethereal.grayness)
|
||||
|
10
mushroom.lua
10
mushroom.lua
@ -51,8 +51,6 @@ minetest.register_node(":flowers:mushroom_brown", {
|
||||
}
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
-- mushroom spread and death
|
||||
minetest.register_abm({
|
||||
nodenames = {"flowers:mushroom_brown", "flowers:mushroom_red"},
|
||||
@ -89,13 +87,15 @@ minetest.register_abm({
|
||||
end
|
||||
|
||||
if minetest.get_item_group(node_under.name, "soil") ~= 0
|
||||
and minetest.get_node_light(pos, nil) < 13
|
||||
and minetest.get_node_light(random, nil) < 13 then
|
||||
minetest.set_node(random, {name = node.name})
|
||||
and minetest.get_node_light(pos, nil) < 9
|
||||
and minetest.get_node_light(random, nil) < 9 then
|
||||
minetest.swap_node(random, {name = node.name})
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
-- these old mushroom related nodes can be simplified now
|
||||
minetest.register_alias("flowers:mushroom_spores_brown", "flowers:mushroom_brown")
|
||||
minetest.register_alias("flowers:mushroom_spores_red", "flowers:mushroom_red")
|
||||
|
@ -94,7 +94,7 @@ minetest.register_abm({
|
||||
|
||||
-- grow
|
||||
node.name = "ethereal:onion_"..minetest.get_item_group(node.name, "onion") + 1
|
||||
minetest.set_node(pos, node)
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
})
|
||||
|
||||
|
@ -48,7 +48,7 @@ minetest.register_abm({
|
||||
z = pos.z
|
||||
}, 1, 1, ethereal.bambootree)
|
||||
else
|
||||
minetest.set_node(pos, {name = node.name})
|
||||
minetest.swap_node(pos, {name = node.name})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -29,7 +29,7 @@ minetest.register_node("ethereal:fire_flower", {
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "ethereal:fire_flower",
|
||||
burntime = 60,
|
||||
burntime = 40,
|
||||
})
|
||||
|
||||
-- Fire Dust
|
||||
@ -48,7 +48,7 @@ minetest.register_craft({
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "ethereal:fire_dust",
|
||||
burntime = 30,
|
||||
burntime = 20,
|
||||
})
|
||||
|
||||
-- Fern (boston)
|
||||
|
@ -46,7 +46,7 @@ ethereal.add_tree = function (pos, ofx, ofz, schem)
|
||||
return
|
||||
end
|
||||
-- remove sapling and place schematic
|
||||
minetest.set_node(pos, {name = "air"})
|
||||
minetest.swap_node(pos, {name = "air"})
|
||||
minetest.place_schematic(
|
||||
{x = pos.x - ofx, y = pos.y, z =pos.z - ofz},
|
||||
schem, "random", {}, false
|
||||
|
@ -166,13 +166,13 @@ minetest.register_abm({
|
||||
if height < 14
|
||||
and pos.y < 0
|
||||
and minetest.get_node(pos).name == "default:water_source" then
|
||||
minetest.set_node(pos, {name = "ethereal:seaweed"})
|
||||
minetest.swap_node(pos, {name = "ethereal:seaweed"})
|
||||
end
|
||||
|
||||
else
|
||||
pos.y = pos.y + 1
|
||||
if minetest.get_node(pos).name == "default:water_source" then
|
||||
minetest.set_node(pos, {name = "ethereal:coral"..sel})
|
||||
minetest.swap_node(pos, {name = "ethereal:coral"..sel})
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -223,7 +223,7 @@ minetest.register_abm({
|
||||
|
||||
-- grow
|
||||
local height = minetest.get_item_group(node.name, "strawberry") + 1
|
||||
minetest.set_node(pos, {name = "ethereal:strawberry_"..height})
|
||||
minetest.swap_node(pos, {name = "ethereal:strawberry_"..height})
|
||||
end
|
||||
})
|
||||
|
||||
|
16
water.lua
16
water.lua
@ -47,7 +47,7 @@ minetest.register_abm({
|
||||
chance = 100,
|
||||
catch_up = false,
|
||||
action = function(pos, node)
|
||||
minetest.set_node(pos, {name = "default:mossycobble"})
|
||||
minetest.swap_node(pos, {name = "default:mossycobble"})
|
||||
end
|
||||
})
|
||||
|
||||
@ -68,7 +68,7 @@ minetest.register_abm({
|
||||
{"default:water_source", "default:river_water_source"})
|
||||
|
||||
if water and #water > 0 then
|
||||
minetest.set_node(water[1], {name = "default:ice"})
|
||||
minetest.swap_node(water[1], {name = "default:ice"})
|
||||
end
|
||||
end,
|
||||
})
|
||||
@ -97,11 +97,11 @@ minetest.register_abm({
|
||||
or node.name == "default:snowblock"
|
||||
or node.name == "ethereal:icebrick"
|
||||
or node.name == "ethereal:snowbrick" then
|
||||
minetest.set_node(pos, {name = water_node.."_source"})
|
||||
minetest.swap_node(pos, {name = water_node.."_source"})
|
||||
elseif node.name == "default:snow" then
|
||||
minetest.set_node(pos, {name = water_node.."_flowing"})
|
||||
minetest.swap_node(pos, {name = water_node.."_flowing"})
|
||||
elseif node.name == "default:dirt_with_snow" then
|
||||
minetest.set_node(pos, {name = "default:dirt_with_grass"})
|
||||
minetest.swap_node(pos, {name = "default:dirt_with_grass"})
|
||||
end
|
||||
|
||||
nodeupdate(pos)
|
||||
@ -117,9 +117,9 @@ minetest.register_abm({
|
||||
catch_up = false,
|
||||
action = function(pos, node)
|
||||
if node == "ethereal:dry_dirt" then
|
||||
minetest.set_node(pos, {name = "default:dirt"})
|
||||
minetest.swap_node(pos, {name = "default:dirt"})
|
||||
else
|
||||
minetest.set_node(pos, {name = "ethereal:green_dirt"})
|
||||
minetest.swap_node(pos, {name = "ethereal:green_dirt"})
|
||||
end
|
||||
end,
|
||||
})
|
||||
@ -145,7 +145,7 @@ minetest.register_abm({
|
||||
{x = pos.x, y = pos.y + 1, z = pos.z},
|
||||
{"group:water"})
|
||||
if num > 0 then
|
||||
minetest.set_node(pos, {name = "default:water_flowing"})
|
||||
minetest.swap_node(pos, {name = "default:water_flowing"})
|
||||
minetest.add_item(pos, {name = node.name})
|
||||
end
|
||||
end,
|
||||
|
Loading…
Reference in New Issue
Block a user