diff --git a/autocrafter.lua b/autocrafter.lua index 81477fc..f63f6cc 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -252,7 +252,7 @@ minetest.register_node("basic_machines:autocrafter", { description = "Autocrafter", drawtype = "normal", tiles = {"pipeworks_autocrafter.png"}, - groups = {cracky=3, mesecon_effector_on = 1}, + groups = {cracky=3}, on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -333,7 +333,7 @@ minetest.register_node("basic_machines:autocrafter", { return 0; -- no internal inventory moves! end, - mesecons = {effector = { -- rnd: run machine when activated by signal + effector = { -- rnd: run machine when activated by signal action_on = function (pos, node,ttl) if type(ttl)~="number" then ttl = 1 end if ttl<0 then return end -- machines_TTL prevents infinite recursion @@ -351,7 +351,6 @@ minetest.register_node("basic_machines:autocrafter", { end } - } --on_timer = run_autocrafter -- rnd }) diff --git a/ball.lua b/ball.lua index 8eca97a..f313ee0 100644 --- a/ball.lua +++ b/ball.lua @@ -215,13 +215,13 @@ minetest.register_entity("basic_machines:ball",{ local node = minetest.get_node(pos); local table = minetest.registered_nodes[node.name]; - if table and table.mesecons and table.mesecons.effector then -- activate target + if table and table.effector then -- activate target local energy = self.energy; if energy~=0 then if minetest.is_protected(pos,self.owner) then return end end - local effector = table.mesecons.effector; + local effector = table.effector; local count = ballcount[self.owner] or 1; count=count-1; ballcount[self.owner] = count; self.object:remove(); @@ -340,7 +340,7 @@ minetest.register_entity("basic_machines:ball",{ minetest.register_node("basic_machines:ball_spawner", { description = "Spawns energy ball one block above", tiles = {"basic_machines_ball.png"}, - groups = {cracky=3, mesecon_effector_on = 1}, + groups = {cracky=3}, drawtype = "allfaces", paramtype = "light", param1=1, @@ -368,7 +368,7 @@ minetest.register_node("basic_machines:ball_spawner", { end, - mesecons = {effector = { + effector = { action_on = function (pos, node,ttl) if type(ttl)~="number" then ttl = 1 end if ttl<0 then return end @@ -483,7 +483,6 @@ minetest.register_node("basic_machines:ball_spawner", { luaent.energy = -1; obj:set_properties({textures={"basic_machines_ball.png^[colorize:blue:120"}}) end - } }, on_receive_fields = function(pos, formname, fields, sender) diff --git a/constructor.lua b/constructor.lua index 7c3425f..169de23 100644 --- a/constructor.lua +++ b/constructor.lua @@ -35,10 +35,16 @@ basic_machines.craft_recipes = { } + basic_machines.craft_recipe_order = { -- order in which nodes appear "keypad","light","grinder","mover", "battery","generator","detector", "distributor", "clock_generator","recycler","autocrafter","ball_spawner", "enviroment", "power_block", "power_cell", "coal_lump", } +if mesecon then -- add mesecon adapter + basic_machines.craft_recipes["mesecon_adapter"] = {item = "basic_machines:mesecon_adapter", description = "interface between machines and mesecons", craft = {"default:mese_crystal_fragment"}, tex = "jeija_luacontroller_top"} + basic_machines.craft_recipe_order[1+#basic_machines.craft_recipe_order] = "mesecon_adapter" +end + local constructor_process = function(pos) @@ -124,7 +130,7 @@ end minetest.register_node("basic_machines:constructor", { description = "Constructor: used to make machines", tiles = {"constructor.png"}, - groups = {cracky=3, mesecon_effector_on = 1}, + groups = {cracky=3}, sounds = default.node_sound_wood_defaults(), after_place_node = function(pos, placer) local meta = minetest.get_meta(pos); @@ -169,13 +175,12 @@ minetest.register_node("basic_machines:constructor", { return 0; end, - mesecons = {effector = { + effector = { action_on = function (pos, node,ttl) if type(ttl)~="number" then ttl = 1 end if ttl<0 then return end -- machines_TTL prevents infinite recursion constructor_process(pos); end - } }, on_receive_fields = function(pos, formname, fields, sender) diff --git a/depends.txt b/depends.txt index f29c289..fd4784e 100644 --- a/depends.txt +++ b/depends.txt @@ -3,4 +3,5 @@ protector? doors? areas? boneworld? -moreores? \ No newline at end of file +moreores? +mesecons? \ No newline at end of file diff --git a/enviro.lua b/enviro.lua index 2af171e..1650e9e 100644 --- a/enviro.lua +++ b/enviro.lua @@ -65,7 +65,7 @@ minetest.register_node("basic_machines:enviro", { drawtype = "allfaces", paramtype = "light", param1=1, - groups = {cracky=3, mesecon_effector_on = 1}, + groups = {cracky=3}, sounds = default.node_sound_wood_defaults(), after_place_node = function(pos, placer) local meta = minetest.env:get_meta(pos) @@ -90,7 +90,7 @@ minetest.register_node("basic_machines:enviro", { enviro_update_form(pos); end, - mesecons = {effector = { + effector = { action_on = function (pos, node,ttl) local meta = minetest.get_meta(pos); local machines = meta:get_int("machines"); @@ -145,7 +145,6 @@ minetest.register_node("basic_machines:enviro", { end - } }, diff --git a/grinder.lua b/grinder.lua index 3c4e460..869d7df 100644 --- a/grinder.lua +++ b/grinder.lua @@ -189,13 +189,12 @@ minetest.register_node("basic_machines:grinder", { return 0; end, - mesecons = {effector = { + effector = { action_on = function (pos, node,ttl) if type(ttl)~="number" then ttl = 1 end if ttl<0 then return end -- machines_TTL prevents infinite recursion grinder_process(pos); end - } }, on_receive_fields = function(pos, formname, fields, sender) diff --git a/init.lua b/init.lua index 688f367..c78b004 100644 --- a/init.lua +++ b/init.lua @@ -30,6 +30,10 @@ dofile(minetest.get_modpath("basic_machines").."/constructor.lua") -- enable cra dofile(minetest.get_modpath("basic_machines").."/protect.lua") -- enable interaction with players, adds local on protect/chat event handling +-- MESECON functionality +if mesecon then + dofile(minetest.get_modpath("basic_machines").."/mesecon_adapter.lua") +end -- OPTIONAL ADDITIONAL STUFF ( comment to disable ) dofile(minetest.get_modpath("basic_machines").."/ball.lua") -- interactive flying ball, can activate blocks or be used as a weapon diff --git a/mesecon_adapter.lua b/mesecon_adapter.lua new file mode 100644 index 0000000..2ae90a6 --- /dev/null +++ b/mesecon_adapter.lua @@ -0,0 +1,64 @@ + +-- block that can be activated/activate mesecon blocks + +local adapter_effector = { + action_on = function (pos, node,ttl) + if type(ttl)~="number" then ttl = 2 end + if not(ttl>0) then return end + + pos.y=pos.y+1; + local node = minetest.get_node(pos); + if not node.name then return end -- error + local table = minetest.registered_nodes[node.name]; + if not table then return end + if table.effector and table.effector.action_on then -- activate basic_machine + local effector=table.effector; + effector.action_on(pos,node,ttl); + else -- table.mesecons and table.mesecons.effector then -- activate mesecons + pos.y=pos.y-1 + mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node)) + --local effector=table.mesecons.effector; + --effector.action_on(pos,node); + end + end, + + action_off = function (pos, node,ttl) + if type(ttl)~="number" then ttl = 2 end + if not(ttl>0) then return end + + pos.y=pos.y+1; + local node = minetest.get_node(pos); + if not node.name then return end -- error + local table = minetest.registered_nodes[node.name]; + if not table then return end + if table.effector and table.effector.action_off then -- activate basic_machine + local effector=table.effector; + effector.action_off(pos,node,ttl); + else -- table.mesecons and table.mesecons.effector then -- activate mesecons + pos.y=pos.y-1 + mesecon.receptor_off(pos, mesecon.rules.buttonlike_get(node)) + --local effector=table.mesecons.effector; + --effector.action_off(pos,node); + end + end, + } + +minetest.register_node("basic_machines:mesecon_adapter", { + description = "interface between machines and mesecons - place block to be activated on top of it.", + tiles = {"basic_machine_clock_generator.png","basic_machine_clock_generator.png", + "jeija_luacontroller_top.png","jeija_luacontroller_top.png","jeija_luacontroller_top.png","jeija_luacontroller_top.png" + }, + groups = {cracky=3,mesecon_effector_on = 1,mesecon_effector_off=1,mesecon_needs_receiver = 1,}, + sounds = default.node_sound_wood_defaults(), + + + effector = adapter_effector, + mesecons = { + effector = adapter_effector, + receptor = { + rules = mesecon.rules.buttonlike_get, + state = mesecon.state.off + }, + }, + +}) \ No newline at end of file diff --git a/mesecon_doors.lua b/mesecon_doors.lua index f0c8b10..165f94e 100644 --- a/mesecon_doors.lua +++ b/mesecon_doors.lua @@ -13,14 +13,15 @@ tablecopy = function(a) end local function door_signal_overwrite(name) + local table = minetest.registered_nodes[name]; if not table then return end --if table.mesecons then return end -- already exists, don't change local door_on_rightclick = table.on_rightclick; - minetest.override_item(name, - {mesecons = {effector = { - action_on = function (pos,node) + { + effector = { + action_on = function(pos,node) local meta = minetest.get_meta(pos);local name = meta:get_string("owner"); -- create virtual player local clicker = {}; @@ -34,9 +35,9 @@ local function door_signal_overwrite(name) if door_on_rightclick then door_on_rightclick(pos, nil, clicker,ItemStack(""),{}) end -- safety if it doesnt exist --minetest.swap_node(pos, {name = "protector:trapdoor", param1 = node.param1, param2 = node.param2}) -- more direct approach?, need to set param2 then too end - } } -}) + } + ) end diff --git a/mesecon_lights.lua b/mesecon_lights.lua index eeb5deb..3c293b8 100644 --- a/mesecon_lights.lua +++ b/mesecon_lights.lua @@ -10,22 +10,12 @@ local table = minetest.registered_nodes[name]; if not table then return end local offname = "basic_machines:"..string.gsub(name, ":", "_").. "_OFF"; - table2.mesecons = {effector = { -- action to toggle light off + table2.effector = { -- action to toggle light off action_off = function (pos,node,ttl) minetest.swap_node(pos,{name = offname}); end - } - }; + }; - table2.after_place_node = function(pos, placer) - minetest.after(5, -- fixes mesecons turning light off after place - function() - if minetest.get_node(pos).name == offname then - minetest.swap_node(pos,{name = name}) - end - end - ) - end minetest.register_node(":"..name, table2) -- redefine item @@ -38,11 +28,10 @@ local table = minetest.registered_nodes[name]; if not table then return end end table3.light_source = 0; -- off block has light off - table3.mesecons = {effector = { + effector = { action_on = function (pos,node,ttl) minetest.swap_node(pos,{name = name}); end - } }; -- REGISTER OFF BLOCK diff --git a/mover.lua b/mover.lua index 5923a93..20bdd98 100644 --- a/mover.lua +++ b/mover.lua @@ -13,7 +13,7 @@ basic_machines.max_range = 10 -- machines normal range of operation basic_machines.machines_operations = 10 -- 1 coal will provide 10 mover basic operations ( moving dirt 1 block distance) basic_machines.machines_TTL = 16 -- time to live for signals, how many hops before signal dissipates -basic_machines.version = "03/02/2021a"; +basic_machines.version = "10/02/2021a"; basic_machines.clockgen = 1; -- if 0 all background continuously running activity (clockgen/keypad) repeating is disabled -- how hard it is to move blocks, default factor 1, note fuel cost is this multiplied by distance and divided by machine_operations.. @@ -225,8 +225,8 @@ local get_mover_form = function(pos,player) inventory_list1 = ""; inventory_list2 = "" end - - form = "size[6,5.5]" .. -- width, height + + form = "size[8,8.25]" .. -- width, height --"size[6,10]" .. -- width, height "tabheader[0,0;tabs;MODE OF OPERATION,WHERE TO MOVE;".. seltab .. ";true;true]".. @@ -275,7 +275,7 @@ local check_for_falling = minetest.check_for_falling or nodeupdate; -- 1st for m minetest.register_node("basic_machines:mover", { description = "Mover - universal digging/harvesting/teleporting/transporting machine, its upgradeable.", tiles = {"compass_top.png","default_furnace_top.png", "basic_machine_mover_side.png","basic_machine_mover_side.png","basic_machine_mover_side.png","basic_machine_mover_side.png"}, - groups = {cracky=3, mesecon_effector_on = 1}, + groups = {cracky=3}, sounds = default.node_sound_wood_defaults(), after_place_node = function(pos, placer) local meta = minetest.env:get_meta(pos) @@ -304,7 +304,7 @@ minetest.register_node("basic_machines:mover", { "CHECK why it doesnt work: 1. did you click OK in mover after changing setting 2. does it have battery, 3. does battery have enough fuel 4. did you set filter for taking out of chest?\n\n".. "IMPORTANT: Please read the help button inside machine before first use."; - local form = "size [5.5,5.5] textarea[0,0;6,7;help;MOVER INTRODUCTION;".. text.."]" + local form = "size [7.5,5.5] textarea[0,0.1;8,7;help;MOVER INTRODUCTION;".. text.."]" minetest.show_formspec(name, "basic_machines:intro_mover", form) @@ -328,6 +328,7 @@ minetest.register_node("basic_machines:mover", { end, allow_metadata_inventory_put = function(pos, listname, index, stack, player) + if minetest.is_protected(pos,player:get_player_name()) then return end if listname == "filter" then local meta = minetest.get_meta(pos); local itemname = stack:to_string() or ""; @@ -364,6 +365,7 @@ minetest.register_node("basic_machines:mover", { end, allow_metadata_inventory_take = function(pos, listname, index, stack, player) + if minetest.is_protected(pos,player:get_player_name()) then return end local meta = minetest.get_meta(pos); meta:set_float("upgrade",1); -- reset upgrade local form = get_mover_form(pos,player) @@ -371,7 +373,7 @@ minetest.register_node("basic_machines:mover", { return stack:get_count(); end, - mesecons = {effector = { + effector = { action_on = function (pos, node,ttl) if type(ttl)~="number" then ttl = 1 end @@ -839,7 +841,7 @@ minetest.register_node("basic_machines:mover", { } - } + }) -- anal retentive change in minetest 5.0.0 to minetest 5.1.0 changing unknown node warning into crash @@ -955,7 +957,14 @@ local function use_keypad(pos,ttl, again) -- position, time to live ( how many t return elseif bit == 36 then-- text starts with $, play sound text = string.sub(text,2) ; if not text or text == "" then return end - minetest.sound_play(text, {pos=pos,gain=1.0,max_hear_distance = 16,}) + local i = string.find(text, " ") + if not i then + minetest.sound_play(text, {pos=pos,gain=1.0,max_hear_distance = 16}) + else + local pitch = tonumber(string.sub(text,i+1)) or 1; + if pitch<0.01 or pitch > 10 then pitch = 1 end + minetest.sound_play(string.sub(text,1,i-1), {pos=pos,gain=1.0,max_hear_distance = 16,pitch = pitch}) + end end local tmeta = minetest.get_meta(tpos);if not tmeta then return end @@ -1059,9 +1068,8 @@ local function use_keypad(pos,ttl, again) -- position, time to live ( how many t --activate target local table = minetest.registered_nodes[node.name]; if not table then return end -- error - if not table.mesecons then return end -- error - if not table.mesecons.effector then return end -- error - local effector=table.mesecons.effector; + if not table.effector then return end -- error + local effector=table.effector; if mode == 3 then -- keypad in toggle mode local state = meta:get_int("state") or 0;state = 1-state; meta:set_int("state",state); @@ -1112,7 +1120,7 @@ end minetest.register_node("basic_machines:keypad", { description = "Keypad - basic way to activate machines by sending signal", tiles = {"keypad.png"}, - groups = {cracky=3, mesecon_effector_on = 1}, + groups = {cracky=3}, sounds = default.node_sound_wood_defaults(), after_place_node = function(pos, placer) local meta = minetest.env:get_meta(pos) @@ -1125,14 +1133,14 @@ minetest.register_node("basic_machines:keypad", { local name = placer:get_player_name();punchset[name] = {};punchset[name].state = 0 end, - mesecons = {effector = { + effector = { action_on = function (pos, node,ttl) if type(ttl)~="number" then ttl = 1 end if ttl<0 then return end -- machines_TTL prevents infinite recursion use_keypad(pos,0,0) -- activate just 1 time end - } }, + on_rightclick = function(pos, node, player, itemstack, pointed_thing) local meta = minetest.get_meta(pos); local privs = minetest.get_player_privs(player:get_player_name()); @@ -1150,15 +1158,15 @@ minetest.register_node("basic_machines:keypad", { pass = meta:get_string("pass"); local form = - "size[4.25,3.75]" .. -- width, height + "size[4.75,3.75]" .. -- width, height "bgcolor[#888888BB; false]" .. - "field[2.25,0.25;2.25,1;pass;Password: ;"..pass.."]" .. + "field[2.5,0.25;2.25,1;pass;Password: ;"..pass.."]" .. "field[0.25,2.5;3.25,1;text;text;".. text .."]" .. - "field[0.25,0.25;1,1;mode;mode;"..mode.."]".. "field[1.25,0.25;1,1;iter;repeat;".. iter .."]".. + "field[0.25,0.25;1,1;mode;mode;"..mode.."]".. "field[1.25,0.25;1.1,1;iter;repeat;".. iter .."]".. "label[0.,0.75;".. minetest.colorize("lawngreen","MODE: 1=OFF/2=ON/3=TOGGLE").."]".. "field[0.25,3.5;1,1;x0;target;"..x0.."] field[1.25,3.5;1,1;y0;;"..y0.."] field[2.25,3.5;1,1;z0;;"..z0.."]".. - "button_exit[3.25,3.25;1,1;help;help] button_exit[3.25,2.25;1,1;OK;OK]" + "button[3.25,3.25;1,1;help;help] button_exit[3.25,2.25;1,1;OK;OK]" @@ -1178,7 +1186,7 @@ minetest.register_node("basic_machines:keypad", { minetest.register_node("basic_machines:detector", { description = "Detector - can detect blocks/players/objects and activate machines", tiles = {"detector.png"}, - groups = {cracky=3, mesecon_effector_on = 1}, + groups = {cracky=3}, sounds = default.node_sound_wood_defaults(), after_place_node = function(pos, placer) local meta = minetest.env:get_meta(pos) @@ -1282,7 +1290,7 @@ minetest.register_node("basic_machines:detector", { return count end, - mesecons = {effector = { + effector = { action_on = function (pos, node,ttl) if type(ttl)~="number" then ttl = 1 end @@ -1444,9 +1452,8 @@ minetest.register_node("basic_machines:detector", { local node = minetest.get_node({x=x2,y=y2,z=z2});if not node.name then return end -- error local table = minetest.registered_nodes[node.name]; if not table then return end -- error - if not table.mesecons then return end -- error - if not table.mesecons.effector then return end -- error - local effector=table.mesecons.effector; + if not table.effector then return end -- error + local effector=table.effector; if trigger then -- activate target node if succesful meta:set_string("infotext", "detector: on"); @@ -1466,7 +1473,6 @@ minetest.register_node("basic_machines:detector", { end end } - } }) minetest.register_chatcommand("clockgen", { -- test: toggle machine running with clockgens, useful for debugging @@ -1505,10 +1511,10 @@ minetest.register_abm({ pos.y=pos.y+1; node = minetest.get_node(pos);if not node.name or node.name == "air" then return end local table = minetest.registered_nodes[node.name]; - if table and table.mesecons and table.mesecons.effector then -- check if all elements exist, safe cause it checks from left to right + if table and table.effector then -- check if all elements exist, safe cause it checks from left to right else return end - local effector=table.mesecons.effector; + local effector=table.effector; if effector.action_on then effector.action_on(pos,node,machines_TTL); end @@ -1518,7 +1524,7 @@ minetest.register_abm({ minetest.register_node("basic_machines:clockgen", { description = "Clock generator - use sparingly, continually activates top block", tiles = {"basic_machine_clock_generator.png"}, - groups = {cracky=3, mesecon_effector_on = 1}, + groups = {cracky=3}, sounds = default.node_sound_wood_defaults(), after_place_node = function(pos, placer) if minetest.find_node_near(pos, 15, {"basic_machines:clockgen"}) then @@ -1564,7 +1570,7 @@ local get_distributor_form = function(pos,player) if view == 0 then local form = "size[7,"..(0.75+(n)*0.75).."]" .. -- width, height - "label[0,-0.25;" .. minetest.colorize("lawngreen","target: x y z, MODE -2=only OFF, -1=NOT input/0/1=input, 2 = only ON") .. "]"; + "label[0,-0.25;" .. minetest.colorize("lawngreen","target: x y z, MODE") .. "]"; for i =1,n do form = form.."field[0.25,"..(0.5+(i-1)*0.75)..";1,1;x"..i..";;"..p[i].x.."] field[1.25,"..(0.5+(i-1)*0.75)..";1,1;y"..i..";;"..p[i].y.."] field[2.25,"..(0.5+(i-1)*0.75)..";1,1;z"..i..";;"..p[i].z.."] field [ 3.25,"..(0.5+(i-1)*0.75)..";1,1;active"..i..";;" .. active[i] .. "]" form = form .. "button[4.,"..(0.25+(i-1)*0.75)..";1.5,1;SHOW"..i..";SHOW "..i.."]".."button_exit[5.25,"..(0.25+(i-1)*0.75)..";1,1;SET"..i..";SET]".."button[6.25,"..(0.25+(i-1)*0.75)..";1,1;X"..i..";X]" @@ -1601,7 +1607,7 @@ end minetest.register_node("basic_machines:distributor", { description = "Distributor - can forward signal up to 16 different targets", tiles = {"distributor.png"}, - groups = {cracky=3, mesecon_effector_on = 1}, + groups = {cracky=3}, sounds = default.node_sound_wood_defaults(), after_place_node = function(pos, placer) local meta = minetest.env:get_meta(pos) @@ -1618,7 +1624,7 @@ minetest.register_node("basic_machines:distributor", { local name = placer:get_player_name();punchset[name] = {}; punchset[name].node = ""; punchset[name].state = 0 end, - mesecons = {effector = { + effector = { action_on = function (pos, node,ttl) if type(ttl)~="number" then ttl = 1 end @@ -1664,11 +1670,9 @@ minetest.register_node("basic_machines:distributor", { node = minetest.get_node(posf[i]);if not node.name then return end -- error table = minetest.registered_nodes[node.name]; - if table and table.mesecons and table.mesecons.effector then -- check if all elements exist, safe cause it checks from left to right - -- alternative way: overkill - --ret = pcall(function() if not table.mesecons.effector then end end); -- exception handling to determine if structure exists + if table and table.effector then -- check if all elements exist, safe cause it checks from left to right - local effector=table.mesecons.effector; + local effector=table.effector; local active_i = active[i]; if (active_i == 1 or active_i == 2) and effector.action_on then -- normal OR only forward input ON @@ -1735,8 +1739,8 @@ minetest.register_node("basic_machines:distributor", { if active[i]~=0 then node = minetest.get_node(posf[i]);if not node.name then return end -- error table = minetest.registered_nodes[node.name]; - if table and table.mesecons and table.mesecons.effector then - local effector=table.mesecons.effector; + if table and table.effector then + local effector=table.effector; if (active[i] == 1 or active[i]==-2) and effector.action_off then -- normal OR only forward input OFF effector.action_off(posf[i],node,ttl-1); elseif (active[i] == -1) and effector.action_on then @@ -1750,7 +1754,6 @@ minetest.register_node("basic_machines:distributor", { if delay>0 then minetest.after(delay, activate) else activate() end end - } }, on_rightclick = function(pos, node, player, itemstack, pointed_thing) local form = get_distributor_form(pos,player) @@ -1765,8 +1768,8 @@ minetest.register_node("basic_machines:distributor", { minetest.register_node("basic_machines:light_off", { description = "Light off", tiles = {"light_off.png"}, - groups = {cracky=3, mesecon_effector_on = 1}, - mesecons = {effector = { + groups = {cracky=3}, + effector = { action_on = function (pos, node,ttl) minetest.swap_node(pos,{name = "basic_machines:light_on"}); local meta = minetest.get_meta(pos); @@ -1783,8 +1786,7 @@ minetest.register_node("basic_machines:light_off", { end ) end - end - } + end }, }) @@ -1792,7 +1794,7 @@ minetest.register_node("basic_machines:light_off", { minetest.register_node("basic_machines:light_on", { description = "Light on", tiles = {"light.png"}, - groups = {cracky=3, mesecon_effector_on = 1}, + groups = {cracky=3}, light_source = LIGHT_MAX, after_place_node = function(pos, placer) local meta = minetest.get_meta(pos); @@ -1800,13 +1802,6 @@ minetest.register_node("basic_machines:light_on", { local deactivate = meta:get_int("deactivate"); local form = "size[2,2] field[0.25,0.5;2,1;deactivate;deactivate after ;"..deactivate.."]".."button_exit[0.,1;1,1;OK;OK]"; - minetest.after(5, -- fixes mesecons turning light off - function() - if minetest.get_node(pos).name == "basic_machines:light_off" then - minetest.swap_node(pos,{name = "basic_machines:light_on"}) - end - end - ) meta:set_string("formspec", form); end, on_receive_fields = function(pos, formname, fields, player) @@ -1822,7 +1817,7 @@ minetest.register_node("basic_machines:light_on", { end, - mesecons = {effector = { + effector = { action_off = function (pos, node,ttl) minetest.swap_node(pos,{name = "basic_machines:light_off"}); end, @@ -1831,7 +1826,6 @@ minetest.register_node("basic_machines:light_on", { local count = tonumber(meta:get_string("infotext")) or 0; meta:set_string("infotext",count+1); -- increase activate count end - } }, }) @@ -2175,7 +2169,7 @@ minetest.register_on_player_receive_fields(function(player,formname,fields) "\n\n FUEL CONSUMPTION depends on blocks to be moved and distance. For example, stone or tree is harder to move than dirt, harvesting wheat is very cheap and and moving lava is very hard.".. "\n\n UPGRADE mover by moving mese blocks in upgrade inventory. Each mese block increases mover range by 10, fuel consumption is divided by (number of mese blocks)+1 in upgrade. Max 10 blocks are used for upgrade. Dont forget to click OK to refresh after upgrade. ".. "\n\n Activate mover by keypad/detector signal or mese signal (if mesecons mod) ."; - local form = "size [6,7] textarea[0,0;6.5,8.5;help;MOVER HELP;".. text.."]" + local form = "size [8,7] textarea[0,0.1;8.5,8.5;help;MOVER HELP;".. text.."]" minetest.show_formspec(name, "basic_machines:help_mover", form) return end @@ -2304,13 +2298,14 @@ minetest.register_on_player_receive_fields(function(player,formname,fields) -- KEYPAD fname = "basic_machines:keypad_" + if string.sub(formname,0,string.len(fname)) == fname then local pos_s = string.sub(formname,string.len(fname)+1); local pos = minetest.string_to_pos(pos_s) local name = player:get_player_name(); if name==nil then return end local meta = minetest.get_meta(pos) local privs = minetest.get_player_privs(player:get_player_name()); if (minetest.is_protected(pos,name) and not privs.privs) or not fields then return end -- only builder can interact - + if fields.help then local text = "target : represents coordinates ( x, y, z ) relative to keypad. (0,0,0) is keypad itself, (0,1,0) is one node above, (0,-1,0) one node below. X coordinate axes goes from east to west, Y from down to up, Z from south to north.".. "\n\nPassword: enter password and press OK. Password will be encrypted. Next time you use keypad you will need to enter correct password to gain access.".. @@ -2335,7 +2330,8 @@ minetest.register_on_player_receive_fields(function(player,formname,fields) "\ntext replacement : Suppose keypad A is set with text \"@some @. text @!\" and there are blocks on top of keypad A with infotext '1' and '2'. Suppose we target B with A and activate A. Then text of keypad B will be set to \"some 1. text 2!\"".. "\nword extraction: Suppose similiar setup but now keypad A is set with text \"%1\". Then upon activation text of keypad B will be set to 1.st word of infotext"; - local form = "size [6,7] textarea[0,0;6.5,8.5;help;KEYPAD HELP;".. text.."]" + + local form = "size [8,7] textarea[0,0.1;8.5,8.5;help;KEYPAD HELP;".. minetest.formspec_escape(text).."]" minetest.show_formspec(name, "basic_machines:help_keypad", form) return end @@ -2626,7 +2622,7 @@ minetest.register_on_player_receive_fields(function(player,formname,fields) if fields.help == "help" then local text = "SETUP: to select target nodes for activation click SET then click target node.\n".. - "You can add more targets with ADD. To see where target node is click SHOW button next to it.\n".. + "You can add more targets with ADD. To see where target node is click SHOW button next to it.\n\n".. "4 numbers in each row represent (from left to right) : first 3 numbers are target coordinates x y z,\n".. "last number (MODE) controls how signal is passed to target. For example, to only pass OFF signal use -2,\n".. "to only pass ON use 2, -1 negates the signal, 1 = pass original signal, 0 blocks signal\n".. @@ -2638,17 +2634,15 @@ minetest.register_on_player_receive_fields(function(player,formname,fields) "some integers i,j,k. Then you need to configure first row of numbers in distributor:\n".. "by putting 0 as MODE it will start to listen. First number x = 0/1 controls if node listens to failed interact attempts around it, second\n".. "number y= -1/0/1 controls listening to chat (-1 additionaly mutes chat)"; - local form = "size [5.5,5.5] textarea[0,0;6,7;help;DISTRIBUTOR HELP;".. text.."]" + local form = "size [7.5,5.5] textarea[0,0.1;8,7;help;DISTRIBUTOR HELP;".. text.."]" minetest.show_formspec(name, "basic_machines:help_distributor", form) end end - end) - -- CRAFTS -- -- minetest.register_craft({ diff --git a/recycler.lua b/recycler.lua index f0884b4..f17318a 100644 --- a/recycler.lua +++ b/recycler.lua @@ -166,7 +166,7 @@ end minetest.register_node("basic_machines:recycler", { description = "Recycler - use to get some ingredients back from crafted things", tiles = {"recycler.png"}, - groups = {cracky=3, mesecon_effector_on = 1}, + groups = {cracky=3}, sounds = default.node_sound_wood_defaults(), after_place_node = function(pos, placer) local meta = minetest.get_meta(pos); @@ -207,13 +207,12 @@ minetest.register_node("basic_machines:recycler", { return 0; end, - mesecons = {effector = { + effector = { action_on = function (pos, node,ttl) if type(ttl)~="number" then ttl = 1 end if ttl<0 then return end -- machines_TTL prevents infinite recursion recycler_process(pos); end - } }, on_receive_fields = function(pos, formname, fields, sender) diff --git a/technic_power.lua b/technic_power.lua index 522f1cb..812fb3c 100644 --- a/technic_power.lua +++ b/technic_power.lua @@ -147,7 +147,7 @@ local machines_activate_furnace = minetest.registered_nodes["default:furnace"].o minetest.register_node("basic_machines:battery_0", { description = "battery - stores energy, generates energy from fuel, can power nearby machines, or accelerate/run furnace above it. Its upgradeable.", tiles = {"basic_machine_outlet.png","basic_machine_battery.png","basic_machine_battery_0.png"}, - groups = {cracky=3, mesecon_effector_on = 1}, + groups = {cracky=3}, sounds = default.node_sound_wood_defaults(), after_place_node = function(pos, placer) @@ -161,7 +161,7 @@ minetest.register_node("basic_machines:battery_0", { meta:set_float("energy",0); end, - mesecons = {effector = { + effector = { action_on = function (pos, node,ttl) if type(ttl)~="number" then ttl = 1 end if ttl<0 then return end -- machines_TTL prevents infinite recursion @@ -246,7 +246,7 @@ minetest.register_node("basic_machines:battery_0", { if full_coef_new ~= full_coef then minetest.swap_node(pos,{name = "basic_machines:battery_".. full_coef_new}) end end - }}, + }, on_rightclick = function(pos, node, player, itemstack, pointed_thing) local meta = minetest.get_meta(pos); @@ -366,7 +366,7 @@ end minetest.register_node("basic_machines:generator", { description = "Generator - very expensive, generates power crystals that provide power. Its upgradeable.", tiles = {"basic_machine_generator.png"}, - groups = {cracky=3, mesecon_effector_on = 1}, + groups = {cracky=3}, sounds = default.node_sound_wood_defaults(), after_place_node = function(pos, placer)