for i = 1, 5 do
minetest.register_node("mesecons_battery:battery_charging_"..i, {
drawtype = "nodebox",
tiles = {"jeija_battery_charging.png"},
paramtype = "light",
is_ground_content = true,
walkable = true,
node_box = {
type = "fixed",
fixed = {
{-0.499, -0.499, -0.499, -0.4, 0.499, 0.499},
{ 0.4, -0.499, -0.499, 0.499, 0.499, 0.499},
{-0.499, -0.499, -0.499, 0.499, 0.499, -0.4 },
{-0.499, -0.499, 0.4, 0.499, 0.499, 0.499 },
{-0.4 , -0.5 , -0.4 , 0.4 , 1*(i/5)-0.5, 0.4}}
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
groups = {dig_immediate=2, mesecon = 2},
description="Battery",
on_construct = function(pos)
meta = minetest.env:get_meta(pos)
meta:set_int("batterystate", i*20-19)
meta:set_int("charging", 0)
end,
on_punch = function(pos, node, puncher)
local meta = minetest.env:get_meta(pos);
local batterystate = meta:get_int("batterystate")
local charging = meta:get_int("charging")
mesecon:swap_node(pos, "mesecons_battery:battery_discharging_" .. i)
meta:set_int("batterystate", batterystate)
meta:set_int("charging", charging)
end,
mesecons = {effector = {
action_on = function(pos, node)
minetest.env:get_meta(pos):set_int("charging", 1)
end,
action_off = function(pos, node)
minetest.env:get_meta(pos):set_int("charging", 0)
end,
}}
})
end
for i = 1, 5 do
minetest.register_node("mesecons_battery:battery_discharging_"..i, {
drawtype = "nodebox",
tiles = {"jeija_battery_discharging.png"},
paramtype = "light",
is_ground_content = true,
walkable = true,
node_box = {
type = "fixed",
fixed = {
{-0.499, -0.499, -0.499, -0.4, 0.499, 0.499},
{ 0.4, -0.499, -0.499, 0.499, 0.499, 0.499},
{-0.499, -0.499, -0.499, 0.499, 0.499, -0.4 },
{-0.499, -0.499, 0.4, 0.499, 0.499, 0.499 },
{-0.4 , -0.5 , -0.4 , 0.4 , 1*(i/5)-0.5, 0.4}}
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 2},
description="Battery",
on_construct = function(pos)
meta = minetest.env:get_meta(pos)
meta:set_int("batterystate", i*20-19)
meta:set_int("charging", 0)
end,
on_punch = function(pos, node, puncher)
local meta = minetest.env:get_meta(pos);
local batterystate = meta:get_int("batterystate")
local charging = meta:get_int("charging")
mesecon:swap_node(pos, "mesecons_battery:battery_charging_" .. i)
meta:set_int("batterystate", batterystate)
meta:set_int("charging", charging)
end,
mesecons = {
effector = {
action_on = function(pos, node)
minetest.env:get_meta(pos):set_int("charging", 1)
end,
action_off = function(pos, node)
minetest.env:get_meta(pos):set_int("charging", 0)
end,
},
receptor = {
state = mesecon.state.on
},
}
})
end
minetest.register_abm({
nodenames = {"mesecons_battery:battery_charging_1", "mesecons_battery:battery_charging_2", "mesecons_battery:battery_charging_3", "mesecons_battery:battery_charging_4", "mesecons_battery:battery_charging_5"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos);
if meta:get_int("charging") == 1 then
local batterystate = meta:get_int("batterystate")
local charging = meta:get_int("charging")
local name = node.name;
if batterystate < 100 then --change battery charging state
batterystate = batterystate + 1
else
mesecon:swap_node(pos, string.gsub(node.name, "charging", "discharging"))
end
if string.find(node.name, tostring(math.ceil(batterystate/20))) == nil then
node.name = string.gsub(node.name, tostring(math.ceil(batterystate/20)-1), tostring(math.ceil(batterystate/20))) --change node for new nodebox model
end
minetest.env:add_node(pos, node)
meta:set_int("batterystate", batterystate)
meta:set_int("charging", charging)
end
end,
})
minetest.register_abm({
nodenames = {"mesecons_battery:battery_discharging_1", "mesecons_battery:battery_discharging_2", "mesecons_battery:battery_discharging_3", "mesecons_battery:battery_discharging_4", "mesecons_battery:battery_discharging_5"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos);
local batterystate = meta:get_int("batterystate")
local charging = meta:get_int("charging")
local name = node.name;
if batterystate > 1 then --change battery charging state
batterystate = batterystate - 1
else
mesecon:swap_node(pos, string.gsub(node.name, "discharging", "charging"))
end
if string.find(node.name, tostring(math.ceil(batterystate/20))) == nil then
node.name = string.gsub(node.name, tostring(math.ceil(batterystate/20)+1), tostring(math.ceil(batterystate/20))) --change node for new nodebox model
end
minetest.env:add_node(pos, node)
meta:set_int("batterystate", batterystate)
meta:set_int("charging", charging)
end,
})
RealBadAngel wrote:Batteries, energy storage is what Technic is doing. Mesecons are TTL (logic) signals. IMHO if something was about to store mesecons signals it shouldnt be called a battery, but RAM.
yes it is and i will send a pm so others cant use itJeija wrote:Mesecon torches actually shouldn't overheat, they use ABMs... What does that lag machine look like?
Unfortunately your error message could mean anyhting... Is it reproducable, when does it occur?
thats what i noticed on my singleplayer worlds. it never ever locks up. i just have to reset it by turning the construction on and off manuallyVanessaE wrote:Well in my case, I watched jojoa built the circuit on my server. When the last piece is put into place, it causes the server to instantly lock at 100% CPU, stay there for a while (about two minutes), and then the server crashes and exits, which I presume is that stack overflow.
I have sent you a private message with construction info and a screenshot of the offending circuit, which I tested in singleplayer mode with mesecons pulled about an hour before writing this post.
I noticed that it doesn't always lag the server. Sometimes, it just works without issue.
15:50:36: ERROR[main]: ServerError: LuaError: error: ...orlds\Frantic Mine Ride\worldmods\carts/mesecons.lua:3: attempt to call method 'register_on_signal_on' (a nil value)
15:50:36: ERROR[main]: stack traceback:
qwrwed wrote:I get this error when trying to start the game:Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
15:50:36: ERROR[main]: ServerError: LuaError: error: ...orlds\Frantic Mine Ride\worldmods\carts/mesecons.lua:3: attempt to call method 'register_on_signal_on' (a nil value)
15:50:36: ERROR[main]: stack traceback:
Users browsing this forum: No registered users and 18 guests