update from integrated version
parent
ba00f26498
commit
02cc6c4fe8
92
init.lua
92
init.lua
|
@ -1,4 +1,7 @@
|
||||||
|
|
||||||
|
seasons = {}
|
||||||
|
|
||||||
|
|
||||||
function deepclone(t)
|
function deepclone(t)
|
||||||
if type(t) ~= "table" then
|
if type(t) ~= "table" then
|
||||||
return t
|
return t
|
||||||
|
@ -42,11 +45,16 @@ local changes_lookup = {
|
||||||
winter = {},
|
winter = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local function splitname(name)
|
||||||
|
local c = string.find(name, ":", 1)
|
||||||
|
return string.sub(name, 1, c - 1), string.sub(name, c + 1, string.len(name))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function reg_changes(ssn, oldmod, oldname)
|
function reg_changes(ssn, oldmod, oldname)
|
||||||
local old = oldmod..":"..oldname
|
local old = oldmod..":"..oldname
|
||||||
local new = "seasons:"..ssn.."_"..oldname
|
local new = "seasons:"..ssn.."_"..oldmod.."_"..oldname
|
||||||
|
|
||||||
core_lookup[old] = old
|
core_lookup[old] = old
|
||||||
if ssn == "summer" then -- minetest is in "summer" by default
|
if ssn == "summer" then -- minetest is in "summer" by default
|
||||||
|
@ -68,7 +76,7 @@ function reg_generic(oldmod, oldname, tiles, drops, default_season)
|
||||||
local old = oldmod..":"..oldname
|
local old = oldmod..":"..oldname
|
||||||
local ds = default_season or "summer"
|
local ds = default_season or "summer"
|
||||||
|
|
||||||
function reg(ssn)
|
local function reg(ssn)
|
||||||
local new
|
local new
|
||||||
if ssn == ds then -- minetest is in "summer" by default
|
if ssn == ds then -- minetest is in "summer" by default
|
||||||
new = old
|
new = old
|
||||||
|
@ -94,7 +102,7 @@ function reg_generic(oldmod, oldname, tiles, drops, default_season)
|
||||||
minetest.register_node(new, def)
|
minetest.register_node(new, def)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- print("new: "..new.." old: "..old)
|
||||||
core_lookup[new] = old
|
core_lookup[new] = old
|
||||||
changes_lookup[ssn][old] = new
|
changes_lookup[ssn][old] = new
|
||||||
table.insert(abm_list, new)
|
table.insert(abm_list, new)
|
||||||
|
@ -128,8 +136,27 @@ reg_generic("default", "bush_leaves", {
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
reg_generic("default", "jungleleaves", nil, nil)
|
reg_generic("default", "jungleleaves", nil, nil)
|
||||||
|
default.register_leafdecay({
|
||||||
|
trunks = {"default:jungletree"},
|
||||||
|
leaves = {
|
||||||
|
"seasons:winter_default_jungleleaves",
|
||||||
|
"seasons:fall_default_jungleleaves",
|
||||||
|
"seasons:spring_default_jungleleaves",
|
||||||
|
},
|
||||||
|
radius = 2,
|
||||||
|
})
|
||||||
|
|
||||||
reg_generic("default", "acacia_leaves", nil, nil)
|
reg_generic("default", "acacia_leaves", nil, nil)
|
||||||
|
default.register_leafdecay({
|
||||||
|
trunks = {"default:acacia_tree"},
|
||||||
|
leaves = {
|
||||||
|
"seasons:winter_default_acacia_leaves",
|
||||||
|
"seasons:fall_default_acacia_leaves",
|
||||||
|
"seasons:spring_default_acacia_leaves",
|
||||||
|
},
|
||||||
|
radius = 2,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
saplings
|
saplings
|
||||||
|
@ -153,7 +180,7 @@ falling leaf particles
|
||||||
function reg_leaves(ssn)
|
function reg_leaves(ssn)
|
||||||
reg_changes(ssn, "default", "leaves")
|
reg_changes(ssn, "default", "leaves")
|
||||||
|
|
||||||
minetest.register_node("seasons:"..ssn.."_leaves", {
|
minetest.register_node("seasons:"..ssn.."_default_leaves", {
|
||||||
description = "Apple Tree Leaves",
|
description = "Apple Tree Leaves",
|
||||||
drawtype = "allfaces_optional",
|
drawtype = "allfaces_optional",
|
||||||
waving = 1,
|
waving = 1,
|
||||||
|
@ -174,7 +201,7 @@ function reg_leaves(ssn)
|
||||||
{
|
{
|
||||||
-- player will get leaves only if he get no saplings,
|
-- player will get leaves only if he get no saplings,
|
||||||
-- this is because max_items is 1
|
-- this is because max_items is 1
|
||||||
items = {'seasons:'..ssn..'_leaves'},
|
items = {'seasons:'..ssn..'_default_leaves'},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -182,6 +209,12 @@ function reg_leaves(ssn)
|
||||||
|
|
||||||
after_place_node = default.after_place_leaves,
|
after_place_node = default.after_place_leaves,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
default.register_leafdecay({
|
||||||
|
trunks = {"default:tree"},
|
||||||
|
leaves = {"seasons:"..ssn.."_default_leaves"},
|
||||||
|
radius = 2,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
reg_leaves("spring")
|
reg_leaves("spring")
|
||||||
reg_leaves("fall")
|
reg_leaves("fall")
|
||||||
|
@ -192,7 +225,7 @@ reg_changes("summer", "default", "leaves")
|
||||||
function reg_aspen_leaves(ssn)
|
function reg_aspen_leaves(ssn)
|
||||||
reg_changes(ssn, "default", "aspen_leaves")
|
reg_changes(ssn, "default", "aspen_leaves")
|
||||||
|
|
||||||
minetest.register_node("seasons:"..ssn.."_aspen_leaves", {
|
minetest.register_node("seasons:"..ssn.."_default_aspen_leaves", {
|
||||||
description = "Aspen Tree Leaves",
|
description = "Aspen Tree Leaves",
|
||||||
drawtype = "allfaces_optional",
|
drawtype = "allfaces_optional",
|
||||||
tiles = {"seasons_"..ssn.."_aspen_leaves.png"},
|
tiles = {"seasons_"..ssn.."_aspen_leaves.png"},
|
||||||
|
@ -205,13 +238,19 @@ function reg_aspen_leaves(ssn)
|
||||||
max_items = 1,
|
max_items = 1,
|
||||||
items = {
|
items = {
|
||||||
{items = {"default:aspen_sapling"}, rarity = 20},
|
{items = {"default:aspen_sapling"}, rarity = 20},
|
||||||
{items = {"seasons:"..ssn.."_aspen_leaves"}}
|
{items = {"seasons:"..ssn.."_default_aspen_leaves"}}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
sounds = default.node_sound_leaves_defaults(),
|
||||||
|
|
||||||
after_place_node = default.after_place_leaves,
|
after_place_node = default.after_place_leaves,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
default.register_leafdecay({
|
||||||
|
trunks = {"default:aspen_tree"},
|
||||||
|
leaves = {"seasons:"..ssn.."_default_aspen_leaves"},
|
||||||
|
radius = 3,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
reg_aspen_leaves("spring")
|
reg_aspen_leaves("spring")
|
||||||
|
@ -249,6 +288,7 @@ reg_generic("flowers", "tulip",
|
||||||
},
|
},
|
||||||
"spring")
|
"spring")
|
||||||
|
|
||||||
|
--[[
|
||||||
reg_generic("flowers", "tulip_black",
|
reg_generic("flowers", "tulip_black",
|
||||||
{
|
{
|
||||||
summer = {"seasons_summer_flowers_tulip.png"},
|
summer = {"seasons_summer_flowers_tulip.png"},
|
||||||
|
@ -262,7 +302,7 @@ reg_generic("flowers", "tulip_black",
|
||||||
winter = {}, -- TODO: bulb
|
winter = {}, -- TODO: bulb
|
||||||
},
|
},
|
||||||
"spring")
|
"spring")
|
||||||
|
]]
|
||||||
|
|
||||||
local def
|
local def
|
||||||
-- dandelions are done manually because the default ones represent two seasons
|
-- dandelions are done manually because the default ones represent two seasons
|
||||||
|
@ -326,6 +366,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
local get_season = function()
|
local get_season = function()
|
||||||
|
local season, time
|
||||||
local t = minetest.get_gametime()
|
local t = minetest.get_gametime()
|
||||||
|
|
||||||
local s = (t % SEASONS_YEARLEN) / SEASONS_YEARLEN
|
local s = (t % SEASONS_YEARLEN) / SEASONS_YEARLEN
|
||||||
|
@ -348,6 +389,7 @@ local get_season = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
seasons.get_season = get_season
|
||||||
|
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
|
@ -459,3 +501,35 @@ minetest.register_abm({
|
||||||
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
local last_season = {
|
||||||
|
spring = "winter",
|
||||||
|
summer = "spring",
|
||||||
|
fall = "summer",
|
||||||
|
winter = "fall",
|
||||||
|
}
|
||||||
|
|
||||||
|
minetest.register_lbm({
|
||||||
|
name = "seasons:catchup",
|
||||||
|
nodenames = abm_list,
|
||||||
|
run_at_every_load = true,
|
||||||
|
action = function(pos, node)
|
||||||
|
local s, progress = get_season()
|
||||||
|
|
||||||
|
if math.random() > (progress * 1.2) then
|
||||||
|
-- use last season's node
|
||||||
|
s = last_season[s]
|
||||||
|
end
|
||||||
|
|
||||||
|
--local name = changes[s][node.name]
|
||||||
|
local core = core_lookup[node.name]
|
||||||
|
local name = changes_lookup[s][core]
|
||||||
|
|
||||||
|
if name == nil or name == node.name then return end
|
||||||
|
|
||||||
|
minetest.set_node(pos, {name = name})
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 236 B |
Binary file not shown.
After Width: | Height: | Size: 163 B |
Binary file not shown.
After Width: | Height: | Size: 153 B |
Loading…
Reference in New Issue