improved flowers spawning, and some other code cleanup.

This commit is contained in:
NathanSalapat 2016-11-05 12:42:29 -05:00
parent a849b20e76
commit 8cbab18044
7 changed files with 107 additions and 147 deletions

6
README
View File

@ -1,4 +1,4 @@
Mod is by Don and Nathan
Mod is by Don, Nathan with optimizations from Snoopy.
Mymonths is licenced as DWYWPL
@ -30,8 +30,8 @@ The trees in these biomes do not loose their leaves.
Each morning at 6am a chat message will say the date. If the day is a holiday it will show in chat with the morning date.
If you are caught in a storm you will need to seek shelter. Rain or snow does nothingbut if you are in a storm, snowstorm,
sandstorm or hail you will recieve damage. You need to cover yourself so you do not recieve damage.
If you are caught in a storm you will need to seek shelter. Rain or snow does nothing but if you are in a storm, snowstorm,
sandstorm or hail you will receive damage. You need to cover yourself so you do not receive damage.
Chat Commands

View File

@ -1,3 +1,4 @@
default
thirsty?
lightning?
flowers?
bakedclay?

View File

@ -22,7 +22,10 @@ minetest.register_abm({
interval = 240,
chance = 100,
action = function (pos)
action = function (pos, node)
if node.name == 'default:desert_sand' then
return
end
-- return if not march or april
if mymonths.month_counter ~= 3
@ -30,44 +33,20 @@ minetest.register_abm({
return
end
local pos0 = {x = pos.x - 4, y = pos.y - 4, z = pos.z - 4}
local pos1 = {x = pos.x + 4, y = pos.y + 4, z = pos.z + 4}
local pos0 = {x = pos.x - 4, y = pos.y - 2, z = pos.z - 4}
local pos1 = {x = pos.x + 4, y = pos.y + 2, z = pos.z + 4}
local flowers = minetest.find_nodes_in_area(pos0, pos1, "group:flower")
if #flowers > 2 then
if #flowers > 1 then
return
end
pos.y = pos.y + 1
if minetest.get_node(pos).name == 'air' then
local key = math.random(1, 6)
if key == 1 then
minetest.set_node(pos, {name = 'flowers:dandelion_white'})
elseif key == 2 then
minetest.set_node(pos, {name = "flowers:dandelion_yellow"})
elseif key == 3 then
minetest.set_node(pos, {name = "flowers:geranium"})
elseif key == 4 then
minetest.set_node(pos, {name = "flowers:rose"})
elseif key == 5 then
minetest.set_node(pos, {name = "flowers:tulip"})
elseif key == 6 then
minetest.set_node(pos, {name = "flowers:viola"})
end
local key = math.random(1, mymonths.flower_number)
local placed_flower = mymonths.flowers[key]
minetest.set_node(pos, {name = placed_flower})
end
end
})

View File

@ -1,7 +1,7 @@
minetest.register_node("mymonths:fall_grass", {
description = "Dirt with Grass",
tiles = {"default_grass.png^[colorize:brown:50", "default_dirt.png",
{name = "default_dirt.png^default_grass_side.png^[colorize:brown:50",
{name = "default_dirt.png^(default_grass_side.png^[colorize:brown:50)",
tileable_vertical = false}},
groups = {crumbly = 3, soil = 1, spreading_dirt_type = 1},
drop = 'default:dirt',

View File

@ -1,10 +1,10 @@
--Settings
mymonths = {}
--Turn damage on or off. This will make storms and hail cause damage
--Turn damage on or off. This will make storms and hail cause damage to players
mymonths.damage = false
--You can turn weather off
--You can turn weather off; this will put snow and puddles off too
mymonths.use_weather = true
--Leaves change color in the fall.
@ -26,47 +26,30 @@ if minetest.get_modpath("lightning") then
lightning.auto = false
end
local modpath = minetest.get_modpath("mymonths")
local input = io.open(modpath.."/settings.txt", "r")
local input = io.open(modpath .. "/settings.txt", "r")
if input then
dofile(modpath.."/settings.txt")
dofile(modpath .. "/settings.txt")
input:close()
input = nil
else
mymonths.damage = false
mymonths.use_weather = true
mymonths.leaves = true
mymonths.snow_on_ground = true
mymonths.use_puddles = true
end
dofile(minetest.get_modpath("mymonths") .. "/functions.lua")
dofile(minetest.get_modpath("mymonths") .. "/abms.lua")
dofile(minetest.get_modpath("mymonths") .. "/command.lua")
dofile(minetest.get_modpath("mymonths") .. "/months.lua")
dofile(modpath .. "/functions.lua")
dofile(modpath .. "/abms.lua")
dofile(modpath .. "/command.lua")
dofile(modpath .. "/months.lua")
if mymonths.use_weather == true then
dofile(minetest.get_modpath("mymonths").."/weather.lua")
end
if mymonths.grass_change == true then
dofile(minetest.get_modpath("mymonths").."/grass.lua")
end
if mymonths.use_weather == false then
minetest.register_alias("mymonths:puddle", "air")
minetest.register_alias("mymonths:snow_cover_1", "air")
minetest.register_alias("mymonths:snow_cover_2", "air")
minetest.register_alias("mymonths:snow_cover_3", "air")
minetest.register_alias("mymonths:snow_cover_4", "air")
minetest.register_alias("mymonths:snow_cover_5", "air")
dofile(modpath .. "/weather.lua")
else
mymonths.snow_on_ground = false
mymonths.use_puddles = false
end
if mymonths.snow_on_ground == false then
minetest.register_alias("mymonths:snow_cover_1", "air")
minetest.register_alias("mymonths:snow_cover_2", "air")
minetest.register_alias("mymonths:snow_cover_3", "air")
@ -78,23 +61,24 @@ if mymonths.use_puddles == false then
minetest.register_alias("mymonths:puddle", "air")
end
if mymonths.leaves == true then
dofile(minetest.get_modpath("mymonths") .. "/leaves.lua")
if mymonths.grass_change == true then
dofile(modpath .. "/grass.lua")
end
if mymonths.leaves == false then
if mymonths.leaves == true then
dofile(modpath .. "/leaves.lua")
else
minetest.register_alias("mymonths:leaves_pale_green", "default:leaves")
minetest.register_alias("mymonths:leaves_orange", "default:leaves")
minetest.register_alias("mymonths:leaves_red", "default:leaves")
minetest.register_alias("mymonths:sticks_default", "default:leaves")
minetest.register_alias("mymonths:sticks_aspen", "default:aspen_leaves")
minetest.register_alias("mymonths:leaves_yellow_aspen", "default:aspen_leaves")
minetest.register_alias("mymonths:leaves_orange_aspen", "default:aspen_leaves")
minetest.register_alias("mymonths:leaves_red_aspen", "default:aspen_leaves")
end
if mymonths.flowers_die == true then
dofile(minetest.get_modpath("mymonths") .. "/flowers.lua")
end
if minetest.get_modpath("thirsty") then
thirst = true
dofile(modpath .. '/pre-flowers.lua')
dofile(modpath .. "/flowers.lua")
end

View File

@ -135,60 +135,37 @@ minetest.register_abm({
end
})
--apples die in November
-- apples die in November
minetest.register_abm({
nodenames = {'default:apple'},
interval = 15,
chance = 10,
action = function (pos, node, active_object_count, active_object_count_wider)
local nodeu1 = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z})
local nodeu2 = minetest.get_node({x = pos.x, y = pos.y - 2, z = pos.z})
local nodeu3 = minetest.get_node({x = pos.x, y = pos.y - 3, z = pos.z})
local nodeu4 = minetest.get_node({x = pos.x, y = pos.y - 4, z = pos.z})
action = function (pos)
if mymonths.month_counter == 11 then
if nodeu1.name == "air" then
minetest.set_node(pos,{name = 'mymonths:sticks_default'})
local i = 1
repeat
local n = minetest.get_node({x = pos.x, y = pos.y - i, z = pos.z})
if n.name == "air" then
minetest.spawn_item({
x = pos.x,
y = pos.y - 1,
z = pos.z}, 'default:apple')
y = pos.y - i,
z = pos.z},
'default:apple')
minetest.set_node(pos,{name = 'mymonths:sticks_default'})
elseif nodeu2.name == "air" then
minetest.spawn_item({
x = pos.x,
y = pos.y - 2,
z = pos.z}, 'default:apple')
minetest.set_node(pos,{name = 'mymonths:sticks_default'})
elseif nodeu3.name == "air" then
minetest.spawn_item({
x = pos.x,
y = pos.y - 3,
z = pos.z}, 'default:apple')
minetest.set_node(pos,{name = 'mymonths:sticks_default'})
elseif nodeu4.name == "air" then
minetest.spawn_item({
x = pos.x,
y = pos.y - 4,
z = pos.z}, 'default:apple')
minetest.set_node(pos,{name = 'mymonths:sticks_default'})
else
minetest.set_node(pos,{name = 'mymonths:sticks_default'})
end
i = i + 1
until n.name == "air" or i == 4
end
end
})

19
pre-flowers.lua Normal file
View File

@ -0,0 +1,19 @@
mymonths.flowers = {}
if minetest.get_modpath('flowers') then
table.insert(mymonths.flowers,'flowers:dandelion_white')
table.insert(mymonths.flowers,'flowers:dandelion_yellow')
table.insert(mymonths.flowers,'flowers:geranium')
table.insert(mymonths.flowers,'flowers:rose')
table.insert(mymonths.flowers,'flowers:tulip')
table.insert(mymonths.flowers,'flowers:viola')
end
if minetest.get_modpath('bakedclay') then
table.insert(mymonths.flowers,'bakedclay:delphinium')
table.insert(mymonths.flowers,'bakedclay:lazarus')
table.insert(mymonths.flowers,'bakedclay:mannagrass')
table.insert(mymonths.flowers,'bakedclay:thistle')
end
mymonths.flower_number = table.getn(mymonths.flowers)