parent
5372b0ceb3
commit
36af430a31
49
abms.lua
49
abms.lua
|
@ -3,24 +3,21 @@ minetest.register_abm({
|
|||
nodenames = {"group:leaves","default:dirt","default:dirt_with_grass"},
|
||||
neighbors = {"air","mymonths:puddle"},
|
||||
interval = 5.0,
|
||||
chance = 20,
|
||||
chance = 40,
|
||||
action = function (pos, node, active_object_count, active_object_count_wider)
|
||||
local na = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
if mymonths.weather2 == "snow" and
|
||||
math.random(1,8) == 1 then
|
||||
local na = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
if minetest.get_node_light({x=pos.x,y=pos.y+1,z=pos.z}, 0.5) == 15
|
||||
and na.name == "air" then
|
||||
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name="mymonths:snow_cover_1"})
|
||||
elseif minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}) == "mymonths:puddle" then
|
||||
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name="mymonths:snow_cover_1"})
|
||||
math.random(1,4) == 1 then
|
||||
if minetest.get_node_light({x=pos.x,y=pos.y+1,z=pos.z}, 0.5) == 15 and na.name == "air" then
|
||||
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name="mymonths:snow_cover_1"})
|
||||
elseif minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}) == "mymonths:puddle" then
|
||||
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name="mymonths:snow_cover_1"})
|
||||
end
|
||||
elseif mymonths.weather2 == "snowstorm" then
|
||||
local na = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
if minetest.get_node_light({x=pos.x,y=pos.y+1,z=pos.z}, 0.5) == 15
|
||||
and na.name == "air" then
|
||||
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name="mymonths:snow_cover_1"})
|
||||
elseif minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}) == "mymonths:puddle" then
|
||||
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name="mymonths:snow_cover_1"})
|
||||
if minetest.get_node_light({x=pos.x,y=pos.y+1,z=pos.z}, 0.5) == 15 and na.name == "air" then
|
||||
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name="mymonths:snow_cover_1"})
|
||||
elseif minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}) == "mymonths:puddle" then
|
||||
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name="mymonths:snow_cover_1"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -30,10 +27,10 @@ minetest.register_abm({
|
|||
nodenames = {"mymonths:snow_cover_1","mymonths:snow_cover_2","mymonths:snow_cover_3","mymonths:snow_cover_4"},
|
||||
neighbors = {"default:dirt","default:dirt_with_grass"},
|
||||
interval = 5.0,
|
||||
chance = 20,
|
||||
chance = 40,
|
||||
action = function (pos, node, active_object_count, active_object_count_wider)
|
||||
if mymonths.weather2 == "snow" and
|
||||
math.random(1,8) == 1 then
|
||||
math.random(1,4) == 1 then
|
||||
if node.name == "mymonths:snow_cover_1" then
|
||||
minetest.set_node(pos,{name = "mymonths:snow_cover_2"})
|
||||
elseif node.name == "mymonths:snow_cover_2" then
|
||||
|
@ -60,11 +57,13 @@ minetest.register_abm({
|
|||
minetest.register_abm({
|
||||
nodenames = {"mymonths:snow_cover_1","mymonths:snow_cover_2","mymonths:snow_cover_3","mymonths:snow_cover_4","mymonths:snow_cover_5"},
|
||||
interval = 10.0,
|
||||
chance = 80,
|
||||
chance = 1,
|
||||
action = function (pos, node, active_object_count, active_object_count_wider)
|
||||
if mymonths.month_counter ~= 12 or
|
||||
mymonths.month_counter ~= 1 or
|
||||
mymonths.month_counter ~= 2 then
|
||||
local ran = math.random(1,100)
|
||||
if ran == 1 then
|
||||
if mymonths.month_counter ~= "12" or
|
||||
mymonths.month_counter ~= "1" or
|
||||
mymonths.month_counter ~= "2" then
|
||||
if node.name == "mymonths:snow_cover_2" then
|
||||
minetest.set_node(pos,{name = "mymonths:snow_cover_1"})
|
||||
elseif node.name == "mymonths:snow_cover_3" then
|
||||
|
@ -75,13 +74,16 @@ minetest.register_abm({
|
|||
minetest.set_node(pos,{name = "mymonths:snow_cover_4"})
|
||||
elseif node.name == "mymonths:snow_cover_1" then
|
||||
local nu = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
|
||||
local ran = math.random(1,10)
|
||||
if ran == 1 and nu.name == "default:dirt_with_grass" then
|
||||
minetest.set_node(pos,{name = "mymonths:puddle"})
|
||||
else minetest.remove_node(pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if mymonths.month_counter == "6" then --removes snow if month is june
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end
|
||||
})
|
||||
--Makes Puddles when raining
|
||||
|
@ -89,14 +91,13 @@ minetest.register_abm({
|
|||
nodenames = {"default:dirt","default:dirt_with_grass"},
|
||||
neighbors = {"default:air"},
|
||||
interval = 10.0,
|
||||
chance = 5000,
|
||||
chance = 50,
|
||||
action = function (pos, node, active_object_count, active_object_count_wider)
|
||||
if mymonths.weather2 == "rain" then
|
||||
local na = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
local nn = minetest.find_node_near(pos, 20, "mymonths:puddle")
|
||||
if nn == nil then
|
||||
if minetest.get_node_light({x=pos.x,y=pos.y+1,z=pos.z}, 0.5) == 15
|
||||
and na.name == "air" then
|
||||
if minetest.get_node_light({x=pos.x,y=pos.y+1,z=pos.z}, 0.5) == 15 and na.name == "air" then
|
||||
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name="mymonths:puddle"})
|
||||
end
|
||||
end
|
||||
|
|
26
command.lua
26
command.lua
|
@ -1,14 +1,12 @@
|
|||
minetest.register_privilege("weather", {
|
||||
description = "Change the weather",
|
||||
give_to_singleplayer = false
|
||||
})
|
||||
|
||||
--Sets the privs for changing settings
|
||||
minetest.register_privilege("mymonths", {
|
||||
description = "Change the weather",
|
||||
give_to_singleplayer = false
|
||||
})
|
||||
-- Set weather
|
||||
minetest.register_chatcommand("setweather", {
|
||||
params = "<weather>",
|
||||
params = "<mymonths>",
|
||||
description = "Set weather to rain, snow, wind or none",
|
||||
privs = {mymonths = true},
|
||||
func = function(name, param)
|
||||
|
@ -64,21 +62,14 @@ minetest.register_chatcommand("setday", {
|
|||
end
|
||||
})
|
||||
--Weather
|
||||
-- Set weather
|
||||
minetest.register_chatcommand("w", {
|
||||
minetest.register_chatcommand("weather", {
|
||||
params = "",
|
||||
description = "Set weather to rain, snow, wind or none",
|
||||
func = function(name, param)
|
||||
minetest.chat_send_player(name,"The weather is "..mymonths.weather)
|
||||
end
|
||||
})
|
||||
minetest.register_chatcommand("w2", {
|
||||
params = "",
|
||||
description = "Set weather to rain, snow, wind or none",
|
||||
description = "Tells player the weather",
|
||||
func = function(name, param)
|
||||
minetest.chat_send_player(name,"The weather is "..mymonths.weather2)
|
||||
end
|
||||
})
|
||||
|
||||
--Time and Date
|
||||
minetest.register_chatcommand("date", {
|
||||
params = "",
|
||||
|
@ -102,12 +93,9 @@ minetest.register_chatcommand("date", {
|
|||
if th == 0 then th = 12 end
|
||||
else
|
||||
ampm = "am"
|
||||
print(th)
|
||||
if th == 0 or th == "" then th = 12 end
|
||||
end
|
||||
--
|
||||
minetest.chat_send_player(name,"The time is "..th..":"..mi.." "..ampm.." on "..mymonths.month.." "..mymonths.day_counter)
|
||||
|
||||
minetest.chat_send_player(name,"The time is "..th..":"..mi.." "..ampm.." on "..mymonths.day_name.." "..mymonths.month.." "..mymonths.day_counter)
|
||||
end
|
||||
|
||||
})
|
||||
|
|
148
init.lua
148
init.lua
|
@ -1,17 +1,19 @@
|
|||
function save_table()
|
||||
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()
|
||||
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
|
||||
|
@ -19,8 +21,10 @@ minetest.register_globalstep(function(dtime)
|
|||
save_table()
|
||||
end
|
||||
end)
|
||||
|
||||
mymonths = {}
|
||||
local days_per_month = 15
|
||||
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"
|
||||
local morn = 6000
|
||||
local night = 22000
|
||||
local tseconds = 3
|
||||
|
@ -29,6 +33,8 @@ 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
|
||||
|
||||
--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
|
||||
|
@ -49,7 +55,7 @@ mymonths.weather2 = "none"
|
|||
end
|
||||
|
||||
|
||||
|
||||
--Sets Month and length of day
|
||||
local timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
-- Checks every X seconds
|
||||
|
@ -65,7 +71,7 @@ minetest.register_globalstep(function(dtime)
|
|||
minetest.setting_set("time_speed", mymonths.day_speed)
|
||||
mymonths.day_counter = mymonths.day_counter + 1
|
||||
minetest.set_timeofday(0.259)
|
||||
if mymonths.day_counter >= days_per_month +1 then
|
||||
if mymonths.day_counter >= mymonths.days_per_month +1 then
|
||||
mymonths.month_counter = mymonths.month_counter + 1
|
||||
if mymonths.month_counter >= 13 then
|
||||
mymonths.month_counter = 1
|
||||
|
@ -77,179 +83,93 @@ minetest.register_globalstep(function(dtime)
|
|||
mymonths.month = "January"
|
||||
mymonths.day_speed = t5
|
||||
mymonths.night_speed = t1
|
||||
minetest.chat_send_all("The date is "..mymonths.month.." "..mymonths.day_counter)
|
||||
--February
|
||||
--Febuary
|
||||
elseif mymonths.month_counter == 2 then
|
||||
mymonths.month = "February"
|
||||
mymonths.day_speed = t5
|
||||
mymonths.night_speed = t1
|
||||
minetest.chat_send_all("The date is "..mymonths.month.." "..mymonths.day_counter)
|
||||
--March
|
||||
elseif mymonths.month_counter == 3 then
|
||||
mymonths.month = "March"
|
||||
mymonths.day_speed = t4
|
||||
mymonths.night_speed = t2
|
||||
minetest.chat_send_all("The date is "..mymonths.month.." "..mymonths.day_counter)
|
||||
--April
|
||||
elseif mymonths.month_counter == 4 then
|
||||
mymonths.month = "April"
|
||||
mymonths.day_speed = t4
|
||||
mymonths.night_speed = t2
|
||||
minetest.chat_send_all("The date is "..mymonths.month.." "..mymonths.day_counter)
|
||||
--May
|
||||
elseif mymonths.month_counter == 5 then
|
||||
mymonths.month = "May"
|
||||
mymonths.day_speed = t3
|
||||
mymonths.night_speed = t3
|
||||
minetest.chat_send_all("The date is "..mymonths.month.." "..mymonths.day_counter)
|
||||
--June
|
||||
elseif mymonths.month_counter == 6 then
|
||||
mymonths.month = "June"
|
||||
mymonths.day_speed = t3
|
||||
mymonths.night_speed = t3
|
||||
minetest.chat_send_all("The date is "..mymonths.month.." "..mymonths.day_counter)
|
||||
--July
|
||||
elseif mymonths.month_counter == 7 then
|
||||
mymonths.month = "July"
|
||||
mymonths.day_speed = t1
|
||||
mymonths.night_speed = t5
|
||||
minetest.chat_send_all("The date is "..mymonths.month.." "..mymonths.day_counter)
|
||||
--August
|
||||
--Augest
|
||||
elseif mymonths.month_counter == 8 then
|
||||
mymonths.month = "August"
|
||||
mymonths.day_speed = t1
|
||||
mymonths.night_speed = t5
|
||||
minetest.chat_send_all("The date is "..mymonths.month.." "..mymonths.day_counter)
|
||||
--September
|
||||
elseif mymonths.month_counter == 9 then
|
||||
mymonths.month = "September"
|
||||
mymonths.day_speed = t3
|
||||
mymonths.night_speed = t3
|
||||
minetest.chat_send_all("The date is "..mymonths.month.." "..mymonths.day_counter)
|
||||
--October
|
||||
elseif mymonths.month_counter == 10 then
|
||||
mymonths.month = "October"
|
||||
mymonths.day_speed = t3
|
||||
mymonths.night_speed = t3
|
||||
minetest.chat_send_all("The date is "..mymonths.month.." "..mymonths.day_counter)
|
||||
--November
|
||||
elseif mymonths.month_counter == 11 then
|
||||
mymonths.month = "November"
|
||||
mymonths.day_speed = t4
|
||||
mymonths.night_speed = t2
|
||||
minetest.chat_send_all("The date is "..mymonths.month.." "..mymonths.day_counter)
|
||||
--December
|
||||
elseif mymonths.month_counter == 12 then
|
||||
mymonths.month = "December"
|
||||
mymonths.day_speed = t4
|
||||
mymonths.night_speed = t2
|
||||
minetest.chat_send_all("The date is "..mymonths.month.." "..mymonths.day_counter)
|
||||
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
|
||||
|
||||
end)
|
||||
minetest.register_globalstep(function(dtime)
|
||||
if mymonths.weather == "rain" or mymonths.weather == "snow" then
|
||||
if math.random(1, 10000) == 1 then
|
||||
mymonths.weather = "none"
|
||||
save_table()
|
||||
end
|
||||
else
|
||||
if mymonths.month_counter == 1 then--January
|
||||
if math.random(1, 10000) == 1 then
|
||||
mymonths.weather = "snow"
|
||||
minetest.chat_send_all("Looks like snow is on it's way")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 2 then--February
|
||||
if math.random(1, 10000) == 1 then
|
||||
mymonths.weather = "snow"
|
||||
minetest.chat_send_all("Looks like snow is on it's way")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 3 then --March
|
||||
if math.random(1, 10000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
elseif math.random(1, 25000) == 2 then
|
||||
mymonths.weather = "snow"
|
||||
minetest.chat_send_all("Looks like snow is on it's way")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 4 then --April
|
||||
if math.random(1, 10000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 5 then --May
|
||||
if math.random(1, 15000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 6 then --June
|
||||
if math.random(1, 20000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
elseif math.random(1, 50000) == 1 then
|
||||
mymonths.weather = "storm"
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 7 then --July
|
||||
if math.random(1, 50000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 8 then --August
|
||||
if math.random(1, 50000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 9 then --September
|
||||
if math.random(1, 15000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 10 then --October
|
||||
if math.random(1, 10000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 11 then --November
|
||||
if math.random(1, 10000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
elseif math.random(1, 20000) == 2 then
|
||||
mymonths.weather = "snow"
|
||||
minetest.chat_send_all("Looks like snow is on it's way")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 12 then --December
|
||||
if math.random(1, 25000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
elseif math.random(1, 10000) == 1 then
|
||||
mymonths.weather = "snow"
|
||||
minetest.chat_send_all("Looks like snow is on it's way")
|
||||
save_table()
|
||||
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")
|
||||
--dofile(minetest.get_modpath("mymonths").."/days.lua")
|
||||
|
|
307
weather.lua
307
weather.lua
|
@ -1,92 +1,184 @@
|
|||
|
||||
--Sets the weather types for each month
|
||||
local t = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
local month = mymonths.month_counter
|
||||
t = t + dtime
|
||||
if t < 5 then
|
||||
return
|
||||
end
|
||||
t = 0
|
||||
|
||||
if mymonths.weather == "rain" or
|
||||
mymonths.weather == "storm" or
|
||||
mymonths.weather == "snow" or
|
||||
mymonths.weather == "snowstorm" then
|
||||
if math.random(1, 50) == 1 then
|
||||
mymonths.weather = "none"
|
||||
end
|
||||
else
|
||||
|
||||
if month == "1" then--January
|
||||
if math.random(1, 100) == 1 then
|
||||
mymonths.weather = "snow"
|
||||
elseif math.random(1, 500) == 1 then
|
||||
mymonths.weather = "snowstorm"
|
||||
end
|
||||
elseif month == "2" then--Febuary
|
||||
if math.random(1, 100) == 1 then
|
||||
mymonths.weather = "snow"
|
||||
elseif math.random(1, 500) == 1 then
|
||||
mymonths.weather = "snowstorm"
|
||||
end
|
||||
elseif month == "3" then --March
|
||||
if math.random(1, 100) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
elseif math.random(1, 250) == 2 then
|
||||
mymonths.weather = "snow"
|
||||
end
|
||||
elseif month == "4" then --April
|
||||
if math.random(1, 100) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
end
|
||||
elseif month == "5" then --May
|
||||
if math.random(1, 150) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
elseif math.random(1, 500) == 1 then
|
||||
mymonths.weather = "storm"
|
||||
end
|
||||
elseif month == "6" then --June
|
||||
if math.random(1, 200) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
elseif math.random(1, 500) == 1 then
|
||||
mymonths.weather = "storm"
|
||||
end
|
||||
elseif month == "7" then --July
|
||||
if math.random(1, 500) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
elseif math.random(1, 500) == 1 then
|
||||
mymonths.weather = "storm"
|
||||
end
|
||||
elseif month == "8" then --Augest
|
||||
if math.random(1, 500) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
elseif math.random(1, 500) == 1 then
|
||||
mymonths.weather = "storm"
|
||||
end
|
||||
elseif month == "9" then --September
|
||||
if math.random(1, 150) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
elseif math.random(1, 250) == 1 then
|
||||
mymonths.weather = "storm"
|
||||
end
|
||||
elseif month == "10" then --October
|
||||
if math.random(1, 100) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
elseif math.random(1, 250) == 1 then
|
||||
mymonths.weather = "storm"
|
||||
end
|
||||
elseif month == "11" then --November
|
||||
if math.random(1, 100) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
elseif math.random(1, 200) == 2 then
|
||||
mymonths.weather = "snow"
|
||||
end
|
||||
elseif month == "12" then --December
|
||||
if math.random(1, 250) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
elseif math.random(1, 100) == 1 then
|
||||
mymonths.weather = "snow"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end)
|
||||
|
||||
--Weather vectors and particles are from jeija's weather mod
|
||||
addvectors = function (v1, v2)
|
||||
return {x=v1.x+v2.x, y=v1.y+v2.y, z=v1.z+v2.z}
|
||||
end
|
||||
|
||||
|
||||
|
||||
local t = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
|
||||
t = t + dtime
|
||||
if t >= 1 then
|
||||
|
||||
mymonths.weather2 = mymonths.weather
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
local ppos = player:getpos()
|
||||
local person = player
|
||||
local name = player:get_player_name()
|
||||
local nodein = minetest.get_node(ppos)
|
||||
local nodeu = minetest.get_node({x=ppos.x,y=ppos.y-1,z=ppos.z})
|
||||
|
||||
local biome_jungle = minetest.find_node_near(ppos, 5, "default:jungletree","default:junglegrass")
|
||||
local biome_desert = minetest.find_node_near(ppos, 5, "default:desert_sand","default:desert_stone")
|
||||
local biome_snow = minetest.find_node_near(ppos, 5, "default:snow","default:snowblock","default:dirt_with_snow","default:ice")
|
||||
--print(person)
|
||||
local minp = addvectors(ppos, {x=-7, y=7, z=-7})
|
||||
local maxp = addvectors(ppos, {x= 7, y=7, z= 7})
|
||||
|
||||
local minp = addvectors(ppos, {x=-10, y=7, z=-10})
|
||||
local maxp = addvectors(ppos, {x= 10, y=7, z= 10})
|
||||
local minp_deep = addvectors(ppos, {x=-10, y=3.2, z=-10})
|
||||
local maxp_deep = addvectors(ppos, {x= 10, y=2.6, z= 10})
|
||||
local vel_rain = {x=0, y= -4, z=0}
|
||||
local vel_rain = {x=0, y=-4, z=0}
|
||||
local acc_rain = {x=0, y=-9.81, z=0}
|
||||
local vel_snow = {x=0, y= -0.4, z=0}
|
||||
local acc_snow = {x=0, y= -0.5, z=0}
|
||||
local vel_snow = {x=0, y=-0.4, z=0}
|
||||
local acc_snow = {x=0, y=-0.5, z=0}
|
||||
local ran_s = math.random(1,6)
|
||||
|
||||
--slows players walk in snow
|
||||
if nodein.name == "mymonths:snow_cover_1" then
|
||||
player:set_physics_override(0.9,1,1,true,false)
|
||||
player:set_physics_override(0.95,1,1,true,false)
|
||||
elseif nodein.name == "mymonths:snow_cover_2" then
|
||||
player:set_physics_override(0.8,1,1,true,false)
|
||||
elseif nodein.name == "mymonths:snow_cover_3" then
|
||||
player:set_physics_override(0.7,1,1,true,false)
|
||||
player:set_physics_override(0.65,1,1,true,false)
|
||||
elseif nodein.name == "mymonths:snow_cover_4" then
|
||||
player:set_physics_override(0.6,1,1,true,false)
|
||||
elseif nodein.name == "mymonths:snow_cover_5" then
|
||||
player:set_physics_override(0.5,1,1,true,false)
|
||||
elseif nodein.name == "mymonths:snow_cover_5" then
|
||||
player:set_physics_override(0.35,1,1,true,false)
|
||||
else
|
||||
player:set_physics_override(1,1,1,true,false)
|
||||
end
|
||||
|
||||
--check light to make sure player is outside
|
||||
if minetest.get_node_light({x=ppos.x,y=ppos.y+1,z=ppos.z}, 0.5) ~= 15 then return end
|
||||
|
||||
--checks if there is any weather
|
||||
if mymonths.weather2 == "none" then return end
|
||||
|
||||
if biome_jungle ~= nil and
|
||||
mymonths.weather == "snow" then
|
||||
mymonths.weather2 = "rain"
|
||||
elseif biome_jungle ~= nil and
|
||||
mymonths.weather == "snowstorm" then
|
||||
mymonths.weather2 = "storm"
|
||||
elseif biome_desert ~= nil and
|
||||
mymonths.weather == "snow" then
|
||||
mymonths.weather2 = "none"
|
||||
elseif biome_desert ~= nil and
|
||||
mymonths.weather == "rain" then
|
||||
mymonths.weather2 = "none"
|
||||
elseif biome_desert ~= nil and
|
||||
mymonths.weather == "storm" then
|
||||
mymonths.weather2 = "none"
|
||||
elseif biome_desert ~= nil and
|
||||
mymonths.weather == "snowstorm" then
|
||||
mymonths.weather2 = "none"
|
||||
elseif biome_snow ~= nil and
|
||||
mymonths.weather == "rain" then
|
||||
mymonths.weather2 = "snow"
|
||||
elseif biome_snow ~= nil and
|
||||
mymonths.weather == "storm" then
|
||||
mymonths.weather2 = "snowstorm"
|
||||
--changes weather based on biome
|
||||
--Jungle
|
||||
if biome_jungle ~= nil then
|
||||
if mymonths.weather == "snow" then
|
||||
mymonths.weather2 = "rain"
|
||||
elseif mymonths.weather == "snowstorm" then
|
||||
mymonths.weather2 = "storm"
|
||||
end
|
||||
elseif biome_desert ~= nil then
|
||||
if mymonths.weather == "snow" or
|
||||
mymonths.weather == "snowstorm" or
|
||||
mymonths.weather == "storm" or
|
||||
mymonths.weather == "rain" then
|
||||
mymonths.weather2 = "none"
|
||||
end
|
||||
elseif biome_snow ~= nil then
|
||||
if mymonths.weather == "rain" then
|
||||
mymonths.weather2 = "snow"
|
||||
elseif mymonths.weather == "storm" then
|
||||
mymonths.weather2 = "snowstorm"
|
||||
end
|
||||
else
|
||||
mymonths.weather2 = mymonths.weather
|
||||
end
|
||||
|
||||
if mymonths.weather2 == "storm" then
|
||||
local ran_t = math.random(1,200)
|
||||
--storm
|
||||
minetest.add_particlespawner({amount=40, time=0.5,
|
||||
minpos=minp, maxpos=maxp,
|
||||
minvel=vel_rain, maxvel=vel_rain,
|
||||
minacc=acc_rain, maxacc=acc_rain,
|
||||
minexptime=0.8, maxexptime=0.8,
|
||||
minsize=25, maxsize=40,
|
||||
collisiondetection=false, vertical=true, texture="weather_rain_dark.png", player:get_player_name()
|
||||
})
|
||||
minetest.add_particlespawner({amount = 40, time = 0.5,
|
||||
minpos = minp, maxpos=maxp,
|
||||
minvel = vel_rain, maxvel = vel_rain,
|
||||
minacc = acc_rain, maxacc = acc_rain,
|
||||
minexptime = 0.8, maxexptime = 0.8,
|
||||
minsize = 25, maxsize = 40,
|
||||
collisiondetection = false,
|
||||
vertical = true,
|
||||
texture = "weather_rain_dark.png",
|
||||
playername = name})
|
||||
|
||||
if ran_t == 1 then
|
||||
minetest.sound_play("mymonths_thunder", {
|
||||
|
@ -95,57 +187,68 @@ minetest.register_globalstep(function(dtime)
|
|||
gain = 10.0,
|
||||
})
|
||||
end
|
||||
end
|
||||
if mymonths.weather2 == "rain" then
|
||||
--light rain
|
||||
minetest.add_particlespawner({amount=15, time=0.5,
|
||||
minpos=minp, maxpos=maxp,
|
||||
minvel=vel_rain, maxvel=vel_rain,
|
||||
minacc=acc_rain, maxacc=acc_rain,
|
||||
minexptime=0.6, maxexptime=0.8,
|
||||
minsize=25, maxsize=25,
|
||||
collisiondetection=false, vertical=true, texture="weather_rain.png", player:get_player_name()})
|
||||
end
|
||||
|
||||
if mymonths.weather2 == "snow" then
|
||||
minetest.add_particlespawner(4, 0.5,
|
||||
minp, maxp,
|
||||
vel_snow, vel_snow,
|
||||
acc_snow, acc_snow,
|
||||
4, 6,
|
||||
15, 25,
|
||||
false, "weather_snow.png", player:get_player_name())
|
||||
minetest.add_particlespawner(4, 0.5,
|
||||
minp_deep, maxp_deep,
|
||||
vel_snow, vel_snow,
|
||||
acc_snow, acc_snow,
|
||||
4, 6,
|
||||
15, 25,
|
||||
false, "weather_snow.png", player:get_player_name())
|
||||
end
|
||||
elseif mymonths.weather2 == "rain" then
|
||||
minetest.add_particlespawner({amount = 15, time = 0.5,
|
||||
minpos = minp, maxpos = maxp,
|
||||
minvel = vel_rain, maxvel = vel_rain,
|
||||
minacc = acc_rain, maxacc = acc_rain,
|
||||
minexptime = 0.6, maxexptime = 0.8,
|
||||
minsize = 25, maxsize = 25,
|
||||
collisiondetection = false,
|
||||
vertical = true,
|
||||
texture = "weather_rain.png",
|
||||
playername = name})
|
||||
elseif mymonths.weather2 == "snow" then
|
||||
minetest.add_particlespawner({amount = 4, time = 0.5,
|
||||
minpos = minp, maxpos = maxp,
|
||||
minvel = vel_snow, maxvel = vel_snow,
|
||||
minacc = acc_snow, maxacc = acc_snow,
|
||||
minexptime = 4, maxexptime = 8,
|
||||
minsize = 15, maxsize = 25,
|
||||
collisiondetection = false,
|
||||
vertical = true,
|
||||
texture = "weather_snow.png",
|
||||
playername = name})
|
||||
|
||||
if mymonths.weather2 == "snowstorm" then
|
||||
minetest.add_particlespawner(25, 0.5,
|
||||
minp, maxp,
|
||||
vel_snow, vel_snow,
|
||||
acc_snow, acc_snow,
|
||||
4, 6,
|
||||
15, 35,
|
||||
false, "weather_snow.png", player:get_player_name())
|
||||
minetest.add_particlespawner(25, 0.5,
|
||||
minp_deep, maxp_deep,
|
||||
vel_snow, vel_snow,
|
||||
acc_snow, acc_snow,
|
||||
4, 6,
|
||||
15, 25,
|
||||
false, "weather_snow.png", player:get_player_name())
|
||||
minetest.add_particlespawner({amount = 4, time = 0.5,
|
||||
minpos = minp_deep, maxpos = maxp_deep,
|
||||
minvel = vel_snow, maxvel = vel_snow,
|
||||
minacc = acc_snow, maxacc = acc_snow,
|
||||
minexptime = 4, maxexptime = 6,
|
||||
minesize = 15, maxsize = 25,
|
||||
collisiondetection = false,
|
||||
vertical = true,
|
||||
texture = "weather_snow.png",
|
||||
playername = name})
|
||||
|
||||
elseif mymonths.weather2 == "snowstorm" then
|
||||
minetest.add_particlespawner({amount = 25, time = 0.5,
|
||||
minpos = minp, maxpos = maxp,
|
||||
minvel = vel_snow, maxvel = vel_snow,
|
||||
minacc = acc_snow, maxacc = acc_snow,
|
||||
minexptime = 4, maxexptime = 6,
|
||||
minesize = 15, maxsize = 35,
|
||||
collisiondetection = false,
|
||||
vertical = true,
|
||||
texture = "weather_snow.png",
|
||||
playername = name})
|
||||
|
||||
minetest.add_particlespawner({amount = 25, time = 0.5,
|
||||
minpos = minp_deep, maxpos = maxp_deep,
|
||||
minvel = vel_snow, maxvel = vel_snow,
|
||||
minacc = acc_snow, maxacc = acc_snow,
|
||||
minexptime = 4, maxexptime = 6,
|
||||
minesize = 15, maxsize = 25,
|
||||
collisiondetection = false,
|
||||
vertical = true,
|
||||
texture = "weather_snow.png",
|
||||
playername = name})
|
||||
end
|
||||
|
||||
biome_jungle = nil
|
||||
biome_snow = nil
|
||||
biome_desert = nil
|
||||
end
|
||||
end
|
||||
end)
|
||||
t2 = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
|
@ -164,14 +267,11 @@ end)
|
|||
|
||||
--Puddle node
|
||||
local puddle_box =
|
||||
{
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.1875, -0.5, -0.375, 0.125, -0.4875, 0.3125},
|
||||
{type = "fixed",
|
||||
fixed = {{-0.1875, -0.5, -0.375, 0.125, -0.4875, 0.3125},
|
||||
{-0.25, -0.5, -0.3125, 0.3125, -0.4925, 0.25},
|
||||
{-0.3125, -0.5, -0.1875, 0.375, -0.4975, 0.1875},
|
||||
}
|
||||
}
|
||||
{-0.3125, -0.5, -0.1875, 0.375, -0.4975, 0.1875},}}
|
||||
|
||||
minetest.register_node("mymonths:puddle", {
|
||||
tiles = {"weather_puddle.png"},
|
||||
drawtype = "nodebox",
|
||||
|
@ -182,11 +282,10 @@ minetest.register_node("mymonths:puddle", {
|
|||
node_box = puddle_box,
|
||||
selection_box = puddle_box,
|
||||
groups = {not_in_creative_inventory = 1, crumbly = 3, attached_node = 0, falling_node = 1},
|
||||
drop = {""}
|
||||
drop = "",
|
||||
})
|
||||
|
||||
--Snow Nodes
|
||||
local snow_box ={type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5}}
|
||||
local snow = {
|
||||
{"mymonths:snow_cover_1","1",-0.4},
|
||||
{"mymonths:snow_cover_2","2",-0.2},
|
||||
|
@ -207,7 +306,7 @@ minetest.register_node(itm, {
|
|||
node_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, box, 0.5}},
|
||||
selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, box, 0.5}},
|
||||
groups = {not_in_creative_inventory = 0, crumbly = 3, attached_node = 0, falling_node = 1},
|
||||
drop = "default:snow "..num
|
||||
drop = "default:snow "..num,
|
||||
})
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue