1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-07-15 01:04:17 +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 GuiCommon = require 'maps.pirates.gui.common'
local Public = {} local Public = {}
local _inspect = require 'utils.inspect'.inspect
local window_name = 'classes' local window_name = 'classes'
@ -187,34 +188,41 @@ function Public.full_update(player, force_refresh)
-- Update current content table -- Update current content table
for i = 1, memory.class_entry_count do for i = 1, memory.class_entry_count do
local label = class_list_panel_table['player_label' .. i] local label = class_list_panel_table['player_label' .. i]
local class_entry = memory.unlocked_classes[i] if label then
label.caption = class_entry.taken_by and game.players[class_entry.taken_by].name or '' 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 black = {r=0, g=0, b=0}
local red = {r=1, g=0, b=0} local red = {r=1, g=0, b=0}
local button = class_list_panel_table['button' .. i] local button = class_list_panel_table['button' .. i]
if not class_entry.taken_by then if not class_entry.taken_by then
button.caption = {'pirates.gui_classes_take'} button.caption = {'pirates.gui_classes_take'}
button.tooltip = {'pirates.gui_classes_take_enabled_tooltip'} button.tooltip = {'pirates.gui_classes_take_enabled_tooltip'}
button.style.font_color = black button.style.font_color = black
button.style.hovered_font_color = black button.style.hovered_font_color = black
button.style.clicked_font_color = black button.style.clicked_font_color = black
button.enabled = true button.enabled = true
elseif class_entry.taken_by == player.index then elseif class_entry.taken_by == player.index then
button.caption = {'pirates.gui_classes_drop'} button.caption = {'pirates.gui_classes_drop'}
button.tooltip = {'pirates.gui_classes_drop_tooltip'} button.tooltip = {'pirates.gui_classes_drop_tooltip'}
button.style.font_color = red button.style.font_color = red
button.style.hovered_font_color = red button.style.hovered_font_color = red
button.style.clicked_font_color = red button.style.clicked_font_color = red
button.enabled = true 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 else
button.caption = {'pirates.gui_classes_take'} log('Error: Non-existant label index, here some debug info.')
button.tooltip = {'pirates.gui_classes_take_disabled_tooltip'} log(_inspect(class_list_panel_table))
button.style.font_color = black log(memory.class_entry_count)
button.style.hovered_font_color = black log(memory.unlocked_classes)
button.style.clicked_font_color = black
button.enabled = false
end end
end end

View File

@ -68,38 +68,40 @@ function Public.reveal(cave_miner, surface, source_surface, position, brushsize)
local entity_position = entity.position local entity_position = entity.position
if (position.x - entity_position.x) ^ 2 + (position.y - entity_position.y) ^ 2 < brushsize_square then 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}) local e = entity.clone({position = entity_position, surface = surface})
if e.name == 'market' then if e and e.valid then
rendering.draw_light( if e.name == 'market' then
{ rendering.draw_light(
sprite = 'utility/light_medium', {
scale = 7, sprite = 'utility/light_medium',
intensity = 0.8, scale = 7,
minimum_darkness = 0, intensity = 0.8,
oriented = true, minimum_darkness = 0,
color = {255, 255, 255}, oriented = true,
target = e, color = {255, 255, 255},
surface = surface, target = e,
visible = true, surface = surface,
only_in_alt_mode = false 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
end 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 end
end end