From 53b77bd9e3b5a7803db9433eb5b0b4e8e593ab8a Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Sat, 31 Aug 2019 01:36:31 +0200 Subject: [PATCH] tubelib2.init_mem(pos) bugfixes power_pole with protection wind turbine prototype added --- models/techage_rotor.b3d | Bin 0 -> 9983 bytes power/protection.lua | 70 ++++++++ textures/techage_rotor.png | Bin 0 -> 468 bytes textures/techage_rotor_blades.png | Bin 0 -> 3085 bytes textures/techage_rotor_top.png | Bin 0 -> 428 bytes textures/techage_wind_turbine_inv.png | Bin 0 -> 7431 bytes wind_turbine/rotor.lua | 238 ++++++++++++++++++++++++++ 7 files changed, 308 insertions(+) create mode 100644 models/techage_rotor.b3d create mode 100644 power/protection.lua create mode 100644 textures/techage_rotor.png create mode 100644 textures/techage_rotor_blades.png create mode 100644 textures/techage_rotor_top.png create mode 100644 textures/techage_wind_turbine_inv.png create mode 100644 wind_turbine/rotor.lua diff --git a/models/techage_rotor.b3d b/models/techage_rotor.b3d new file mode 100644 index 0000000000000000000000000000000000000000..afd8f0c5da8283d4848bfe51aa0b9c1ee9579514 GIT binary patch literal 9983 zcmai(33OCN7KS?^0m;H55VoKJ!WxK@?hu4@Rnia;BrHh~5fy?a$|9R=EUdI4&sKWD5B!VCL(b`5L95G=l-c~UrnFac{%6H-;etHzIyfUttI$; z?g4*xcDZ6)E|;%pRB=yMd@d}VRW@^C=@i$8yN1dzE?0%*wps%;$Unn|4=8w@1N5Ig zp$z|K{J?BtH5C>VUzyiP2e`VZq)1$*$`37b`7?^Q)A1c1To2)Dy zshW&0_I`P9r8mpnEN~&XP?L2GC7d3`4MrT*Kgwak)x%Z$j<`v(_ zdcrBbQ~#Xq?-c)z@{JPjXL|X-KycMUxg+M#wlxQ@^8ZF9vU1j)(&_urp0A>;b-y=q z+6kxl(c076FO*{aFvt9GdcP}=_6}U(-XkZKcMdE)(VuqY9}@c)9Tz`dcQ$9h!bx(~ z(cXDk+C zpgkP_9d6%w`g^hS&zpG6bU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~c63L5$OSmXe`EH@>UD%m}afY+b%;DH$5u^lb%htHb-lnpTpb1%d4f%&Nm%Q`}lI zG;>Bkf!PsWa~wos8_Cenbfv(YI=nTijbtcuAMd-ExpjEYO>HX~%6xdM0`nrg<~ZEm cHdQio^WZHC+#caI-|>tcsgj{nyr%^J0}rmatpET3 literal 0 HcmV?d00001 diff --git a/power/protection.lua b/power/protection.lua new file mode 100644 index 0000000..5fe7cf3 --- /dev/null +++ b/power/protection.lua @@ -0,0 +1,70 @@ +--[[ + + TechAge + ======= + + Copyright (C) 2019 Joachim Stolberg + + GPL v3 + See LICENSE.txt for more information + + TA3/TA4 Power line Protection +]]-- + +local M = minetest.get_meta +local S = techage.S + +local RANGE = 8 + +local IsNodeUnderObservation = {} + +-- Register all nodes, which should be protected by the "techage:power_pole" +function techage.register_powerline_node(name) + IsNodeUnderObservation[name] = true +end + +local function powerpole_found(pos, name, range) + local pos1 = {x=pos.x-range, y=pos.y-range, z=pos.z-range} + local pos2 = {x=pos.x+range, y=pos.y+range, z=pos.z+range} + for _,npos in ipairs(minetest.find_nodes_in_area(pos1, pos2, {"techage:power_pole", "techage:power_pole2"})) do + if minetest.get_meta(npos):get_string("owner") ~= name then + return true + end + end + return false +end + +local function is_protected(pos, name, range) + if minetest.check_player_privs(name, "powerline") + or not powerpole_found(pos, name, range) then + return false + end + return true +end + +function techage.is_protected(pos, name) + return is_protected(pos, name, RANGE+3) +end + + +local old_is_protected = minetest.is_protected + +function minetest.is_protected(pos, name) + local node = minetest.get_node(pos) + if IsNodeUnderObservation[node.name] and is_protected(pos, name, RANGE) then + return true + end + return old_is_protected(pos, name) +end + +minetest.register_privilege("powerline", { + description = S("Allow to dig/place Techage power lines nearby power poles"), + give_to_singleplayer = false, + give_to_admin = true, +}) + +techage.register_powerline_node("techage:power_line") +techage.register_powerline_node("techage:power_lineS") +techage.register_powerline_node("techage:power_lineA") +techage.register_powerline_node("techage:power_pole3") + diff --git a/textures/techage_rotor.png b/textures/techage_rotor.png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ns!0OpIOWe}LaLMi2&7e#SFIGLB_ z2_dj;`;m%sfiJ}P8G?C{yilRWC=L_=ztgxC)Cdl&~rfFh49xt6)AZPV`0nhVzp)=n^ z&4U;YhY&@PyU4>QObEebGC{3YgCt3q&1R5gxiUO)XbU*0D=pV`d0(*XGPNiQxUS2u z>A!f4~ z9LHH|32YE@I-Q~{OAh7X@38Sdranbcgm$~V4*)?x@%{HGfBqR+S>nN!E2v+-jB#tY~LmMFXgy$0jT6_k<$)M`Mj2GuYiz4|IPUw#>xAn7PLc%AJoC)4LSQ1uelJc4f`DGHhd7S$?6c1<1jjtj zxyrNv;NHD^`%Yl)TUPGQ3^1I#r9fBZ0x7)=_ zFTI2)ilFOy<#$LJh9!F`N;<-kcR>&kh9Op0S1Uf-?RNK^;v9`exOj+6((QI3Nz%R$ zm}?FO16;m*dEw?+`t7&hU>L>|pZZ>Fb8{1xW#Q7LOGp0fwY4>LIvo%~DsO^4d=N!Z z;L4RNOD#`YUtd4=v9;rz8@_Pi0`K@9hH#LvS&7Z`9p^eO>tbtteH{-TJm8hyK{pTJ z2!E|?EC&BUzRu(02hy`TxRazdES9H&t2e2Ur9Y}7kIdf bJk0t(aA|TlHaQjz00000NkvXXu0mjfFxj5s literal 0 HcmV?d00001 diff --git a/textures/techage_rotor_top.png b/textures/techage_rotor_top.png new file mode 100644 index 0000000000000000000000000000000000000000..ae1b34d978b31d6e1194d341d9fe9c7079da2c9f GIT binary patch literal 428 zcmV;d0aN~oP)_g82V$<&Z>v?7?hELmMGd zR$2+4XiPo!crq=h>U3xLPL7!k9uWb+4psGd*a@g7VCHF>oO2^B6OnVSVDA7TvK;}O zY3)000K>dQ@0+Qek%> zaB^>EX>4U6ba`-PAZ2)IW&i+q+MSnSk{l@xh5zR%_6Q&W62}1q5qpC@{(e+dd+Z+1 z#KdH|DzixtlHSu3e)j+Vd!GMrWh?0^)x7oA5?AS^%izJ&`?}AQukelckhk=8<Rpt(L|D}Y;An=dpAv*wd>&S{Oa9>Q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1,238 @@ +--[[ + + TechAge + ======= + + Copyright (C) 2019 DS-Minetest, Joachim Stolberg + + GPL v3 + See LICENSE.txt for more information + + TA4 Power Wind Turbine Rotor + + Code by Joachim Stolberg, derived from DS-Minetest [1] + Rotor model and texture designed by DS-Minetest [1] (CC-0) + + [1] https://github.com/DS-Minetest/wind_turbine + +]]-- + +-- for lazy programmers +local M = minetest.get_meta +local S = techage.S + +local CYCLE_TIME = 2 +local PWR_PERF = 80 + +local Cable = techage.ElectricCable +local power = techage.power + +local Rotors = {} + +local Face2Dir = {[0]= + {x=0, y=0, z=1}, + {x=1, y=0, z=0}, + {x=0, y=0, z=-1}, + {x=-1, y=0, z=0}, + {x=0, y=-1, z=0}, + {x=0, y=1, z=0} +} + +local function pos_and_yaw(pos, param2) + local dir = Face2Dir[param2] + local yaw = minetest.dir_to_yaw(dir) + dir = vector.multiply(dir, 1.3) + pos = vector.add(pos, dir) + return pos, {x=0, y=yaw, z=0} +end + +local function add_rotor(pos, player_name) + local pos1 = {x=pos.x-14, y=pos.y-10, z=pos.z-14} + local pos2 = {x=pos.x+14, y=pos.y+10, z=pos.z+14} + local num_node = 29*29*21 - 12 + local num = #minetest.find_nodes_in_area(pos1, pos2, {"air", "ignore"}) + if num < num_node then + if player_name then + minetest.chat_send_player(player_name, "[TA4 Wind Turbine] Not enough space!") + end + return + end + + local data = minetest.get_biome_data({x=pos.x, y=0, z=pos.z}) + if not techage.OceanIdTbl[data.biome] then + if player_name then + minetest.chat_send_player(player_name, "[TA4 Wind Turbine] Wrong place for wind turbines!") + end + return + end + + if pos.y < 12 or pos.y > 20 then + if player_name then + minetest.chat_send_player(player_name, "[TA4 Wind Turbine] No wind at this altitude!") + end + return + end + + local hash = minetest.hash_node_position(pos) + if not Rotors[hash] then + local node = minetest.get_node(pos) + local npos, yaw = pos_and_yaw(pos, node.param2) + local obj = minetest.add_entity(npos, "techage:rotor_ent") + obj:set_animation({x = 0, y = 119}, 0, 0, true) + obj:set_rotation(yaw) + Rotors[hash] = obj + end +end + +local function start_rotor(pos, mem) + mem.providing = true + power.generator_start(pos, mem, PWR_PERF) + local hash = minetest.hash_node_position(pos) + if Rotors[hash] then + Rotors[hash]:set_animation_frame_speed(50) + end +end + +local function stop_rotor(pos, mem) + mem.providing = false + power.generator_stop(pos, mem) + local hash = minetest.hash_node_position(pos) + if Rotors[hash] then + Rotors[hash]:set_animation_frame_speed(0) + end +end + +local function node_timer(pos, elapsed) + local mem = tubelib2.get_mem(pos) + + print("node_timer", mem.running, mem.providing) + if not mem.running then + return false + end + + local time = minetest.get_timeofday() or 0 + if (time >= 5.00/24.00 and time <= 9.00/24.00) or (time >= 17.00/24.00 and time <= 21.00/24.00) then + if not mem.providing then + start_rotor(pos, mem) + end + else + if mem.providing then + stop_rotor(pos, mem) + end + end + if mem.providing then + power.generator_alive(pos, mem) + end + return true +end + +minetest.register_node("techage:ta4_wind_turbine", { + description = S("TA4 Wind Turbine"), + inventory_image = "techage_wind_turbine_inv.png", + tiles = { + -- up, down, right, left, back, front + "techage_rotor_top.png", + "techage_rotor_top.png", + "techage_rotor.png", + }, + + on_construct = tubelib2.init_mem, + + after_place_node = function(pos, placer) + local meta = M(pos) + -- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!! + local mem = tubelib2.get_mem(pos) + local own_num = techage.add_node(pos, "techage:ta4_wind_turbine") + meta:set_string("node_number", own_num) + meta:set_string("owner", placer:get_player_name()) + meta:set_string("infotext", S("TA4 Wind Turbine").." "..own_num) + mem.providing = false + mem.running = true + add_rotor(pos, placer:get_player_name()) + minetest.get_node_timer(pos):start(CYCLE_TIME) + end, + + on_timer = node_timer, + + after_dig_node = function(pos) + local hash = minetest.hash_node_position(pos) + if Rotors[hash] and Rotors[hash]:get_luaentity() then + Rotors[hash]:remove() + end + Rotors[hash] = nil + techage.remove_node(pos) + tubelib2.del_mem(pos) + end, + + paramtype2 = "facedir", + groups = {cracky=2, crumbly=2, choppy=2}, + is_ground_content = false, + sounds = default.node_sound_metal_defaults(), +}) + + +minetest.register_node("techage:ta4_wind_turbine_nacelle", { + description = S("TA4 Wind Turbine Nacelle"), + tiles = { + -- up, down, right, left, back, front + "techage_rotor_top.png", + "techage_rotor_top.png", + "techage_rotor.png", + }, + paramtype2 = "facedir", + groups = {cracky=2, crumbly=2, choppy=2}, + is_ground_content = false, + sounds = default.node_sound_metal_defaults(), + drop = "", +}) + +minetest.register_entity("techage:rotor_ent", {initial_properties = { + physical = false, + pointable = false, + visual = "mesh", + visual_size = {x = 1.5, y = 1.5, z = 1.5}, + mesh = "techage_rotor.b3d", + textures = {"techage_rotor_blades.png"}, + static_save = false, +}}) + +techage.power.register_node({"techage:ta4_wind_turbine"}, { + power_network = Cable, + conn_sides = {"D"}, +}) + +techage.register_node({"techage:ta4_wind_turbine"}, { + on_recv_message = function(pos, src, topic, payload) + local mem = tubelib2.get_mem(pos) + print("on_recv_message", topic) + if topic == "state" then + if mem.running and mem.providing then + return "running" + else + return "stopped" + end + elseif topic == "on" then + mem.running = true + elseif topic == "off" then + mem.running = false + else + return "unsupported" + end + end, + on_node_load = function(pos) + add_rotor(pos) + local mem = tubelib2.get_mem(pos) + mem.providing = false -- to force the rotor start + minetest.get_node_timer(pos):start(CYCLE_TIME) + end, +}) + + +--minetest.register_craft({ +-- output = "techage:ta4_wind_turbine", +-- recipe = { +-- {"", "techage:ta4_wlanchip", ""}, +-- {"techage:ta4_silicon_wafer", "techage:ta4_silicon_wafer", "techage:ta4_silicon_wafer"}, +-- {"default:tin_ingot", "techage:iron_ingot", "default:copper_ingot"}, +-- }, +--})