Standalone Powercell, Lighting Fix's
Powercells can now power machines so long as they are charged up and connected to a machine/light bulb etc ie powercells can be a provider on there own now. Lighting fixed a few issues: Lights weren't getting power if you added them to a network while it was on powercell power rather than provider power. Floodlights had the wrong drops listed
This commit is contained in:
parent
12eacba8f6
commit
5d14083f2c
@ -395,6 +395,24 @@ function elepower_lighting.rot_and_place(itemstack, placer, pointed_thing)
|
||||
return minetest.item_place(itemstack, placer, pointed_thing, param2)
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Light State Function --
|
||||
-- "Active", "Off", "Out of Power" --
|
||||
-------------------------------------
|
||||
function elepower_lighting.status(on_off,storage,usage)
|
||||
local status = "Active"
|
||||
|
||||
if on_off == 0 then
|
||||
status = "Off"
|
||||
|
||||
elseif storage < usage then
|
||||
status = "Out of Power!"
|
||||
|
||||
end
|
||||
|
||||
return status
|
||||
end
|
||||
|
||||
------------------------------------
|
||||
-- Main Lighting timer, what uses --
|
||||
-- EpU's and allows lights to be --
|
||||
@ -539,7 +557,8 @@ function elepower_lighting.light_timer(pos)
|
||||
end
|
||||
end
|
||||
|
||||
meta:set_string("infotext", name .. "\n" .. ele.capacity_text(capacity, storage))
|
||||
local status = elepower_lighting.status(on_off,pow_percent.storage,pow_percent.usage)
|
||||
meta:set_string("infotext", name.." "..status.."\n" .. ele.capacity_text(capacity, storage))
|
||||
|
||||
if light_shape == "flood" then
|
||||
local tilt = meta:get_int("tilt") or 0
|
||||
@ -709,9 +728,10 @@ function elepower_lighting.light_timer_colored(pos)
|
||||
|
||||
end
|
||||
end
|
||||
local status = elepower_lighting.status(on_off,pow_percent.storage,pow_percent.usage)
|
||||
|
||||
meta:set_string("formspec", get_formspec_panel_color(pow_percent,color_mode,color_sync))
|
||||
meta:set_string("infotext", name .. "\n" .. ele.capacity_text(capacity, storage))
|
||||
meta:set_string("infotext", name .." "..status.. "\n" .. ele.capacity_text(capacity, storage))
|
||||
|
||||
cycles = 0
|
||||
end
|
||||
@ -880,6 +900,7 @@ end
|
||||
function elepower_lighting.light_construct(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("on_off",1)
|
||||
meta:set_string("infotext", "Active")
|
||||
|
||||
local is_colored = minetest.registered_items[minetest.get_node(pos).name].palette or nil
|
||||
|
||||
|
@ -13,15 +13,15 @@
|
||||
------------------------------------------------------
|
||||
|
||||
local flood_light_angles = {
|
||||
xp0_yp0 = {groups = {cracky = 1, ele_user = 1, ele_lighting = 1}, drops = "elepower_lighting:incandescent_floodlight_xp0_yp0"},
|
||||
xp0_yp20 = {groups = {cracky = 1, ele_user = 1, not_in_creative_inventory = 1}, drops = "elepower_lighting:incandescent_floodlight_xp0_yp0"},
|
||||
xp0_yn20 = {groups = {cracky = 1, ele_user = 1, not_in_creative_inventory = 1}, drops = "elepower_lighting:incandescent_floodlight_xp0_yp0"},
|
||||
xp45_yp0 = {groups = {cracky = 1, ele_user = 1, not_in_creative_inventory = 1}, drops = "elepower_lighting:incandescent_floodlight_xp0_yp0"},
|
||||
xp45_yp20 = {groups = {cracky = 1, ele_user = 1, not_in_creative_inventory = 1}, drops = "elepower_lighting:incandescent_floodlight_xp0_yp0"},
|
||||
xp45_yn20 = {groups = {cracky = 1, ele_user = 1, not_in_creative_inventory = 1}, drops = "elepower_lighting:incandescent_floodlight_xp0_yp0"},
|
||||
xn45_yp0 = {groups = {cracky = 1, ele_user = 1, not_in_creative_inventory = 1}, drops = "elepower_lighting:incandescent_floodlight_xp0_yp0"},
|
||||
xn45_yp20 = {groups = {cracky = 1, ele_user = 1, not_in_creative_inventory = 1}, drops = "elepower_lighting:incandescent_floodlight_xp0_yp0"},
|
||||
xn45_yn20 = {groups = {cracky = 1, ele_user = 1, not_in_creative_inventory = 1}, drops = "elepower_lighting:incandescent_floodlight_xp0_yp0"}
|
||||
xp0_yp0 = {groups = {cracky = 1, ele_user = 1, ele_lighting = 1}},
|
||||
xp0_yp20 = {groups = {cracky = 1, ele_user = 1, not_in_creative_inventory = 1}},
|
||||
xp0_yn20 = {groups = {cracky = 1, ele_user = 1, not_in_creative_inventory = 1}},
|
||||
xp45_yp0 = {groups = {cracky = 1, ele_user = 1, not_in_creative_inventory = 1}},
|
||||
xp45_yp20 = {groups = {cracky = 1, ele_user = 1, not_in_creative_inventory = 1}},
|
||||
xp45_yn20 = {groups = {cracky = 1, ele_user = 1, not_in_creative_inventory = 1}},
|
||||
xn45_yp0 = {groups = {cracky = 1, ele_user = 1, not_in_creative_inventory = 1}},
|
||||
xn45_yp20 = {groups = {cracky = 1, ele_user = 1, not_in_creative_inventory = 1}},
|
||||
xn45_yn20 = {groups = {cracky = 1, ele_user = 1, not_in_creative_inventory = 1}}
|
||||
}
|
||||
|
||||
for angle,def in pairs(flood_light_angles) do
|
||||
@ -46,7 +46,7 @@ for angle,def in pairs(flood_light_angles) do
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
drops = def.drops,
|
||||
drops = "elepower_lighting:incandescent_floodlight_xp0_yp0",
|
||||
groups = def.groups,
|
||||
ele_capacity = 64,
|
||||
ele_usage = 8,
|
||||
@ -84,7 +84,7 @@ for angle,def in pairs(flood_light_angles) do
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
drops = def.drops,
|
||||
drops = "elepower_lighting:cf_floodlight_xp0_yp0",
|
||||
groups = def.groups,
|
||||
ele_capacity = 128,
|
||||
ele_usage = 4,
|
||||
@ -122,7 +122,7 @@ for angle,def in pairs(flood_light_angles) do
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
drops = def.drops,
|
||||
drops = "elepower_lighting:led_floodlight_xp0_yp0",
|
||||
groups = def.groups,
|
||||
ele_capacity = 192,
|
||||
ele_usage = 2,
|
||||
|
@ -136,8 +136,13 @@ local function discover_branches(pr_pos, positions)
|
||||
end
|
||||
end
|
||||
|
||||
-- Add self to providers
|
||||
-- self/triggered abm node can be provider or powercell/user_gets
|
||||
-- add to correct table provider or user
|
||||
if ele.helpers.get_item_group(provider.name, "ele_storage") then
|
||||
add_node(users, pr_pos, pnodeid, "ele_storage")
|
||||
else
|
||||
add_node(providers, pr_pos, pnodeid)
|
||||
end
|
||||
|
||||
users = ele.helpers.flatten(users)
|
||||
providers = ele.helpers.flatten(providers)
|
||||
@ -182,11 +187,12 @@ end
|
||||
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:ele_provider"},
|
||||
nodenames = {"group:ele_provider","group:ele_storage"},
|
||||
label = "elepower Power Transfer Tick",
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta1 = nil
|
||||
|
||||
@ -205,6 +211,7 @@ minetest.register_abm({
|
||||
}
|
||||
|
||||
local branches = {}
|
||||
|
||||
for _,pos1 in ipairs(positions) do
|
||||
local pnode = minetest.get_node(pos1)
|
||||
local name = pnode.name
|
||||
@ -228,6 +235,18 @@ minetest.register_abm({
|
||||
-- Find all users and providers
|
||||
users, providers = discover_branches(pos, branches)
|
||||
|
||||
-- Standalone Powercell check
|
||||
if ele.helpers.get_item_group(node.name, "ele_storage") and #providers >= 1 then
|
||||
-- abm hits powercell but network has provider end here
|
||||
-- as power distribution will be handled on provider abm hit
|
||||
-- minetest.debug("provider present")
|
||||
return
|
||||
elseif ele.helpers.get_item_group(node.name, "ele_provider") then
|
||||
--minetest.debug("Provider")
|
||||
else
|
||||
--minetest.debug("solo storage")
|
||||
end
|
||||
|
||||
-- Calculate power data for providers
|
||||
local pw_supply = 0
|
||||
local pw_demand = 0
|
||||
|
Loading…
Reference in New Issue
Block a user