mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
.
This commit is contained in:
@@ -94,8 +94,8 @@ end
|
||||
-- @tparam string location the location tag that is in the config file
|
||||
function Public.spawn_compilatron(surface, location)
|
||||
local position = locations[location]
|
||||
local pos = surface.find_non_colliding_position("small-biter", position, 1.5, 0.5)
|
||||
local compi = surface.create_entity{ name = "small-biter", position = pos, force = game.forces.neutral }
|
||||
local pos = surface.find_non_colliding_position("behemoth-biter", position, 1.5, 0.5)
|
||||
local compi = surface.create_entity{ name = "behemoth-biter", position = pos, force = game.forces.neutral }
|
||||
Public.add_compilatron(compi, location)
|
||||
end
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ local vlayer_data = {
|
||||
properties = {
|
||||
total_surface_area = 0,
|
||||
used_surface_area = 0,
|
||||
total_production = 0,
|
||||
production = 0,
|
||||
discharge = 0,
|
||||
capacity = 0,
|
||||
@@ -155,7 +156,7 @@ local function get_production_multiplier()
|
||||
end
|
||||
|
||||
if surface.darkness then
|
||||
-- We are using a real surface, our config does not contain 'darkness'
|
||||
-- We are using a real surface, our config does not contain "darkness"
|
||||
local brightness = 1 - surface.darkness
|
||||
|
||||
if brightness >= surface.min_brightness then
|
||||
@@ -212,7 +213,9 @@ function vlayer.allocate_item(item_name, count)
|
||||
assert(item_properties, "Item not allowed in vlayer: " .. tostring(item_name))
|
||||
|
||||
if item_properties.production then
|
||||
vlayer_data.properties.production = vlayer_data.properties.production + item_properties.production * count
|
||||
local nc = item_properties.production * count
|
||||
vlayer_data.properties.production = vlayer_data.properties.production + nc
|
||||
vlayer_data.properties.total_production = vlayer_data.properties.total_production + nc
|
||||
end
|
||||
|
||||
if item_properties.capacity then
|
||||
@@ -232,6 +235,14 @@ function vlayer.allocate_item(item_name, count)
|
||||
end
|
||||
end
|
||||
|
||||
function vlayer.unable_alloc_item_pwr_calc(item_name, count)
|
||||
local item_properties = config.allowed_items[item_name]
|
||||
|
||||
if item_properties.production then
|
||||
vlayer_data.properties.total_production = vlayer_data.properties.total_production + item_properties.production * count
|
||||
end
|
||||
end
|
||||
|
||||
-- For all allowed items, setup their starting values, default 0
|
||||
for item_name, properties in pairs(config.allowed_items) do
|
||||
vlayer_data.storage.items[item_name] = properties.starting_value or 0
|
||||
@@ -260,7 +271,9 @@ function vlayer.insert_item(item_name, count)
|
||||
vlayer.allocate_item(item_name, allocate_count)
|
||||
end
|
||||
|
||||
local nc = count - allocate_count
|
||||
vlayer_data.storage.unallocated[item_name] = vlayer_data.storage.unallocated[item_name] + count - allocate_count
|
||||
vlayer.unable_alloc_item_pwr_calc(item_name, nc)
|
||||
else
|
||||
vlayer.allocate_item(item_name, count)
|
||||
end
|
||||
@@ -456,6 +469,7 @@ local function handle_unallocated()
|
||||
if allocation_count > 0 then
|
||||
vlayer_data.storage.unallocated[item_name] = vlayer_data.storage.unallocated[item_name] - allocation_count
|
||||
vlayer.allocate_item(item_name, allocation_count)
|
||||
vlayer.unable_alloc_item_pwr_calc(item_name, -allocation_count)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -464,15 +478,19 @@ end
|
||||
function vlayer.get_statistics()
|
||||
local vdp = vlayer_data.properties.production * mega
|
||||
local gdm = get_production_multiplier()
|
||||
local gsm = get_sustained_multiplier()
|
||||
local gald = get_actual_land_defecit()
|
||||
|
||||
return {
|
||||
total_surface_area = vlayer_data.properties.total_surface_area,
|
||||
used_surface_area = vlayer_data.properties.used_surface_area,
|
||||
remaining_surface_area = get_actual_land_defecit(),
|
||||
remaining_surface_area = gald,
|
||||
surface_area = vlayer_data.properties.total_surface_area - gald,
|
||||
production_multiplier = gdm,
|
||||
energy_max = vdp,
|
||||
energy_production = vdp * gdm,
|
||||
energy_sustained = vdp * get_sustained_multiplier(),
|
||||
energy_total_production = vlayer_data.properties.total_production * gsm * mega,
|
||||
energy_sustained = vdp * gsm,
|
||||
energy_capacity = vlayer_data.properties.capacity * mega,
|
||||
energy_storage = vlayer_data.storage.energy,
|
||||
day_time = math.floor(vlayer_data.surface.daytime * vlayer_data.surface.ticks_per_day),
|
||||
|
||||
@@ -177,9 +177,9 @@ local vlayer_gui_display_item_accumulator_count =
|
||||
font = "heading-2",
|
||||
}
|
||||
|
||||
--- Display label for the remaining surface area
|
||||
-- @element vlayer_gui_display_signal_remaining_surface_area_name
|
||||
local vlayer_gui_display_signal_remaining_surface_area_name =
|
||||
--- Display label for the surface area
|
||||
-- @element vlayer_gui_display_signal_surface_area_name
|
||||
local vlayer_gui_display_signal_surface_area_name =
|
||||
Gui.element{
|
||||
type = "label",
|
||||
name = "vlayer_display_signal_remaining_surface_area_name",
|
||||
@@ -190,16 +190,16 @@ local vlayer_gui_display_signal_remaining_surface_area_name =
|
||||
width = 200,
|
||||
}
|
||||
|
||||
local vlayer_gui_display_signal_remaining_surface_area_count =
|
||||
local vlayer_gui_display_signal_surface_area_count =
|
||||
Gui.element{
|
||||
type = "label",
|
||||
name = "vlayer_display_signal_remaining_surface_area_count",
|
||||
caption = "0",
|
||||
style = "heading_2_label",
|
||||
type = "progressbar",
|
||||
name = "vlayer_display_signal_surface_area_count",
|
||||
caption = "",
|
||||
value = 0,
|
||||
style = "electric_satisfaction_statistics_progressbar",
|
||||
}:style{
|
||||
width = 200,
|
||||
height = 28,
|
||||
horizontal_align = "right",
|
||||
font = "heading-2",
|
||||
}
|
||||
|
||||
--- Display label for the sustained energy production
|
||||
@@ -217,14 +217,14 @@ local vlayer_gui_display_signal_sustained_name =
|
||||
|
||||
local vlayer_gui_display_signal_sustained_count =
|
||||
Gui.element{
|
||||
type = "label",
|
||||
type = "progressbar",
|
||||
name = "vlayer_display_signal_sustained_count",
|
||||
caption = "0",
|
||||
style = "heading_2_label",
|
||||
caption = "",
|
||||
value = 0,
|
||||
style = "electric_satisfaction_statistics_progressbar",
|
||||
}:style{
|
||||
width = 200,
|
||||
height = 28,
|
||||
horizontal_align = "right",
|
||||
font = "heading-2",
|
||||
}
|
||||
|
||||
--- Display label for the current energy production
|
||||
@@ -288,8 +288,8 @@ local vlayer_display_set =
|
||||
vlayer_gui_display_item_solar_count(disp)
|
||||
vlayer_gui_display_item_accumulator_name(disp)
|
||||
vlayer_gui_display_item_accumulator_count(disp)
|
||||
vlayer_gui_display_signal_remaining_surface_area_name(disp)
|
||||
vlayer_gui_display_signal_remaining_surface_area_count(disp)
|
||||
vlayer_gui_display_signal_surface_area_name(disp)
|
||||
vlayer_gui_display_signal_surface_area_count(disp)
|
||||
vlayer_gui_display_signal_sustained_name(disp)
|
||||
vlayer_gui_display_signal_sustained_count(disp)
|
||||
vlayer_gui_display_signal_production_name(disp)
|
||||
@@ -493,11 +493,13 @@ Event.on_nth_tick(config.update_tick_gui, function(_)
|
||||
val = (items_alloc["accumulator"] / math.max(items["accumulator"], 1)),
|
||||
cap = format_number(items_alloc["accumulator"], false) .. " / " .. format_number(items["accumulator"], false),
|
||||
},
|
||||
[vlayer_gui_display_signal_remaining_surface_area_count.name] = {
|
||||
cap = format_number(stats.remaining_surface_area, false),
|
||||
[vlayer_gui_display_signal_surface_area_count.name] = {
|
||||
val = (stats.total_surface_area / math.max(stats.surface_area, 1)),
|
||||
cap = format_number(stats.remaining_surface_area)
|
||||
},
|
||||
[vlayer_gui_display_signal_sustained_count.name] = {
|
||||
cap = format_energy(stats.energy_sustained, "W"),
|
||||
val = (stats.energy_sustained / math.max(stats.energy_total_production, 1)),
|
||||
cap = format_energy(stats.energy_sustained, "W") .. " / " .. format_energy(stats.energy_total_production, "W")
|
||||
},
|
||||
[vlayer_gui_display_signal_production_count.name] = {
|
||||
val = (stats.energy_production / math.max(stats.energy_max, 1)),
|
||||
|
||||
Reference in New Issue
Block a user