summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2016-01-09 12:25:33 +0000
committerTenPlus1 <kinsellaja@yahoo.com>2016-01-09 12:25:33 +0000
commitad7b63b86971ccae7b1abc008196c9e9553b54ec (patch)
tree05fe8e2a0ea0e9b8d4939cffaed46e6abb0cf9f4
parent94873618b17859a6f3cc9c3a02dcc88b511075cf (diff)
Optimize and tidy code.
-rw-r--r--README.md3
-rw-r--r--dirt.lua8
-rw-r--r--extra.lua16
-rw-r--r--fences.lua2
-rw-r--r--flowers.lua8
-rw-r--r--gates.lua32
-rw-r--r--init.lua2
-rw-r--r--mapgen_v7n.lua2
-rw-r--r--mushroom.lua10
-rw-r--r--onion.lua2
-rw-r--r--papyrus.lua2
-rw-r--r--plantlife.lua6
-rw-r--r--plantpack.lua2
-rw-r--r--sapling.lua2
-rw-r--r--sealife.lua6
-rw-r--r--strawberry.lua4
-rw-r--r--water.lua18
-rw-r--r--wood.lua2
18 files changed, 67 insertions, 60 deletions
diff --git a/README.md b/README.md
index 0e1d71c..ee8c1db 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/dirt.lua b/dirt.lua
index 73c2ea0..e4fd4f8 100644
--- a/dirt.lua
+++ b/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
})
diff --git a/extra.lua b/extra.lua
index e61cc4c..3455ff9 100644
--- a/extra.lua
+++ b/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
diff --git a/fences.lua b/fences.lua
index c639a85..17bf442 100644
--- a/fences.lua
+++ b/fences.lua
@@ -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",
diff --git a/flowers.lua b/flowers.lua
index 21c6dcc..fbe1344 100644
--- a/flowers.lua
+++ b/flowers.lua
@@ -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,
diff --git a/gates.lua b/gates.lua
index 3ffc0d6..f669615 100644
--- a/gates.lua
+++ b/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,13 +117,14 @@ 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"},
}
})
-end \ No newline at end of file
+end
diff --git a/init.lua b/init.lua
index 8e2c319..bc8f1fd 100644
--- a/init.lua
+++ b/init.lua
@@ -63,4 +63,4 @@ else
dofile(path .. "/stairs.lua")
end
-print ("[MOD] Ethereal mod loaded") \ No newline at end of file
+print ("[MOD] Ethereal mod loaded")
diff --git a/mapgen_v7n.lua b/mapgen_v7n.lua
index 0e1d945..ab7f6ea 100644
--- a/mapgen_v7n.lua
+++ b/mapgen_v7n.lua
@@ -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)
diff --git a/mushroom.lua b/mushroom.lua
index 5485c07..39e14d2 100644
--- a/mushroom.lua
+++ b/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")
diff --git a/onion.lua b/onion.lua
index b222969..e6eb78b 100644
--- a/onion.lua
+++ b/onion.lua
@@ -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
})
diff --git a/papyrus.lua b/papyrus.lua
index d689ed9..4f359ca 100644
--- a/papyrus.lua
+++ b/papyrus.lua
@@ -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
diff --git a/plantlife.lua b/plantlife.lua
index acb998b..9395362 100644
--- a/plantlife.lua
+++ b/plantlife.lua
@@ -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)
@@ -549,4 +549,4 @@ minetest.register_craft({
{"","ethereal:palm_wax"},
{"","ethereal:palm_wax"},
}
-}) \ No newline at end of file
+})
diff --git a/plantpack.lua b/plantpack.lua
index 6956de4..09e361e 100644
--- a/plantpack.lua
+++ b/plantpack.lua
@@ -187,4 +187,4 @@ minetest.register_craft({
{"","ethereal:mushroom_plant", ""},
{"","ethereal:bowl", ""},
}
-}) \ No newline at end of file
+})
diff --git a/sapling.lua b/sapling.lua
index ac15dbf..05ba759 100644
--- a/sapling.lua
+++ b/sapling.lua
@@ -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
diff --git a/sealife.lua b/sealife.lua
index 8a7a245..41de5d0 100644
--- a/sealife.lua
+++ b/sealife.lua
@@ -166,15 +166,15 @@ 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
end,
-}) \ No newline at end of file
+})
diff --git a/strawberry.lua b/strawberry.lua
index 87833e1..d919cca 100644
--- a/strawberry.lua
+++ b/strawberry.lua
@@ -223,8 +223,8 @@ 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
})
-end \ No newline at end of file
+end
diff --git a/water.lua b/water.lua
index 1f13f51..952b3ca 100644
--- a/water.lua
+++ b/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,8 +145,8 @@ 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,
-}) \ No newline at end of file
+})
diff --git a/wood.lua b/wood.lua
index 7310abe..d0b891e 100644
--- a/wood.lua
+++ b/wood.lua
@@ -265,4 +265,4 @@ minetest.register_node("ethereal:birch_wood", {
minetest.register_craft({
output = "ethereal:birch_wood 4",
recipe = {{"ethereal:birch_trunk"}}
-}) \ No newline at end of file
+})