1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-01 13:08:05 +02:00

Script error fixes from the logs

This commit is contained in:
Piratux 2023-01-28 15:55:01 +02:00
parent 2dd3e1523c
commit 7930fdd32c
2 changed files with 65 additions and 55 deletions

View File

@ -7,6 +7,7 @@ local Classes = require 'maps.pirates.roles.classes'
local GuiCommon = require 'maps.pirates.gui.common'
local Public = {}
local _inspect = require 'utils.inspect'.inspect
local window_name = 'classes'
@ -187,34 +188,41 @@ function Public.full_update(player, force_refresh)
-- Update current content table
for i = 1, memory.class_entry_count do
local label = class_list_panel_table['player_label' .. i]
local class_entry = memory.unlocked_classes[i]
label.caption = class_entry.taken_by and game.players[class_entry.taken_by].name or ''
if label then
local class_entry = memory.unlocked_classes[i]
label.caption = class_entry.taken_by and game.players[class_entry.taken_by].name or ''
local black = {r=0, g=0, b=0}
local red = {r=1, g=0, b=0}
local black = {r=0, g=0, b=0}
local red = {r=1, g=0, b=0}
local button = class_list_panel_table['button' .. i]
if not class_entry.taken_by then
button.caption = {'pirates.gui_classes_take'}
button.tooltip = {'pirates.gui_classes_take_enabled_tooltip'}
button.style.font_color = black
button.style.hovered_font_color = black
button.style.clicked_font_color = black
button.enabled = true
elseif class_entry.taken_by == player.index then
button.caption = {'pirates.gui_classes_drop'}
button.tooltip = {'pirates.gui_classes_drop_tooltip'}
button.style.font_color = red
button.style.hovered_font_color = red
button.style.clicked_font_color = red
button.enabled = true
local button = class_list_panel_table['button' .. i]
if not class_entry.taken_by then
button.caption = {'pirates.gui_classes_take'}
button.tooltip = {'pirates.gui_classes_take_enabled_tooltip'}
button.style.font_color = black
button.style.hovered_font_color = black
button.style.clicked_font_color = black
button.enabled = true
elseif class_entry.taken_by == player.index then
button.caption = {'pirates.gui_classes_drop'}
button.tooltip = {'pirates.gui_classes_drop_tooltip'}
button.style.font_color = red
button.style.hovered_font_color = red
button.style.clicked_font_color = red
button.enabled = true
else
button.caption = {'pirates.gui_classes_take'}
button.tooltip = {'pirates.gui_classes_take_disabled_tooltip'}
button.style.font_color = black
button.style.hovered_font_color = black
button.style.clicked_font_color = black
button.enabled = false
end
else
button.caption = {'pirates.gui_classes_take'}
button.tooltip = {'pirates.gui_classes_take_disabled_tooltip'}
button.style.font_color = black
button.style.hovered_font_color = black
button.style.clicked_font_color = black
button.enabled = false
log('Error: Non-existant label index, here some debug info.')
log(_inspect(class_list_panel_table))
log(memory.class_entry_count)
log(memory.unlocked_classes)
end
end

View File

@ -68,38 +68,40 @@ function Public.reveal(cave_miner, surface, source_surface, position, brushsize)
local entity_position = entity.position
if (position.x - entity_position.x) ^ 2 + (position.y - entity_position.y) ^ 2 < brushsize_square then
local e = entity.clone({position = entity_position, surface = surface})
if e.name == 'market' then
rendering.draw_light(
{
sprite = 'utility/light_medium',
scale = 7,
intensity = 0.8,
minimum_darkness = 0,
oriented = true,
color = {255, 255, 255},
target = e,
surface = surface,
visible = true,
only_in_alt_mode = false
}
)
end
if entity.force.index == 2 then
e.active = true
table.insert(cave_miner.reveal_queue, {entity.type, entity.position.x, entity.position.y})
end
entity.destroy()
-- make revealing a spawner recursively reveal nearby ones too
if e.name == 'biter-spawner' or e.name == 'spitter-spawner' then
-- prevent spawners immediately spawning tons of biters for a while to give player a chance to clear them or run away
if destination.dynamic_data and destination.dynamic_data.disabled_wave_timer then
destination.dynamic_data.disabled_wave_timer = Balance.prevent_waves_from_spawning_in_cave_timer_length
if e and e.valid then
if e.name == 'market' then
rendering.draw_light(
{
sprite = 'utility/light_medium',
scale = 7,
intensity = 0.8,
minimum_darkness = 0,
oriented = true,
color = {255, 255, 255},
target = e,
surface = surface,
visible = true,
only_in_alt_mode = false
}
)
end
Public.reveal(cave_miner, surface, source_surface, entity_position, 15)
if entity.force.index == 2 then
e.active = true
table.insert(cave_miner.reveal_queue, {entity.type, entity.position.x, entity.position.y})
end
entity.destroy()
-- make revealing a spawner recursively reveal nearby ones too
if e.name == 'biter-spawner' or e.name == 'spitter-spawner' then
-- prevent spawners immediately spawning tons of biters for a while to give player a chance to clear them or run away
if destination.dynamic_data and destination.dynamic_data.disabled_wave_timer then
destination.dynamic_data.disabled_wave_timer = Balance.prevent_waves_from_spawning_in_cave_timer_length
end
Public.reveal(cave_miner, surface, source_surface, entity_position, 15)
end
end
end
end