Implement ABM wrapper, allow environment checks for general positions

This commit is contained in:
Till Affeldt
2020-04-16 19:12:20 +02:00
parent 7f8f1a77f2
commit f41d5f259c
6 changed files with 65 additions and 26 deletions

View File

@ -1,21 +1,26 @@
local trigger = {}
function trigger.get_player_environment(player)
local ppos = player:get_pos()
function trigger.get_position_environment(pos)
local wind_x = climate_mod.state:get_float("wind_x")
local wind_z = climate_mod.state:get_float("wind_z")
local env = {}
env.player = player
env.pos = ppos
env.height = ppos.y
env.pos = pos
env.height = pos.y
env.wind = vector.new(wind_x, 0, wind_z)
env.windspeed = vector.length(env.wind)
env.heat = climate_api.environment.get_heat(ppos)
env.humidity = climate_api.environment.get_humidity(ppos)
env.heat = climate_api.environment.get_heat(pos)
env.humidity = climate_api.environment.get_humidity(pos)
env.time = minetest.get_timeofday()
env.date = minetest.get_day_count()
env.light = minetest.get_node_light(vector.add(ppos, vector.new({x=0,y=1.5,z=0})), 0.5)
env.light = minetest.get_node_light(vector.add(pos, vector.new({x=0,y=1,z=0})), 0.5)
return env
end
function trigger.get_player_environment(player)
local ppos = player:get_pos()
local env = trigger.get_position_environment(ppos)
env.player = player
return env
end