parent
2b5ebc8b46
commit
14071f3239
2
README
2
README
|
@ -27,6 +27,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.
|
||||
|
||||
|
||||
Chat Commands
|
||||
|
|
6
abms.lua
6
abms.lua
|
@ -1,4 +1,5 @@
|
|||
--Places Snow on ground
|
||||
if mymonths.snow_on_ground == true then
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:leaves","default:dirt","default:dirt_with_grass"},
|
||||
neighbors = {"air","mymonths:puddle"},
|
||||
|
@ -86,6 +87,9 @@ minetest.register_abm({
|
|||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
if mymonths.use_puddles == true then
|
||||
--Makes Puddles when raining
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:dirt","default:dirt_with_grass"},
|
||||
|
@ -119,4 +123,4 @@ minetest.register_abm({
|
|||
end
|
||||
end
|
||||
})
|
||||
|
||||
end
|
||||
|
|
38
command.lua
38
command.lua
|
@ -1,19 +1,34 @@
|
|||
|
||||
--Sets the privs for changing settings
|
||||
minetest.register_privilege("mymonths", {
|
||||
description = "Change the weather",
|
||||
description = "Change the weather and date",
|
||||
give_to_singleplayer = false
|
||||
})
|
||||
|
||||
-- Set weather
|
||||
if mymonths.use_weather == true then
|
||||
minetest.register_chatcommand("setweather", {
|
||||
params = "<mymonths>",
|
||||
description = "Set weather to rain, snow, wind or none",
|
||||
privs = {mymonths = true},
|
||||
func = function(name, param)
|
||||
mymonths.weather = param
|
||||
save_table()
|
||||
if param == "rain" or
|
||||
param == "storm" or
|
||||
param == "snow" or
|
||||
param == "snowstorm" or
|
||||
param == "sandstorm" or
|
||||
param == "hail" or
|
||||
param == "clear" then
|
||||
mymonths.weather = param
|
||||
mymonths.save_table()
|
||||
else
|
||||
minetest.chat_send_player(name,"invalid input - use rain, storm, snow, snowstorm, sandstorm, hail or clear.")
|
||||
return
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
--Set month
|
||||
minetest.register_chatcommand("setmonth", {
|
||||
params = "",
|
||||
|
@ -46,23 +61,25 @@ minetest.register_chatcommand("setmonth", {
|
|||
mymonths.month = "December"
|
||||
end
|
||||
mymonths.month_counter = param
|
||||
save_table()
|
||||
mymonths.save_table()
|
||||
end
|
||||
})
|
||||
--Set Days
|
||||
|
||||
--Set Days
|
||||
minetest.register_chatcommand("setday", {
|
||||
params = "",
|
||||
description = "Set the day of the month",
|
||||
privs = {mymonths = true},
|
||||
func = function(name, param)
|
||||
for day = 1,mymonths.days_per_month do
|
||||
if param >= 15 then return end
|
||||
if param == ""..day then mymonths.day_counter = day end
|
||||
end
|
||||
for day = 1,14 do
|
||||
if tonumber(param) >= 15 then return end
|
||||
if param == day then mymonths.day_counter = day end
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
--Weather
|
||||
if mymonths.use_weather == true then
|
||||
minetest.register_chatcommand("weather", {
|
||||
params = "",
|
||||
description = "Tells player the weather",
|
||||
|
@ -70,6 +87,7 @@ minetest.register_chatcommand("weather", {
|
|||
minetest.chat_send_player(name,"The weather is "..mymonths.weather2)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
--Time and Date
|
||||
minetest.register_chatcommand("date", {
|
||||
|
@ -100,6 +118,8 @@ minetest.register_chatcommand("date", {
|
|||
end
|
||||
|
||||
})
|
||||
|
||||
--Gives list of holidays
|
||||
minetest.register_chatcommand("holidays", {
|
||||
params = "",
|
||||
description = "Say the date in chat",
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
-- Save table to file
|
||||
function mymonths.save_table()
|
||||
local data = mymonths
|
||||
local f, err = io.open(minetest.get_worldpath().."/mymonths_data", "w")
|
||||
if err then return err end
|
||||
f:write(minetest.serialize(data))
|
||||
f:close()
|
||||
end
|
||||
|
||||
-- Reads saved file
|
||||
function mymonths.read_mymonths()
|
||||
local f, err = io.open(minetest.get_worldpath().."/mymonths_data", "r")
|
||||
local data = minetest.deserialize(f:read("*a"))
|
||||
f:close()
|
||||
return data
|
||||
end
|
||||
|
||||
-- Saves the table every 10 seconds
|
||||
local tmr = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
tmr = tmr + dtime;
|
||||
if tmr >= 10 then
|
||||
tmr = 0
|
||||
mymonths.save_table()
|
||||
end
|
||||
end)
|
||||
|
||||
--Check to see if file exists and if not sets default values.
|
||||
local f, err = io.open(minetest.get_worldpath().."/mymonths_data", "r")
|
||||
if f == nil then
|
||||
mymonths.day_speed = 72
|
||||
mymonths.night_speed = 72
|
||||
mymonths.day_counter = 1
|
||||
mymonths.month_counter = 6
|
||||
mymonths.month = "June"
|
||||
mymonths.weather = "none"
|
||||
mymonths.weather2 = "none"
|
||||
mymonths.days_per_month = 14 --Should be 7,14,21 or 28. One week is 7 days. Weeks start on Monday
|
||||
mymonths.day_name = "Monday"
|
||||
else
|
||||
mymonths.day_speed = mymonths.read_mymonths().day_speed
|
||||
mymonths.night_speed = mymonths.read_mymonths().night_speed
|
||||
mymonths.day_counter = mymonths.read_mymonths().day_counter
|
||||
mymonths.month_counter = mymonths.read_mymonths().month_counter
|
||||
mymonths.month = mymonths.read_mymonths().month
|
||||
mymonths.weather = mymonths.read_mymonths().weather
|
||||
mymonths.weather2 = mymonths.read_mymonths().weather2
|
||||
mymonths.days_per_month = mymonths.read_mymonths().days_per_month
|
||||
mymonths.day_name = mymonths.read_mymonths().day_name
|
||||
end
|
258
init.lua
258
init.lua
|
@ -1,203 +1,75 @@
|
|||
function save_table() -- Save table to file
|
||||
local data = mymonths
|
||||
local f, err = io.open(minetest.get_worldpath().."/mymonths_data", "w")
|
||||
if err then return err end
|
||||
f:write(minetest.serialize(data))
|
||||
f:close()
|
||||
end
|
||||
local function read_mymonths() -- Reads saved file
|
||||
local f, err = io.open(minetest.get_worldpath().."/mymonths_data", "r")
|
||||
local data = minetest.deserialize(f:read("*a"))
|
||||
f:close()
|
||||
return data
|
||||
end
|
||||
local tmr = 0
|
||||
|
||||
-- Saves the table every 10 seconds
|
||||
minetest.register_globalstep(function(dtime)
|
||||
tmr = tmr + dtime;
|
||||
if tmr >= 10 then
|
||||
tmr = 0
|
||||
save_table()
|
||||
end
|
||||
end)
|
||||
|
||||
--Settings
|
||||
mymonths = {}
|
||||
|
||||
local morn = 6000
|
||||
local night = 22000
|
||||
local daychange = 1
|
||||
local tseconds = 3
|
||||
local t1 = 52 -- 14 min set to 52
|
||||
local t2 = 60 -- 12 min set to 60
|
||||
local t3 = 72 -- 10 min set to 72
|
||||
local t4 = 90 -- 8 min set to 90
|
||||
local t5 = 120 -- 6 min set to 120
|
||||
--Turn damage on or off. This will make storms and hail cause damage
|
||||
mymonths.damage = false
|
||||
|
||||
--Check to see if file exists and if not sets default values.
|
||||
local f, err = io.open(minetest.get_worldpath().."/mymonths_data", "r")
|
||||
if f == nil then
|
||||
mymonths.day_speed = 72
|
||||
mymonths.night_speed = 72
|
||||
mymonths.day_counter = 1
|
||||
mymonths.month_counter = 6
|
||||
mymonths.month = "June"
|
||||
mymonths.weather = "none"
|
||||
mymonths.weather2 = "none"
|
||||
mymonths.days_per_month = 14 --Should be 7,14,21 or 28. One week is 7 days. Weeks start on Monday
|
||||
mymonths.day_name = "Monday"
|
||||
--You can turn weather off
|
||||
mymonths.use_weather = true
|
||||
|
||||
--Leaves change color in the fall.
|
||||
mymonths.leaves = true
|
||||
|
||||
--Have snow accumulate on the ground
|
||||
mymonths.snow_on_ground = true
|
||||
|
||||
--Puddles appear when raining
|
||||
mymonths.use_puddles = true
|
||||
|
||||
|
||||
local modpath = minetest.get_modpath("mymonths")
|
||||
local input = io.open(modpath.."/settings.txt", "r")
|
||||
if input then
|
||||
dofile(modpath.."/settings.txt")
|
||||
input:close()
|
||||
input = nil
|
||||
else
|
||||
mymonths.day_speed = read_mymonths().day_speed
|
||||
mymonths.night_speed = read_mymonths().night_speed
|
||||
mymonths.day_counter = read_mymonths().day_counter
|
||||
mymonths.month_counter = read_mymonths().month_counter
|
||||
mymonths.month = read_mymonths().month
|
||||
mymonths.weather = read_mymonths().weather
|
||||
mymonths.weather2 = read_mymonths().weather2
|
||||
mymonths.days_per_month = read_mymonths().days_per_month
|
||||
mymonths.day_name = read_mymonths().day_name
|
||||
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")
|
||||
|
||||
if mymonths.use_weather == true then
|
||||
dofile(minetest.get_modpath("mymonths").."/weather.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
|
||||
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")
|
||||
minetest.register_alias("mymonths:snow_cover_4", "air")
|
||||
minetest.register_alias("mymonths:snow_cover_5", "air")
|
||||
end
|
||||
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")
|
||||
end
|
||||
|
||||
if mymonths.leaves == false then
|
||||
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:leaves_sticks", "default:leaves")
|
||||
end
|
||||
|
||||
|
||||
--Sets Month and length of day
|
||||
local timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
local month = mymonths.month
|
||||
local monthn = mymonths.month_counter
|
||||
local day = mymonths.day_counter
|
||||
-- Checks every X seconds
|
||||
timer = timer + dtime
|
||||
if timer < 3 then
|
||||
return
|
||||
end
|
||||
timer = 0
|
||||
--Checks for morning
|
||||
local time_in_seconds = minetest.get_timeofday() * 24000
|
||||
if time_in_seconds >= daychange and
|
||||
time_in_seconds <= daychange + 200 then
|
||||
mymonths.day_counter = mymonths.day_counter + 1
|
||||
if mymonths.day_counter >= mymonths.days_per_month +1 then
|
||||
mymonths.month_counter = mymonths.month_counter + 1
|
||||
end
|
||||
if mymonths.month_counter >= "13" then
|
||||
mymonths.month_counter = "1"
|
||||
mymonths.day_counter = 1
|
||||
end
|
||||
end
|
||||
--Sets time speed in the morning
|
||||
if time_in_seconds >= morn and
|
||||
time_in_seconds <= morn + 200 then
|
||||
minetest.setting_set("time_speed", mymonths.day_speed)
|
||||
minetest.set_timeofday(0.259)
|
||||
minetest.chat_send_all("Good Morning! It is "..mymonths.day_name.." "..month.." "..day)
|
||||
|
||||
--Sets holidays
|
||||
if monthn == "12" and
|
||||
day == 14 then
|
||||
minetest.chat_send_all("It is New Years Eve!")
|
||||
elseif monthn == "1" and
|
||||
day == 1 then
|
||||
minetest.chat_send_all("It is New Years Day!")
|
||||
elseif monthn == "3" and
|
||||
day == 12 then
|
||||
minetest.chat_send_all("It is Friendship Day!")
|
||||
elseif monthn == "6" and
|
||||
day == 5 then
|
||||
minetest.chat_send_all("It is Minetest Day!")
|
||||
elseif monthn == "4" and
|
||||
day == 10 then
|
||||
minetest.chat_send_all("It is Miners Day!")
|
||||
elseif monthn == "8" and
|
||||
day == 12 then
|
||||
minetest.chat_send_all("It is Builders Day!")
|
||||
elseif monthn == "10" and
|
||||
day == 8 then
|
||||
minetest.chat_send_all("It is Harvest Day!")
|
||||
end
|
||||
|
||||
|
||||
--January
|
||||
if mymonths.month_counter == 1 then
|
||||
mymonths.month = "January"
|
||||
mymonths.day_speed = t5
|
||||
mymonths.night_speed = t1
|
||||
--Febuary
|
||||
elseif mymonths.month_counter == 2 then
|
||||
mymonths.month = "February"
|
||||
mymonths.day_speed = t5
|
||||
mymonths.night_speed = t1
|
||||
--March
|
||||
elseif mymonths.month_counter == 3 then
|
||||
mymonths.month = "March"
|
||||
mymonths.day_speed = t4
|
||||
mymonths.night_speed = t2
|
||||
--April
|
||||
elseif mymonths.month_counter == 4 then
|
||||
mymonths.month = "April"
|
||||
mymonths.day_speed = t4
|
||||
mymonths.night_speed = t2
|
||||
--May
|
||||
elseif mymonths.month_counter == 5 then
|
||||
mymonths.month = "May"
|
||||
mymonths.day_speed = t3
|
||||
mymonths.night_speed = t3
|
||||
--June
|
||||
elseif mymonths.month_counter == 6 then
|
||||
mymonths.month = "June"
|
||||
mymonths.day_speed = t3
|
||||
mymonths.night_speed = t3
|
||||
--July
|
||||
elseif mymonths.month_counter == 7 then
|
||||
mymonths.month = "July"
|
||||
mymonths.day_speed = t1
|
||||
mymonths.night_speed = t5
|
||||
--Augest
|
||||
elseif mymonths.month_counter == 8 then
|
||||
mymonths.month = "August"
|
||||
mymonths.day_speed = t1
|
||||
mymonths.night_speed = t5
|
||||
--September
|
||||
elseif mymonths.month_counter == 9 then
|
||||
mymonths.month = "September"
|
||||
mymonths.day_speed = t3
|
||||
mymonths.night_speed = t3
|
||||
--October
|
||||
elseif mymonths.month_counter == 10 then
|
||||
mymonths.month = "October"
|
||||
mymonths.day_speed = t3
|
||||
mymonths.night_speed = t3
|
||||
--November
|
||||
elseif mymonths.month_counter == 11 then
|
||||
mymonths.month = "November"
|
||||
mymonths.day_speed = t4
|
||||
mymonths.night_speed = t2
|
||||
--December
|
||||
elseif mymonths.month_counter == 12 then
|
||||
mymonths.month = "December"
|
||||
mymonths.day_speed = t4
|
||||
mymonths.night_speed = t2
|
||||
end
|
||||
elseif time_in_seconds >= night and
|
||||
time_in_seconds <= night + 200 then
|
||||
minetest.setting_set("time_speed", mymonths.night_speed)
|
||||
minetest.set_timeofday(0.925)
|
||||
end
|
||||
--Set the name of the day
|
||||
local days = {{1,8,"Monday"},{2,9,"Tuesday"},{3,10,"Wednesday"},{4,11,"Thursday"},{5,12,"Friday"},{6,13,"Saturday"},{7,14,"Sunday"},}
|
||||
for i in ipairs(days) do
|
||||
local w1 = days[i][1]
|
||||
local w2 = days[i][2]
|
||||
local dy = days[i][3]
|
||||
if mymonths.day_counter == w1 or
|
||||
mymonths.day_counter == w2 then
|
||||
mymonths.day_name = dy
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
|
||||
dofile(minetest.get_modpath("mymonths").."/weather.lua")
|
||||
dofile(minetest.get_modpath("mymonths").."/abms.lua")
|
||||
dofile(minetest.get_modpath("mymonths").."/leaves.lua")
|
||||
dofile(minetest.get_modpath("mymonths").."/command.lua")
|
||||
|
|
32
leaves.lua
32
leaves.lua
|
@ -1,22 +1,14 @@
|
|||
--Nodes #################
|
||||
local leaves_table = {--name, tex
|
||||
{'pale_green', 'pale_green'}, --first stage
|
||||
{'orange', 'orange'}, --second stage
|
||||
{'red', 'red'}, --third stage
|
||||
{'sticks', 'sticks'}, --after leaves fall
|
||||
{'blooms', 'blooms'}, --Spring!!!
|
||||
}
|
||||
local leaves_table = {'pale_green', 'orange', 'red', 'sticks', 'blooms'}
|
||||
|
||||
for i in ipairs (leaves_table) do
|
||||
local name = leaves_table[i][1]
|
||||
local tex = leaves_table[i][2]
|
||||
for i, name in pairs (leaves_table) do
|
||||
|
||||
minetest.register_node('mymonths:leaves_'..name, {
|
||||
description = name..' leaves',
|
||||
drawtype = 'allfaces_optional',
|
||||
waving = 1,
|
||||
visual_scale = 1.3,
|
||||
tiles = {'mymonths_leaves_'..tex..'.png'},
|
||||
tiles = {'mymonths_leaves_'..name..'.png'},
|
||||
paramtype = 'light',
|
||||
is_ground_content = false,
|
||||
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
|
||||
|
@ -33,11 +25,11 @@ minetest.register_abm({ --leaves changing in September
|
|||
action = function (pos, node, active_object_count, active_object_count_wider)
|
||||
if mymonths.month == 'September' then
|
||||
if node.name == 'default:leaves' then
|
||||
minetest.swap_node(pos, {name = 'mymonths:leaves_pale_green'})
|
||||
minetest.set_node(pos, {name = 'mymonths:leaves_pale_green'})
|
||||
elseif node.name == 'mymonths:leaves_pale_green' then
|
||||
minetest.swap_node(pos, {name = 'mymonths:leaves_orange'})
|
||||
minetest.set_node(pos, {name = 'mymonths:leaves_orange'})
|
||||
elseif node.name == 'mymonths:leaves_orange' then
|
||||
minetest.swap_node(pos, {name = 'mymonths:leaves_red'})
|
||||
minetest.set_node(pos, {name = 'mymonths:leaves_red'})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -49,7 +41,7 @@ minetest.register_abm({ --All leaves should be red in October
|
|||
chance = 1,
|
||||
action = function (pos, node, active_object_count, active_object_count_wider)
|
||||
if mymonths.month == 'October' then
|
||||
minetest.swap_node(pos, {name = 'mymonths:leaves_red'})
|
||||
minetest.set_node(pos, {name = 'mymonths:leaves_red'})
|
||||
end
|
||||
end
|
||||
})
|
||||
|
@ -60,7 +52,7 @@ minetest.register_abm({ --leaves 'falling/dying' in October
|
|||
chance = 10,
|
||||
action = function (pos, node, active_object_count, active_object_count_wider)
|
||||
if mymonths.month == 'October' then
|
||||
minetest.swap_node(pos, {name = 'mymonths:leaves_sticks'})
|
||||
minetest.set_node(pos, {name = 'mymonths:leaves_sticks'})
|
||||
end
|
||||
end
|
||||
})
|
||||
|
@ -71,7 +63,7 @@ minetest.register_abm({ --All leaves should be sticks in November
|
|||
chance = 1,
|
||||
action = function (pos, node, active_object_count, active_object_count_wider)
|
||||
if mymonths.month == 'November' then
|
||||
minetest.swap_node(pos, {name = 'mymonths:leaves_sticks'})
|
||||
minetest.set_node(pos, {name = 'mymonths:leaves_sticks'})
|
||||
end
|
||||
end
|
||||
})
|
||||
|
@ -83,9 +75,9 @@ minetest.register_abm({ --New growth in spring
|
|||
action = function (pos, node, active_object_count, active_object_count_wider)
|
||||
if mymonths.month == 'March' then
|
||||
if node.name == 'mymonths:leaves_sticks' then
|
||||
minetest.swap_node(pos, {name = 'mymonths:leaves_blooms'})
|
||||
minetest.set_node(pos, {name = 'mymonths:leaves_blooms'})
|
||||
elseif node.name == 'mymonths:leaves_blooms' then
|
||||
minetest.swap_node(pos, {name = 'default:leaves'})
|
||||
minetest.set_node(pos, {name = 'default:leaves'})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -97,7 +89,7 @@ minetest.register_abm({ --By April all trees should be back to normal
|
|||
chance = 1,
|
||||
action = function (pos, node, active_object_count, active_object_count_wider)
|
||||
if mymonths.month == 'April' then
|
||||
minetest.swap_node(pos, {name = 'default:leaves'})
|
||||
minetest.set_node(pos, {name = 'default:leaves'})
|
||||
end
|
||||
end
|
||||
})
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
local morn = 6000
|
||||
local night = 22000
|
||||
local daychange = 1
|
||||
local tseconds = 3
|
||||
local t1 = 52 -- 14 min set to 52
|
||||
local t2 = 60 -- 12 min set to 60
|
||||
local t3 = 72 -- 10 min set to 72
|
||||
local t4 = 90 -- 8 min set to 90
|
||||
local t5 = 120 -- 6 min set to 120
|
||||
|
||||
--Sets Month and length of day
|
||||
local timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
local month = mymonths.month
|
||||
local monthn = mymonths.month_counter
|
||||
local day = mymonths.day_counter
|
||||
-- Checks every X seconds
|
||||
timer = timer + dtime
|
||||
if timer < 3 then --do not change because it will effect other values
|
||||
return
|
||||
end
|
||||
timer = 0
|
||||
--Checks for morning
|
||||
local time_in_seconds = minetest.get_timeofday() * 24000
|
||||
if time_in_seconds >= daychange and
|
||||
time_in_seconds <= daychange + 200 then
|
||||
mymonths.day_counter = mymonths.day_counter + 1
|
||||
if mymonths.day_counter >= mymonths.days_per_month +1 then
|
||||
mymonths.month_counter = mymonths.month_counter + 1
|
||||
end
|
||||
if mymonths.month_counter >= "13" then
|
||||
mymonths.month_counter = "1"
|
||||
mymonths.day_counter = 1
|
||||
end
|
||||
end
|
||||
--Sets time speed in the morning
|
||||
if time_in_seconds >= morn and
|
||||
time_in_seconds <= morn + 200 then
|
||||
minetest.setting_set("time_speed", mymonths.day_speed)
|
||||
minetest.set_timeofday(0.259)
|
||||
minetest.chat_send_all("Good Morning! It is "..mymonths.day_name.." "..month.." "..day)
|
||||
|
||||
--Holidays
|
||||
local hol = {
|
||||
{"12", 14, "It is New Years Eve!"},
|
||||
{"1", 1, "It is New Years Day!"},
|
||||
{"3", 12, "It is Friendship Day!"},
|
||||
{"6", 5, "It is Minetest Day!"},
|
||||
{"4", 10, "It is Miners Day!"},
|
||||
{"8", 12, "It is Builders Day!"},
|
||||
{"10", 8, "It is Harvest Day!"},
|
||||
}
|
||||
for i in ipairs(hol) do
|
||||
local h1 = hol[i][1]
|
||||
local h2 = hol[i][2]
|
||||
local h3 = hol[i][3]
|
||||
if monthn == h1 and
|
||||
day == h2 then
|
||||
minetest.chat_send_all(h3)
|
||||
end
|
||||
end
|
||||
|
||||
--Months
|
||||
local mon = {
|
||||
{1, "January", t5,t1},
|
||||
{2, "February", t5,t1},
|
||||
{3, "March", t4,t2},
|
||||
{4, "April", t4,t2},
|
||||
{5, "May", t3,t3},
|
||||
{6, "June", t3,t3},
|
||||
{7, "July", t1,t5},
|
||||
{8, "Augest", t1,t5},
|
||||
{9, "September", t3,t3},
|
||||
{10,"October", t3,t3},
|
||||
{11,"November", t4,t2},
|
||||
{12,"December", t4,t2},
|
||||
}
|
||||
for i in ipairs(mon) do
|
||||
local m1 = mon[i][1]
|
||||
local m2 = mon[i][2]
|
||||
local m3 = mon[i][3]
|
||||
local m4 = mon[i][4]
|
||||
if mymonths.month_counter == m1 then
|
||||
mymonths.month = m2
|
||||
mymonths.day_speed = m3
|
||||
mymonths.night_speed = m4
|
||||
end
|
||||
end
|
||||
|
||||
elseif time_in_seconds >= night and
|
||||
time_in_seconds <= night + 200 then
|
||||
minetest.setting_set("time_speed", mymonths.night_speed)
|
||||
minetest.set_timeofday(0.925)
|
||||
end
|
||||
|
||||
--Set the name of the day
|
||||
local days = { {1,8,"Monday"},
|
||||
{2,9,"Tuesday"},
|
||||
{3,10,"Wednesday"},
|
||||
{4,11,"Thursday"},
|
||||
{5,12,"Friday"},
|
||||
{6,13,"Saturday"},
|
||||
{7,14,"Sunday"},}
|
||||
for i in ipairs(days) do
|
||||
local w1 = days[i][1]
|
||||
local w2 = days[i][2]
|
||||
local dy = days[i][3]
|
||||
if mymonths.day_counter == w1 or
|
||||
mymonths.day_counter == w2 then
|
||||
mymonths.day_name = dy
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
--Turn damage on or off. This will make storms and hail cause damage
|
||||
|
||||
mymonths.damage = false
|
||||
|
||||
------------------------------------------------------------------------
|
||||
--You can turn weather off
|
||||
|
||||
mymonths.use_weather = true
|
||||
|
||||
------------------------------------------------------------------------
|
||||
--Leaves change color in the fall.
|
||||
|
||||
mymonths.leaves = true
|
||||
|
||||
------------------------------------------------------------------------
|
||||
--Have snow accumulate on the ground
|
||||
|
||||
mymonths.snow_on_ground = true
|
||||
|
||||
------------------------------------------------------------------------
|
||||
--Puddles appear when raining
|
||||
|
||||
mymonths.use_puddles = true
|
33
weather.lua
33
weather.lua
|
@ -15,8 +15,8 @@ local month = mymonths.month_counter
|
|||
mymonths.weather == "snowstorm" or
|
||||
mymonths.weather == "sandstorm" or
|
||||
mymonths.weather == "hail" then
|
||||
if math.random(1, 50) == 1 then
|
||||
mymonths.weather = "none"
|
||||
if math.random(1, 500) == 1 then
|
||||
mymonths.weather = "clear"
|
||||
end
|
||||
else
|
||||
|
||||
|
@ -105,6 +105,7 @@ end)
|
|||
addvectors = function (v1, v2)
|
||||
return {x=v1.x+v2.x, y=v1.y+v2.y, z=v1.z+v2.z}
|
||||
end
|
||||
|
||||
hp_t = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
hp_t = hp_t + dtime
|
||||
|
@ -158,20 +159,23 @@ hp_t = hp_t + dtime
|
|||
--changes weather based on biome
|
||||
--Jungle
|
||||
if biome_jungle ~= nil then
|
||||
if mymonths.weather == "snow" or
|
||||
mymonths.weather == "hail" then
|
||||
if mymonths.weather == "snow" then
|
||||
mymonths.weather2 = "rain"
|
||||
elseif mymonths.weather == "snowstorm" then
|
||||
elseif mymonths.weather == "snowstorm" or
|
||||
mymonths.weather == "hail" then
|
||||
mymonths.weather2 = "storm"
|
||||
end
|
||||
--Desert
|
||||
elseif biome_desert ~= nil then
|
||||
if mymonths.weather == "snow" or
|
||||
mymonths.weather == "snowstorm" or
|
||||
mymonths.weather == "storm" or
|
||||
mymonths.weather == "hail" or
|
||||
mymonths.weather == "rain" then
|
||||
mymonths.weather2 = "clear"
|
||||
elseif mymonths.weather == "snowstorm" or
|
||||
mymonths.weather == "hail" or
|
||||
mymonths.weather == "storm" then
|
||||
mymonths.weather2 = "sandstorm"
|
||||
end
|
||||
--Snow
|
||||
elseif biome_snow ~= nil then
|
||||
if mymonths.weather == "rain" then
|
||||
mymonths.weather2 = "snow"
|
||||
|
@ -194,8 +198,8 @@ hp_t = hp_t + dtime
|
|||
vertical = true,
|
||||
texture = "weather_rain_dark.png",
|
||||
playername = name})
|
||||
|
||||
if minetest.get_node_light({x=ppos.x,y=ppos.y+1,z=ppos.z}, 0.5) == 15 then
|
||||
if minetest.get_node_light({x=ppos.x,y=ppos.y+1,z=ppos.z}, 0.5) == 15 and
|
||||
mymonths.damage == true then
|
||||
if hp_t >=15 then
|
||||
player:set_hp(hp-1)
|
||||
hp_t = 0
|
||||
|
@ -266,7 +270,8 @@ hp_t = hp_t + dtime
|
|||
texture = "weather_snow.png",
|
||||
playername = name})
|
||||
|
||||
if minetest.get_node_light({x=ppos.x,y=ppos.y+1,z=ppos.z}, 0.5) == 15 then
|
||||
if minetest.get_node_light({x=ppos.x,y=ppos.y+1,z=ppos.z}, 0.5) == 15 and
|
||||
mymonths.damage == true then
|
||||
if hp_t >=15 then
|
||||
player:set_hp(hp-1)
|
||||
hp_t = 0
|
||||
|
@ -285,7 +290,8 @@ hp_t = hp_t + dtime
|
|||
texture = "weather_sand.png",
|
||||
playername = name})
|
||||
|
||||
if minetest.get_node_light({x=ppos.x,y=ppos.y+1,z=ppos.z}, 0.5) == 15 then
|
||||
if minetest.get_node_light({x=ppos.x,y=ppos.y+1,z=ppos.z}, 0.5) == 15 and
|
||||
mymonths.damage == true then
|
||||
if hp_t >=15 then
|
||||
player:set_hp(hp-1)
|
||||
hp_t = 0
|
||||
|
@ -304,7 +310,8 @@ hp_t = hp_t + dtime
|
|||
texture = "weather_hail.png",
|
||||
playername = name})
|
||||
|
||||
if minetest.get_node_light({x=ppos.x,y=ppos.y+1,z=ppos.z}, 0.5) == 15 then
|
||||
if minetest.get_node_light({x=ppos.x,y=ppos.y+1,z=ppos.z}, 0.5) == 15 and
|
||||
mymonths.damage == true then
|
||||
if hp_t >=15 then
|
||||
player:set_hp(hp-1)
|
||||
hp_t = 0
|
||||
|
|
Loading…
Reference in New Issue