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

18
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 Mymonths is licenced as DWYWPL
@ -13,25 +13,25 @@ by Jeija
- Rain / Snow: CC-BY-SA 3.0, credit goes to TeddyDesTodes, from his weather branch at https://github.com/TeddyDesTodes/minetest/tree/weather - Rain / Snow: CC-BY-SA 3.0, credit goes to TeddyDesTodes, from his weather branch at https://github.com/TeddyDesTodes/minetest/tree/weather
- Sound Effects: - Sound Effects:
- mymonths_rain & mymonths_rain1: CC0 by Q.K. - mymonths_rain & mymonths_rain1: CC0 by Q.K.
This mod adds months, weeks and days to Minetest.
A Minetest year has 12 months with 2 weeks per month. Each week has 7 days.
The weather is depended on the time of year. If it is winter then it will snow spring has rain etc. This mod adds months, weeks and days to Minetest.
Leaves turn color in the fall and the the tree will have no leaves or apples through the winter. A Minetest year has 12 months with 2 weeks per month. Each week has 7 days.
The weather is depended on the time of year. If it is winter then it will snow spring has rain etc.
Leaves turn color in the fall and the the tree will have no leaves or apples through the winter.
The leaves grow back in the spring and the apples later in the year. The leaves grow back in the spring and the apples later in the year.
Acacia trees will bloom in January Acacia trees will bloom in January
The desert and savannah biomes do not get rain or snow but do have sand storms. The desert and savannah biomes do not get rain or snow but do have sand storms.
The snow biomes do not get rain. The snow biomes do not get rain.
The trees in these biomes do not loose their leaves. 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. 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, 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 recieve damage. You need to cover yourself so you do not recieve damage. sandstorm or hail you will receive damage. You need to cover yourself so you do not receive damage.
Chat Commands Chat Commands

View File

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

View File

@ -2,7 +2,7 @@
-- Flowers die in late fall -- Flowers die in late fall
minetest.register_abm({ minetest.register_abm({
nodenames = {'group:flower'}, nodenames = {'group:flower'},
interval = 10, interval = 10,
chance = 10, chance = 10,
action = function (pos) action = function (pos)
@ -22,7 +22,10 @@ minetest.register_abm({
interval = 240, interval = 240,
chance = 100, chance = 100,
action = function (pos) action = function (pos, node)
if node.name == 'default:desert_sand' then
return
end
-- return if not march or april -- return if not march or april
if mymonths.month_counter ~= 3 if mymonths.month_counter ~= 3
@ -30,44 +33,20 @@ minetest.register_abm({
return return
end end
local pos0 = {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 + 4, 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") local flowers = minetest.find_nodes_in_area(pos0, pos1, "group:flower")
if #flowers > 2 then if #flowers > 1 then
return return
end end
pos.y = pos.y + 1 pos.y = pos.y + 1
if minetest.get_node(pos).name == 'air' then if minetest.get_node(pos).name == 'air' then
local key = math.random(1, mymonths.flower_number)
local key = math.random(1, 6) local placed_flower = mymonths.flowers[key]
minetest.set_node(pos, {name = placed_flower})
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
end end
end end
}) })

View File

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

View File

@ -1,10 +1,10 @@
--Settings --Settings
mymonths = {} 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 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 mymonths.use_weather = true
--Leaves change color in the fall. --Leaves change color in the fall.
@ -22,79 +22,63 @@ mymonths.flowers_die = true
--Grass changes color in fall, and spring --Grass changes color in fall, and spring
mymonths.grass_change = true mymonths.grass_change = true
if minetest.get_modpath("lightning") then if minetest.get_modpath("lightning") then
lightning.auto = false lightning.auto = false
end end
local modpath = minetest.get_modpath("mymonths") 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 if input then
dofile(modpath.."/settings.txt") dofile(modpath .. "/settings.txt")
input:close() input:close()
input = nil input = nil
else
mymonths.damage = false
mymonths.use_weather = true
mymonths.leaves = true
mymonths.snow_on_ground = true
mymonths.use_puddles = true
end end
dofile(minetest.get_modpath("mymonths") .. "/functions.lua") dofile(modpath .. "/functions.lua")
dofile(minetest.get_modpath("mymonths") .. "/abms.lua") dofile(modpath .. "/abms.lua")
dofile(minetest.get_modpath("mymonths") .. "/command.lua") dofile(modpath .. "/command.lua")
dofile(minetest.get_modpath("mymonths") .. "/months.lua") dofile(modpath .. "/months.lua")
if mymonths.use_weather == true then if mymonths.use_weather == true then
dofile(minetest.get_modpath("mymonths").."/weather.lua") dofile(modpath .. "/weather.lua")
end else
mymonths.snow_on_ground = false
if mymonths.grass_change == true then mymonths.use_puddles = false
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")
end end
if mymonths.snow_on_ground == false then if mymonths.snow_on_ground == false then
minetest.register_alias("mymonths:snow_cover_1", "air")
minetest.register_alias("mymonths:snow_cover_1", "air") minetest.register_alias("mymonths:snow_cover_2", "air")
minetest.register_alias("mymonths:snow_cover_2", "air") minetest.register_alias("mymonths:snow_cover_3", "air")
minetest.register_alias("mymonths:snow_cover_3", "air") minetest.register_alias("mymonths:snow_cover_4", "air")
minetest.register_alias("mymonths:snow_cover_4", "air") minetest.register_alias("mymonths:snow_cover_5", "air")
minetest.register_alias("mymonths:snow_cover_5", "air")
end end
if mymonths.use_puddles == false then if mymonths.use_puddles == false then
minetest.register_alias("mymonths:puddle", "air") minetest.register_alias("mymonths:puddle", "air")
end
if mymonths.grass_change == true then
dofile(modpath .. "/grass.lua")
end end
if mymonths.leaves == true then if mymonths.leaves == true then
dofile(minetest.get_modpath("mymonths") .. "/leaves.lua") dofile(modpath .. "/leaves.lua")
end else
minetest.register_alias("mymonths:leaves_pale_green", "default:leaves")
if mymonths.leaves == false then minetest.register_alias("mymonths:leaves_orange", "default:leaves")
minetest.register_alias("mymonths:leaves_red", "default:leaves")
minetest.register_alias("mymonths:leaves_pale_green", "default:leaves") minetest.register_alias("mymonths:sticks_default", "default:leaves")
minetest.register_alias("mymonths:leaves_orange", "default:leaves") minetest.register_alias("mymonths:sticks_aspen", "default:aspen_leaves")
minetest.register_alias("mymonths:leaves_red", "default:leaves") minetest.register_alias("mymonths:leaves_yellow_aspen", "default:aspen_leaves")
minetest.register_alias("mymonths:sticks_default", "default:leaves") minetest.register_alias("mymonths:leaves_orange_aspen", "default:aspen_leaves")
minetest.register_alias("mymonths:sticks_aspen", "default:aspen_leaves") minetest.register_alias("mymonths:leaves_red_aspen", "default:aspen_leaves")
end end
if mymonths.flowers_die == true then if mymonths.flowers_die == true then
dofile(minetest.get_modpath("mymonths") .. "/flowers.lua") dofile(modpath .. '/pre-flowers.lua')
end dofile(modpath .. "/flowers.lua")
if minetest.get_modpath("thirsty") then
thirst = true
end end

View File

@ -24,7 +24,7 @@ for i, name in pairs(leaves_table) do
end end
for i, name in pairs(sticks_table) do for i, name in pairs(sticks_table) do
minetest.register_node('mymonths:sticks_' .. name, { minetest.register_node('mymonths:sticks_' .. name, {
description = 'Sticks', description = 'Sticks',
drawtype = 'allfaces_optional', drawtype = 'allfaces_optional',
@ -85,7 +85,7 @@ minetest.register_abm({
--leaves 'falling/dying' in October --leaves 'falling/dying' in October
minetest.register_abm({ minetest.register_abm({
nodenames = {'mymonths:leaves_red', 'mymonths:leaves_red_aspen'}, nodenames = {'mymonths:leaves_red', 'mymonths:leaves_red_aspen'},
interval = 60, interval = 60,
chance = 40, chance = 40,
action = function (pos, node, active_object_count, active_object_count_wider) action = function (pos, node, active_object_count, active_object_count_wider)
@ -107,7 +107,7 @@ minetest.register_abm({
--New growth in spring --New growth in spring
minetest.register_abm({ minetest.register_abm({
nodenames = {'mymonths:sticks_default', 'mymonths:leaves_blooms', 'mymonths:sticks_aspen', 'mymonths:leaves_aspen_blooms'}, nodenames = {'mymonths:sticks_default', 'mymonths:leaves_blooms', 'mymonths:sticks_aspen', 'mymonths:leaves_aspen_blooms'},
interval = 60, interval = 60,
chance = 40, chance = 40,
action = function (pos, node, active_object_count, active_object_count_wider) action = function (pos, node, active_object_count, active_object_count_wider)
@ -135,62 +135,39 @@ minetest.register_abm({
end end
}) })
--apples die in November -- apples die in November
minetest.register_abm({ minetest.register_abm({
nodenames = {'default:apple'}, nodenames = {'default:apple'},
interval = 15, interval = 15,
chance = 10, chance = 10,
action = function (pos)
action = function (pos, node, active_object_count, active_object_count_wider) if mymonths.month_counter == 11 then
local nodeu1 = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z}) minetest.set_node(pos,{name = 'mymonths:sticks_default'})
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})
if mymonths.month_counter == 11 then local i = 1
if nodeu1.name == "air" then repeat
minetest.spawn_item({ local n = minetest.get_node({x = pos.x, y = pos.y - i, z = pos.z})
x = pos.x,
y = pos.y - 1,
z = pos.z}, 'default:apple')
minetest.set_node(pos,{name = 'mymonths:sticks_default'}) if n.name == "air" then
elseif nodeu2.name == "air" then minetest.spawn_item({
x = pos.x,
y = pos.y - i,
z = pos.z},
'default:apple')
minetest.spawn_item({ end
x = pos.x,
y = pos.y - 2,
z = pos.z}, 'default:apple')
minetest.set_node(pos,{name = 'mymonths:sticks_default'}) i = i + 1
elseif nodeu3.name == "air" then until n.name == "air" or i == 4
minetest.spawn_item({ end
x = pos.x, end
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
end
end
}) })
@ -637,7 +614,7 @@ minetest.register_lbm({
if day >= 1 if day >= 1
and day <=7 then and day <=7 then
if n == 'mymonths:sticks_default' if n == 'mymonths:sticks_default'
or n == 'default:leaves' or n == 'default:leaves'
or n == 'mymonths:leaves_pale_green' then or n == 'mymonths:leaves_pale_green' then
@ -664,7 +641,7 @@ minetest.register_lbm({
if day >= 1 if day >= 1
and day <=7 then and day <=7 then
if n == 'mymonths:sticks_aspen' if n == 'mymonths:sticks_aspen'
or n == 'mymonths:leaves_yellow_aspen' or n == 'mymonths:leaves_yellow_aspen'
or n == 'mymonths:leaves_aspen_blooms' or n == 'mymonths:leaves_aspen_blooms'
or n == 'default:aspen_leaves' then or n == 'default:aspen_leaves' then

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)