From ec76d94ee392ec4e13ae47f10fd76cc4e5fb4506 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Sun, 1 Sep 2019 11:21:43 +0200 Subject: [PATCH] ocean detection changed --- doc/ta4_doc.lua | 4 ++-- wind_turbine/rotor.lua | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/doc/ta4_doc.lua b/doc/ta4_doc.lua index b2c5c43..b7e32c6 100644 --- a/doc/ta4_doc.lua +++ b/doc/ta4_doc.lua @@ -47,8 +47,8 @@ techage.register_category_page("ta4wt", "a pillar by means of TA4 Pillar nodes (power cables have to be inside).@n".. "Please note the following limitations:@n".. "- pillar height between 10 and 19 m@n".. - "- can only be built offshore (the info tool indicates where a wind turbine can be built)@n".. - "- 14 m free space in all 4 directions (e.g. to the next wind turbine)@n".. + "- can only be built offshore (20 m in all 4 directions is water)@n".. + "- more than 14 m to the next wind turbine@n".. "- the wind blows only between 5 and 9 o'clock and between 17 and 21 o'clock"), nil, {}, diff --git a/wind_turbine/rotor.lua b/wind_turbine/rotor.lua index 46bd866..44b3efa 100644 --- a/wind_turbine/rotor.lua +++ b/wind_turbine/rotor.lua @@ -29,6 +29,8 @@ local power = techage.power local Rotors = {} +local MAX_NUM_FOREIGN_NODES = 50 + local Face2Dir = {[0]= {x=0, y=0, z=1}, {x=1, y=0, z=0}, @@ -48,6 +50,8 @@ end local function add_rotor(pos, mem, player_name) mem.error = false + + -- Check for next wind turbine local pos1 = {x=pos.x-14, y=pos.y-9, z=pos.z-14} local pos2 = {x=pos.x+14, y=pos.y+10, z=pos.z+14} local num = #minetest.find_nodes_in_area(pos1, pos2, {"techage:ta4_wind_turbine"}) @@ -61,8 +65,11 @@ local function add_rotor(pos, mem, player_name) return end - local data = minetest.get_biome_data({x=pos.x, y=-1, z=pos.z}) - if not techage.OceanIdTbl[data.biome] then + -- Check for water surface (occean) + pos1 = {x=pos.x-20, y=0, z=pos.z-20} + pos2 = {x=pos.x+20, y=1, z=pos.z+20} + local num = #minetest.find_nodes_in_area(pos1, pos2, {"default:water_source", "default:water_flowing", "ignore"}) + if num < (41*41*2-MAX_NUM_FOREIGN_NODES) then if player_name then minetest.chat_send_player(player_name, S("[TA4 Wind Turbine]").. " "..S("Wrong place for wind turbines!")) @@ -91,6 +98,9 @@ local function add_rotor(pos, mem, player_name) obj:set_rotation(yaw) Rotors[hash] = obj end + + local own_num = M(pos):get_string("node_number") or "" + M(pos):set_string("infotext", S("TA4 Wind Turbine").." "..own_num) end local function start_rotor(pos, mem)