mirror of
https://github.com/t-affeldt/climate_api.git
synced 2025-07-05 09:50:34 +02:00
Implement sounds, enable start and stop events
This commit is contained in:
10
lib/api.lua
10
lib/api.lua
@ -2,7 +2,7 @@ local api = {}
|
||||
|
||||
api.SHORT_CYCLE = 0.03 -- for particles and fast animations
|
||||
api.DEFAULT_CYCLE = 0.1 -- for most effect types
|
||||
api.MEDIUM_CYCKE = 2.0 -- for ressource intensive tasks
|
||||
api.MEDIUM_CYCLE = 2.0 -- for ressource intensive tasks
|
||||
api.LONG_CYCLE = 5.0 -- for write operations and skybox changes
|
||||
|
||||
function api.register_weather(name, conditions, effects)
|
||||
@ -17,13 +17,13 @@ end
|
||||
function api.register_effect(name, handler, htype)
|
||||
-- check for valid handler types
|
||||
if htype ~= "start" and htype ~= "tick" and htype ~= "stop" then
|
||||
minetest.log("warn", "[Climate API] Invalid effect handler type: " .. htype)
|
||||
minetest.log("warning", "[Climate API] Invalid effect handler type: " .. htype)
|
||||
return
|
||||
end
|
||||
-- create effect handler registry if not existent yet
|
||||
if type(climate_mod.effects[name]) == "nil" then
|
||||
climate_mod.effects[name] = { start = {}, tick = {}, stop = {} }
|
||||
climate_mod.cycles[name] = { timespan = DEFAULT_CYCLE, timer = 0 }
|
||||
climate_mod.cycles[name] = { timespan = api.DEFAULT_CYCLE, timer = 0 }
|
||||
end
|
||||
-- store effect handler
|
||||
table.insert(climate_mod.effects[name][htype], handler)
|
||||
@ -33,4 +33,8 @@ function api.set_effect_cycle(name, cycle)
|
||||
climate_mod.cycles[name].timespan = cycle
|
||||
end
|
||||
|
||||
--[[function api.register_influence(name, func)
|
||||
climate_mod.influences[name] = func
|
||||
end]]
|
||||
|
||||
return api
|
||||
|
Reference in New Issue
Block a user