Skip to content
Snippets Groups Projects
Commit 7d5b162a authored by tenplus1's avatar tenplus1
Browse files

tidied & optimized code

parent efd4ab24
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ Added Staff of Light (thanks Xanthin), crafted from illumishrooms and can turn s
Changed how Crystal Spikes reproduce
Crystal Ingots now require 2x mese crystal and 2x crystal spikes to craft
Removed obsidian brick & stairs now they are in default game, also removed pine wood stairs for same reason
Tidied code and optimized a few routines
1.14
......
-- Override default Dirt (to stop caves cutting away dirt)
-- override default dirt (to stop caves cutting away dirt)
minetest.override_item("default:dirt", {is_ground_content = false})
-- Green Dirt
-- green dirt
minetest.register_node("ethereal:green_dirt", {
description = "Green Dirt",
tiles = {"default_grass.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"},
......@@ -11,7 +11,7 @@ minetest.register_node("ethereal:green_dirt", {
sounds = default.node_sound_dirt_defaults()
})
-- Dry Dirt
-- dry dirt
minetest.register_node("ethereal:dry_dirt", {
description = "Dried Dirt",
tiles = {"ethereal_dry_dirt.png"},
......@@ -55,49 +55,50 @@ minetest.register_alias("ethereal:fiery_dirt_top", "ethereal:fiery_dirt")
minetest.register_alias("ethereal:gray_dirt_top", "ethereal:gray_dirt")
minetest.register_alias("ethereal:green_dirt_top", "ethereal:green_dirt")
-- Check surrounding grass and change dirt to Same colour (by Sokomine)
-- check surrounding grass and change dirt to same colour (by Sokomine)
minetest.register_abm({
nodenames = {"default:dirt_with_grass"},
interval = 5,
chance = 5,
chance = 2,
action = function(pos, node)
local count_grasses = {}
local curr_max = 0
local curr_type = "ethereal:green_dirt_top"; -- Fallback Colour
local positions = minetest.find_nodes_in_area( {x=(pos.x-2), y=(pos.y-2), z=(pos.z-2)},
{x=(pos.x+2), y=(pos.y+2), z=(pos.z+2)},
"group:ethereal_grass" )
local curr_type = "ethereal:green_dirt_top" -- fallback Colour
local positions = minetest.find_nodes_in_area(
{x=(pos.x-2), y=(pos.y-2), z=(pos.z-2)},
{x=(pos.x+2), y=(pos.y+2), z=(pos.z+2)},
"group:ethereal_grass")
-- count new grass nodes
for _,p in ipairs(positions) do
-- count the new grass node
local n = minetest.get_node( p )
if( n and n.name ) then
if( not( count_grasses[ n.name ] )) then
count_grasses[ n.name ] = 1
local n = minetest.get_node(p)
if n and n.name then
if not count_grasses[n.name] then
count_grasses[n.name] = 1
else
count_grasses[ n.name ] = count_grasses[ n.name ] + 1
count_grasses[n.name] = count_grasses[n.name] + 1
end
-- we found a grass type of which there"s more than the current max
if( count_grasses[ n.name ] > curr_max ) then
curr_max = count_grasses[ n.name ]
-- we found a grass type with more than current max
if count_grasses[n.name] > curr_max then
curr_max = count_grasses[n.name]
curr_type = n.name
end
end
end
minetest.set_node(pos, {name = curr_type })
minetest.set_node(pos, {name = curr_type})
end
})
-- If Grass devoid of light, change to Dirt
-- if grass devoid of light, change to dirt
minetest.register_abm({
nodenames = {"group:ethereal_grass"},
interval = 5,
interval = 2,
chance = 20,
action = function(pos, node)
local name = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name
local nodedef = minetest.registered_nodes[name]
if name ~= "ignore" and nodedef
and not ((nodedef.sunlight_propagates or nodedef.paramtype == "light")
and nodedef.liquidtype == "none") then
and not ((nodedef.sunlight_propagates or nodedef.paramtype == "light")
and nodedef.liquidtype == "none") then
minetest.set_node(pos, {name = "default:dirt"})
end
end
......
......@@ -12,9 +12,6 @@ minetest.register_node("ethereal:vine", {
is_ground_content = false,
selection_box = {
type = "wallmounted",
--wall_top = = <default>
--wall_bottom = = <default>
--wall_side = = <default>
},
groups = {choppy=3, oddly_breakable_by_hand=1},
legacy_wallmounted = true,
......@@ -44,9 +41,6 @@ minetest.register_node("ethereal:stone_ladder", {
is_ground_content = false,
selection_box = {
type = "wallmounted",
--wall_top = = <default>
--wall_bottom = = <default>
--wall_side = = <default>
},
groups = {cracky=3, oddly_breakable_by_hand=1},
legacy_wallmounted = true,
......@@ -310,10 +304,10 @@ minetest.register_craft({
minetest.register_on_generated(function(minp, maxp, seed)
local coal_nodes = minetest.find_nodes_in_area(minp, maxp, "default:stone_with_coal")
local bpos
for key, pos in pairs(coal_nodes) do
local bpos = { x=pos.x, y=pos.y + 1, z=pos.z }
bpos = { x=pos.x, y=pos.y + 1, z=pos.z }
if minetest.get_node(bpos).name == "air" then
if bpos.y > -3000 and bpos.y < -2000 then
......
--[[
Minetest Ethereal Mod 1.15 (9th April 2015)
Minetest Ethereal Mod 1.15 (10th April 2015)
Created by ChinChow
......@@ -35,6 +35,7 @@ ethereal.lake = 1 -- Small sandy lake areas with gravel below, also used for
ethereal.plains = 1 -- Dry dirt with scorched trees
ethereal.fiery = 1 -- Red grass with lava craters
ethereal.sandclay = 1 -- Sand areas with clay underneath
ethereal.icewater = 1 -- Ice surrounding cold coastal areas
dofile(minetest.get_modpath("ethereal").."/plantlife.lua")
dofile(minetest.get_modpath("ethereal").."/mushroom.lua")
......
This diff is collapsed.
-- Override default Papyrus to make it walkable
-- override default papyrus to make it walkable
minetest.override_item("default:papyrus", {walkable=true, sunlight_propagates=true})
-- Have Papyrus grow up to 4 high and Bamboo grow up to 5 in height (shared abm)
-- have papyrus grow up to 4 high and bamboo grow up to 5 in height (shared abm)
minetest.register_abm({
nodenames = {"default:papyrus", "ethereal:bamboo"},
neighbors = {"group:soil"},
......@@ -10,32 +9,32 @@ minetest.register_abm({
chance = 20,
action = function(pos, node)
local type = minetest.get_node(pos).name
local high = 4
pos.y = pos.y-1
local name = minetest.get_node(pos).name
pos.y = pos.y - 1
local nod = minetest.get_node_or_nil(pos)
if minetest.get_item_group(name, "soil") < 1 or minetest.find_node_near(pos, 3, {"group:water"}) == nil then
if not nod
or minetest.get_item_group(nod.name, "soil") < 1
or minetest.find_node_near(pos, 3, {"group:water"}) == nil then
return
end
if type == "ethereal:bamboo" then
if node.name == "ethereal:bamboo" then
high = 5
end
pos.y = pos.y+1
pos.y = pos.y + 1
local height = 0
while minetest.get_node(pos).name == type and height < high do
height = height+1
pos.y = pos.y+1
while minetest.get_node(pos).name == node.name and height < high do
height = height + 1
pos.y = pos.y + 1
end
if height < high then
if minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name=type})
end
nod = minetest.get_node_or_nil(pos)
if nod and nod.name == "air" and height < high then
minetest.set_node(pos, {name=node.name})
end
end,
......
......@@ -4,7 +4,6 @@
--= Desert Biome
-- Cactus
minetest.register_decoration({
deco_type = "simple",
place_on = {"default:desert_sand", "default:sandstone"},
......@@ -15,7 +14,6 @@ minetest.register_decoration({
})
-- Desert Plants
minetest.register_decoration({
deco_type = "simple",
place_on = {"default:desert_sand", "default:sandstone", "default:sand"},
......@@ -28,7 +26,6 @@ minetest.register_decoration({
--= Prairie Biome
-- Grass
minetest.register_decoration({
deco_type = "simple",
place_on = {"ethereal:prairie_dirt", "ethereal:green_dirt"},
......@@ -39,7 +36,6 @@ minetest.register_decoration({
})
-- Flowers
minetest.register_decoration({
deco_type = "simple",
place_on = {"ethereal:prairie_grass", "ethereal:green_dirt", "ethereal:grove_dirt", "ethereal:bamboo_dirt"},
......@@ -58,8 +54,7 @@ minetest.register_decoration({
decoration = {"bakedclay:flower_delphinium", "bakedclay:flower_celosia", "bakedclay:flower_daisy", "bakedclay:flower_bluerose"},
})
--= Shrubs
-- Shrubs
minetest.register_decoration({
deco_type = "simple",
place_on = {"ethereal:prairie_grass", "ethereal:green_dirt", "ethereal:grove_dirt", "ethereal:jungle_grass", "ethereal:gray_dirt"},
......
......@@ -49,8 +49,8 @@ end
-- Grow saplings
minetest.register_abm({
nodenames = {"group:ethereal_sapling"},
interval = 20,
chance = 25,
interval = 10,
chance = 50,
action = function(pos, node)
local under = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
......
......@@ -120,7 +120,7 @@ minetest.register_ore({
height_min = -100,
})
-- Randomly generate Coral or Seaweed and have Seaweed grow up to 10 high
-- randomly generate coral or seaweed and have seaweed grow up to 10 high
minetest.register_abm({
nodenames = {"ethereal:sandy"},
neighbors = {"group:water"},
......@@ -130,31 +130,25 @@ minetest.register_abm({
action = function(pos, node)
local sel = math.random(1,5)
if sel == 1 or minetest.get_node(pos).name == "ethereal:seaweed" then
if sel == 1 or node.name == "ethereal:seaweed" then
local height = 0
while minetest.get_node(pos).name == "ethereal:seaweed"
or minetest.get_node(pos).name == "ethereal:sandy"
while (minetest.get_node(pos).name == "ethereal:seaweed"
or minetest.get_node(pos).name == "ethereal:sandy")
and height < 14 do
height = height + 1
pos.y = pos.y + 1
end
if height < 14 and pos.y < 0 then
if minetest.get_node(pos).name == "default:water_source" then
minetest.set_node(pos, {name="ethereal:seaweed"})
-- print ("GOING UP")
end
if height < 14 and pos.y < 0
and minetest.get_node(pos).name == "default:water_source" then
minetest.set_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})
-- print ("CORAL ", sel)
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment