From ef93a5ca8a6891e5bc6785c46055d5f77f54fbd6 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Sun, 4 Jan 2015 13:52:47 +0100 Subject: [PATCH] Updated Mesecons and Pipeworks mods - Updated pipeworks because of a bug related to vacuuming tubes, which has caused at least 5 crashs. - Updated mesecons too, because the mods are often used together. --- mods/mesecons/mesecons/util.lua | 42 +++++-------------- mods/mesecons/mesecons_gates/init.lua | 4 +- mods/mesecons/mesecons_luacontroller/init.lua | 3 +- .../mesecons/mesecons_pressureplates/init.lua | 6 --- mods/pipeworks/compat.lua | 4 +- mods/pipeworks/tubes.lua | 14 +++---- 6 files changed, 22 insertions(+), 51 deletions(-) diff --git a/mods/mesecons/mesecons/util.lua b/mods/mesecons/mesecons/util.lua index a64e00ce..ab2f32cf 100755 --- a/mods/mesecons/mesecons/util.lua +++ b/mods/mesecons/mesecons/util.lua @@ -6,18 +6,6 @@ function mesecon.move_node(pos, newpos) minetest.get_meta(pos):from_table(meta) end ---[[ new functions: -mesecon.flattenrules(allrules) -mesecon.rule2bit(findrule, allrules) -mesecon.rule2meta(findrule, allrules) -dec2bin(n) -mesecon.getstate(nodename, states) -mesecon.getbinstate(nodename, states) -mesecon.get_bit(binary, bit) -mesecon.set_bit(binary, bit, value) -mesecon.invertRule(r) ---]] - function mesecon.flattenrules(allrules) --[[ { @@ -71,7 +59,6 @@ end function mesecon.rule2metaindex(findrule, allrules) --get the metarule the rule is in, or allrules - if allrules[1].x then return nil end @@ -90,6 +77,8 @@ function mesecon.rule2metaindex(findrule, allrules) end function mesecon.rule2meta(findrule, allrules) + if #allrules == 0 then return {} end + local index = mesecon.rule2metaindex(findrule, allrules) if index == nil then if allrules[1].x then @@ -101,21 +90,12 @@ function mesecon.rule2meta(findrule, allrules) return allrules[index] end -if convert_base then - print( - "base2dec is tonumber(num,base1)\n".. - "commonlib needs dec2base(num,base2)\n".. - "and it needs base2base(num,base1,base2),\n".. - "which is dec2base(tonumber(num,base1),base2)" - ) -else - function dec2bin(n) - local x, y = math.floor(n / 2), n % 2 - if (n > 1) then - return dec2bin(x)..y - else - return ""..y - end +function mesecon.dec2bin(n) + local x, y = math.floor(n / 2), n % 2 + if (n > 1) then + return mesecon.dec2bin(x)..y + else + return ""..y end end @@ -129,7 +109,7 @@ function mesecon.getstate(nodename, states) end function mesecon.getbinstate(nodename, states) - return dec2bin(mesecon.getstate(nodename, states)-1) + return mesecon.dec2bin(mesecon.getstate(nodename, states)-1) end function mesecon.get_bit(binary,bit) @@ -141,11 +121,11 @@ end function mesecon.set_bit(binary,bit,value) if value == "1" then if not mesecon.get_bit(binary,bit) then - return dec2bin(tonumber(binary,2)+math.pow(2,bit-1)) + return mesecon.dec2bin(tonumber(binary,2)+math.pow(2,bit-1)) end elseif value == "0" then if mesecon.get_bit(binary,bit) then - return dec2bin(tonumber(binary,2)-math.pow(2,bit-1)) + return mesecon.dec2bin(tonumber(binary,2)-math.pow(2,bit-1)) end end return binary diff --git a/mods/mesecons/mesecons_gates/init.lua b/mods/mesecons/mesecons_gates/init.lua index 2b6771ab..78a3e835 100755 --- a/mods/mesecons/mesecons_gates/init.lua +++ b/mods/mesecons/mesecons_gates/init.lua @@ -78,7 +78,7 @@ function register_gate(name, inputnumber, assess, recipe) },{ tiles = {"jeija_microcontroller_bottom.png^".."jeija_gate_off.png^".. "jeija_gate_"..name..".png"}, - groups = {dig_immediate = 2}, + groups = {dig_immediate = 2, overheat = 1}, mesecons = { receptor = { state = "off", rules = gate_get_output_rules @@ -89,7 +89,7 @@ function register_gate(name, inputnumber, assess, recipe) },{ tiles = {"jeija_microcontroller_bottom.png^".."jeija_gate_on.png^".. "jeija_gate_"..name..".png"}, - groups = {dig_immediate = 2, not_in_creative_inventory = 1}, + groups = {dig_immediate = 2, not_in_creative_inventory = 1, overheat = 1}, mesecons = { receptor = { state = "on", rules = gate_get_output_rules diff --git a/mods/mesecons/mesecons_luacontroller/init.lua b/mods/mesecons/mesecons_luacontroller/init.lua index 4af91e7a..df681d9c 100755 --- a/mods/mesecons/mesecons_luacontroller/init.lua +++ b/mods/mesecons/mesecons_luacontroller/init.lua @@ -559,7 +559,6 @@ for d = 0, 1 do node_box = node_box, on_construct = reset_meta, on_receive_fields = on_receive_fields, - on_timer = handle_timer, sounds = default.node_sound_stone_defaults(), mesecons = mesecons, digiline = digiline, @@ -600,7 +599,7 @@ minetest.register_node(BASENAME .. "_burnt", { groups = {dig_immediate=2, not_in_creative_inventory=1}, drop = BASENAME.."0000", sunlight_propagates = true, - selection_box = selectionbox, + selection_box = selection_box, node_box = node_box, on_construct = reset_meta, on_receive_fields = on_receive_fields, diff --git a/mods/mesecons/mesecons_pressureplates/init.lua b/mods/mesecons/mesecons_pressureplates/init.lua index d01e6e5a..0fda1f3d 100755 --- a/mods/mesecons/mesecons_pressureplates/init.lua +++ b/mods/mesecons/mesecons_pressureplates/init.lua @@ -22,18 +22,12 @@ pp_on_timer = function (pos, elapsed) if objs[1] == nil and node.name == basename .. "_on" then minetest.add_node(pos, {name = basename .. "_off"}) mesecon.receptor_off(pos, mesecon.rules.pplate) - -- force deactivation of mesecon two blocks below (hacky) - if not mesecon.connected_to_receptor(two_below) then - mesecon.turnoff(two_below) - end else for k, obj in pairs(objs) do local objpos = obj:getpos() if objpos.y > pos.y-1 and objpos.y < pos.y then minetest.add_node(pos, {name = basename .. "_on"}) mesecon.receptor_on(pos, mesecon.rules.pplate ) - -- force activation of mesecon two blocks below (hacky) - mesecon.turnon(two_below) end end end diff --git a/mods/pipeworks/compat.lua b/mods/pipeworks/compat.lua index a1c1d453..21a5efc7 100755 --- a/mods/pipeworks/compat.lua +++ b/mods/pipeworks/compat.lua @@ -116,12 +116,12 @@ minetest.override_item("default:chest_locked", { groups = {choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1, tubedevice_receiver = 1}, tube = { insert_object = function(pos, node, stack, direction) - local meta = minetest.env:get_meta(pos) + local meta = minetest.get_meta(pos) local inv = meta:get_inventory() return inv:add_item("main", stack) end, can_insert = function(pos, node, stack, direction) - local meta = minetest.env:get_meta(pos) + local meta = minetest.get_meta(pos) local inv = meta:get_inventory() return inv:room_for_item("main", stack) end, diff --git a/mods/pipeworks/tubes.lua b/mods/pipeworks/tubes.lua index d4b4f775..149e78e2 100755 --- a/mods/pipeworks/tubes.lua +++ b/mods/pipeworks/tubes.lua @@ -317,10 +317,8 @@ if pipeworks.enable_mese_tube then update_formspec(pos) end, can_dig = function(pos, player) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - return (inv:is_empty("line1") and inv:is_empty("line2") and inv:is_empty("line3") and - inv:is_empty("line4") and inv:is_empty("line5") and inv:is_empty("line6")) + update_formspec(pos) -- so non-virtual items would be dropped for old tubes + return true end, allow_metadata_inventory_put = function(pos, listname, index, stack, player) update_formspec(pos) -- For old tubes @@ -520,7 +518,7 @@ if pipeworks.enable_mese_sand_tube then mese_sand_end_textures, mese_sand_short_texture,mese_sand_inv_texture, {groups = {mese_sand_tube = 1}, on_construct = function(pos) - local meta = minetest.env:get_meta(pos) + local meta = minetest.get_meta(pos) meta:set_int("dist", 0) meta:set_string("formspec", "size[2,1]".. @@ -528,7 +526,7 @@ if pipeworks.enable_mese_sand_tube then meta:set_string("infotext", "Adjustable Vacuuming Pneumatic Tube Segment") end, on_receive_fields = function(pos,formname,fields,sender) - local meta = minetest.env:get_meta(pos) + local meta = minetest.get_meta(pos) local dist _, dist = pcall(tonumber, fields.dist) if dist and 0 <= dist and dist <= 8 then meta:set_int("dist", dist) end @@ -538,7 +536,7 @@ if pipeworks.enable_mese_sand_tube then local function get_objects_with_square_radius(pos, rad) rad = rad + .5; local objs = {} - for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, math.sqrt(3)*rad)) do + for _,object in ipairs(minetest.get_objects_inside_radius(pos, math.sqrt(3)*rad)) do if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then local opos = object:getpos() if pos.x - rad <= opos.x and opos.x <= pos.x + rad and pos.y - rad <= opos.y and opos.y <= pos.y + rad and pos.z - rad <= opos.z and opos.z <= pos.z + rad then @@ -553,7 +551,7 @@ if pipeworks.enable_mese_sand_tube then interval = 1, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) - for _,object in ipairs(get_objects_with_square_radius(pos, minetest.env:get_meta(pos):get_int("dist"))) do + for _,object in ipairs(get_objects_with_square_radius(pos, minetest.get_meta(pos):get_int("dist"))) do if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then if object:get_luaentity().itemstring ~= "" then pipeworks.tube_inject_item(pos, pos, vector.new(0, 0, 0), object:get_luaentity().itemstring)