modules
parent
27619c529c
commit
cf7088ba9a
20
block.lua
20
block.lua
|
@ -1,18 +1,4 @@
|
|||
|
||||
local weatherdefs = {} -- list<weatherdef>
|
||||
|
||||
--[[
|
||||
weatherdef = {
|
||||
name = "",
|
||||
on_step = function() end
|
||||
}
|
||||
--]]
|
||||
|
||||
epic_weather.register_weather = function(def)
|
||||
table.insert(weatherdefs, def)
|
||||
end
|
||||
|
||||
epic_weather.register_weather({ name = "None" })
|
||||
|
||||
|
||||
local update_formspec = function(meta)
|
||||
|
@ -22,13 +8,13 @@ local update_formspec = function(meta)
|
|||
|
||||
local selected = 1
|
||||
local list = ""
|
||||
for i, def in ipairs(weatherdefs) do
|
||||
for i, def in ipairs(epic_weather.weatherdefs) do
|
||||
if def.name == weathername then
|
||||
selected = i
|
||||
end
|
||||
|
||||
list = list .. minetest.formspec_escape(def.name)
|
||||
if i < #weatherdefs then
|
||||
if i < #epic_weather.weatherdefs then
|
||||
-- not end of list
|
||||
list = list .. ","
|
||||
end
|
||||
|
@ -73,7 +59,7 @@ minetest.register_node("epic:set_weather", {
|
|||
local parts = fields.weathername:split(":")
|
||||
if parts[1] == "CHG" then
|
||||
local selected_def = tonumber(parts[2])
|
||||
local weatherdef = weatherdefs[selected_def]
|
||||
local weatherdef = epic_weather.weatherdefs[selected_def]
|
||||
if weatherdef and weatherdef.name then
|
||||
meta:set_string("weathername", weatherdef.name)
|
||||
end
|
||||
|
|
1
init.lua
1
init.lua
|
@ -3,6 +3,7 @@ local MP = minetest.get_modpath("epic_weather")
|
|||
|
||||
epic_weather = {}
|
||||
|
||||
dofile(MP.."/register.lua")
|
||||
dofile(MP.."/block.lua")
|
||||
dofile(MP.."/weather.lua")
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
epic_weather.weatherdefs = {} -- list<weatherdef>
|
||||
|
||||
--[[
|
||||
weatherdef = {
|
||||
name = "",
|
||||
on_step = function() end
|
||||
}
|
||||
--]]
|
||||
|
||||
epic_weather.register_weather = function(def)
|
||||
table.insert(epic_weather.weatherdefs, def)
|
||||
end
|
||||
|
||||
epic_weather.register_weather({ name = "None" })
|
||||
|
||||
|
Loading…
Reference in New Issue