diff options
-rw-r--r-- | mesecons/actionqueue.lua | 5 | ||||
-rw-r--r-- | mesecons/services.lua | 2 | ||||
-rw-r--r-- | mesecons/settings.lua | 22 | ||||
-rw-r--r-- | mesecons_blinkyplant/init.lua | 115 | ||||
-rw-r--r-- | mesecons_detector/init.lua | 2 | ||||
-rw-r--r-- | mesecons_luacontroller/init.lua | 3 | ||||
-rw-r--r-- | mesecons_movestones/init.lua | 5 | ||||
-rw-r--r-- | mesecons_pistons/init.lua | 3 | ||||
-rw-r--r-- | mesecons_pressureplates/init.lua | 2 |
9 files changed, 57 insertions, 102 deletions
diff --git a/mesecons/actionqueue.lua b/mesecons/actionqueue.lua index 87fcee4..fa4079f 100644 --- a/mesecons/actionqueue.lua +++ b/mesecons/actionqueue.lua @@ -57,9 +57,12 @@ local get_highest_priority = function (actions) end local m_time = 0 +local resumetime = mesecon.setting("resumetime", 4) minetest.register_globalstep(function (dtime) m_time = m_time + dtime - if (m_time < MESECONS_RESUMETIME) then return end -- don't even try if server has not been running for XY seconds + -- don't even try if server has not been running for XY seconds; resumetime = time to wait + -- after starting the server before processing the ActionQueue, don't set this too low + if (m_time < resumetime) then return end local actions = mesecon.tablecopy(mesecon.queue.actions) local actions_now={} diff --git a/mesecons/services.lua b/mesecons/services.lua index 97043d3..36d9b80 100644 --- a/mesecons/services.lua +++ b/mesecons/services.lua @@ -61,7 +61,7 @@ mesecon.do_overheat = function(pos) heat = heat + 1 meta:set_int("heat", heat) - if heat < OVERHEAT_MAX then + if heat < mesecon.setting("overheat_max", 20) then mesecon.queue:add_action(pos, "cooldown", {}, 1, nil, 0) else return true diff --git a/mesecons/settings.lua b/mesecons/settings.lua index eb34f17..164cb57 100644 --- a/mesecons/settings.lua +++ b/mesecons/settings.lua @@ -1,14 +1,10 @@ -- SETTINGS
-BLINKY_PLANT_INTERVAL = 3
-NEW_STYLE_WIRES = true -- true = new nodebox wires, false = old raillike wires
-PRESSURE_PLATE_INTERVAL = 0.1
-OBJECT_DETECTOR_RADIUS = 6
-PISTON_MAXIMUM_PUSH = 15
-MOVESTONE_MAXIMUM_PUSH = 100
-MESECONS_RESUMETIME = 4 -- time to wait when starting the server before
- -- processing the ActionQueue, don't set this too low
-OVERHEAT_MAX = 20 -- maximum heat of any component that directly sends an output
- -- signal when the input changes (e.g. luacontroller, gates)
- -- Unit: actions per second, checks are every 1 second
-STACK_SIZE = 3000 -- Recursive functions will abort when this is reached. Therefore,
- -- this is also limits the maximum circuit size.
+function mesecon.setting(setting, default)
+ if type(default) == "bool" then
+ return minetest.setting_getbool("mesecon."..setting) or default
+ elseif type(default) == "string" then
+ return minetest.setting_get("mesecon."..setting) or default
+ elseif type(default) == "number" then
+ return tonumber(minetest.setting_get("mesecon."..setting) or default)
+ end
+end
diff --git a/mesecons_blinkyplant/init.lua b/mesecons_blinkyplant/init.lua index 5b3e471..c3bb3f7 100644 --- a/mesecons_blinkyplant/init.lua +++ b/mesecons_blinkyplant/init.lua @@ -1,98 +1,51 @@ -- The BLINKY_PLANT -minetest.register_node("mesecons_blinkyplant:blinky_plant", { - drawtype = "plantlike", - visual_scale = 1, - tiles = {"jeija_blinky_plant_off.png"}, - inventory_image = "jeija_blinky_plant_off.png", - walkable = false, - groups = {dig_immediate=3, not_in_creative_inventory=1}, - drop="mesecons_blinkyplant:blinky_plant_off 1", - description="Deactivated Blinky Plant", - sounds = default.node_sound_leaves_defaults(), - selection_box = { - type = "fixed", - fixed = {-0.3, -0.5, -0.3, 0.3, -0.5+0.7, 0.3}, - }, - mesecons = {receptor = { - state = mesecon.state.off - }}, - on_rightclick = function(pos, node, clicker) - minetest.set_node(pos, {name="mesecons_blinkyplant:blinky_plant_off"}) - end -}) -minetest.register_node("mesecons_blinkyplant:blinky_plant_off", { - drawtype = "plantlike", - visual_scale = 1, - tiles = {"jeija_blinky_plant_off.png"}, - inventory_image = "jeija_blinky_plant_off.png", - paramtype = "light", - walkable = false, - groups = {dig_immediate=3, mesecon=2}, - description="Blinky Plant", - sounds = default.node_sound_leaves_defaults(), - selection_box = { - type = "fixed", - fixed = {-0.3, -0.5, -0.3, 0.3, -0.5+0.7, 0.3}, - }, - mesecons = {receptor = { - state = mesecon.state.off - }}, - on_rightclick = function(pos, node, clicker) - minetest.set_node(pos, {name="mesecons_blinkyplant:blinky_plant"}) - end -}) +local toggle_timer = function (pos) + local timer = minetest.get_node_timer(pos) + if timer:is_started() then + timer:stop() + else + timer:start(mesecon.setting("blinky_plant_interval", 3)) + end +end -minetest.register_node("mesecons_blinkyplant:blinky_plant_on", { +local on_timer = function (pos) + local node = minetest.get_node(pos) + if(mesecon.flipstate(pos, node) == "on") then + mesecon.receptor_on(pos) + else + mesecon.receptor_off(pos) + end + toggle_timer(pos) +end + +mesecon.register_node("mesecons_blinkyplant:blinky_plant", { + description="Blinky Plant", drawtype = "plantlike", - visual_scale = 1, - tiles = {"jeija_blinky_plant_on.png"}, inventory_image = "jeija_blinky_plant_off.png", paramtype = "light", walkable = false, - groups = {dig_immediate=3, not_in_creative_inventory=1, mesecon=2}, - drop="mesecons_blinkyplant:blinky_plant_off 1", - light_source = LIGHT_MAX-7, - description = "Blinky Plant", sounds = default.node_sound_leaves_defaults(), selection_box = { type = "fixed", fixed = {-0.3, -0.5, -0.3, 0.3, -0.5+0.7, 0.3}, }, - mesecons = {receptor = { - state = mesecon.state.on - }}, - on_rightclick = function(pos, node, clicker) - minetest.set_node(pos, {name = "mesecons_blinkyplant:blinky_plant"}) - mesecon.receptor_off(pos) - end + on_timer = on_timer, + on_rightclick = toggle_timer, + on_construct = toggle_timer +},{ + tiles = {"jeija_blinky_plant_off.png"}, + groups = {dig_immediate=3}, + mesecons = {receptor = { state = mesecon.state.off }} +},{ + tiles = {"jeija_blinky_plant_on.png"}, + groups = {dig_immediate=3, not_in_creative_inventory=1}, + mesecons = {receptor = { state = mesecon.state.on }} }) minetest.register_craft({ output = "mesecons_blinkyplant:blinky_plant_off 1", - recipe = { - {"","group:mesecon_conductor_craftable",""}, - {"","group:mesecon_conductor_craftable",""}, - {"default:sapling","default:sapling","default:sapling"}, - } + recipe = { {"","group:mesecon_conductor_craftable",""}, + {"","group:mesecon_conductor_craftable",""}, + {"default:sapling","default:sapling","default:sapling"}} }) - -minetest.register_abm({ - nodenames = { - "mesecons_blinkyplant:blinky_plant_off", - "mesecons_blinkyplant:blinky_plant_on" - }, - interval = BLINKY_PLANT_INTERVAL, - chance = 1, - action = function(pos, node, active_object_count, active_object_count_wider) - if node.name == "mesecons_blinkyplant:blinky_plant_off" then - minetest.add_node(pos, {name="mesecons_blinkyplant:blinky_plant_on"}) - mesecon.receptor_on(pos) - else - minetest.add_node(pos, {name="mesecons_blinkyplant:blinky_plant_off"}) - mesecon.receptor_off(pos) - end - nodeupdate(pos) - end, -}) - diff --git a/mesecons_detector/init.lua b/mesecons_detector/init.lua index ab997ce..1a8595d 100644 --- a/mesecons_detector/init.lua +++ b/mesecons_detector/init.lua @@ -23,7 +23,7 @@ end -- returns true if player was found, false if not local object_detector_scan = function (pos) - local objs = minetest.get_objects_inside_radius(pos, OBJECT_DETECTOR_RADIUS) + local objs = minetest.get_objects_inside_radius(pos, mesecon.setting("detector_radius", 6)) for k, obj in pairs(objs) do local isname = obj:get_player_name() -- "" is returned if it is not a player; "" ~= nil! local scanname = minetest.get_meta(pos):get_string("scanname") diff --git a/mesecons_luacontroller/init.lua b/mesecons_luacontroller/init.lua index 0887a33..854e264 100644 --- a/mesecons_luacontroller/init.lua +++ b/mesecons_luacontroller/init.lua @@ -201,7 +201,8 @@ local create_environment = function(pos, mem, event) tostring = tostring, tonumber = tonumber, heat = minetest.get_meta(pos):get_int("heat"), - heat_max = OVERHEAT_MAX, + -- overheat_max Unit: actions per second, checks are every 1 second + heat_max = mesecon.setting("overheat_max", 20), string = { byte = string.byte, char = string.char, diff --git a/mesecons_movestones/init.lua b/mesecons_movestones/init.lua index 96d417a..dcbb00b 100644 --- a/mesecons_movestones/init.lua +++ b/mesecons_movestones/init.lua @@ -91,13 +91,14 @@ minetest.register_entity("mesecons_movestones:movestone_entity", { pos.x, pos.y, pos.z = math.floor(pos.x+0.5), math.floor(pos.y+0.5), math.floor(pos.z+0.5) local direction = mesecon.get_movestone_direction(pos) + local maxpush = mesecon.setting("movestone_max_push", 50) if not direction then -- no mesecon power --push only solid nodes local name = minetest.get_node(pos).name if name ~= "air" and name ~= "ignore" and ((not minetest.registered_nodes[name]) or minetest.registered_nodes[name].liquidtype == "none") then - mesecon.mvps_push(pos, self.lastdir, MOVESTONE_MAXIMUM_PUSH) + mesecon.mvps_push(pos, self.lastdir, maxpush) end minetest.add_node(pos, {name="mesecons_movestones:movestone"}) self.object:remove() @@ -105,7 +106,7 @@ minetest.register_entity("mesecons_movestones:movestone_entity", { end local success, stack, oldstack = - mesecon.mvps_push(pos, direction, MOVESTONE_MAXIMUM_PUSH) + mesecon.mvps_push(pos, direction, maxpush) if not success then -- Too large stack/stopper in the way minetest.add_node(pos, {name="mesecons_movestones:movestone"}) self.object:remove() diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index ee7c228..b247039 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -79,7 +79,8 @@ local piston_on = function(pos, node) local dir = piston_get_direction(pistonspec.dir, node) local np = mesecon.addPosRule(pos, dir) - local success, stack, oldstack = mesecon.mvps_push(np, dir, PISTON_MAXIMUM_PUSH) + local maxpush = mesecon.setting("piston_max_push", 15) + local success, stack, oldstack = mesecon.mvps_push(np, dir, maxpush) if success then minetest.add_node(pos, {param2 = node.param2, name = pistonspec.onname}) minetest.add_node(np, {param2 = node.param2, name = pistonspec.pusher}) diff --git a/mesecons_pressureplates/init.lua b/mesecons_pressureplates/init.lua index e9fdf7f..d01e6e5 100644 --- a/mesecons_pressureplates/init.lua +++ b/mesecons_pressureplates/init.lua @@ -59,7 +59,7 @@ function mesecon.register_pressure_plate(basename, description, textures_off, te pressureplate_basename = basename, on_timer = pp_on_timer, on_construct = function(pos) - minetest.get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL) + minetest.get_node_timer(pos):start(mesecon.setting("pplate_interval", 0.1)) end, },{ mesecons = {receptor = { state = mesecon.state.off, rules = mesecon.rules.pplate }}, |