mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-07 13:31:40 +02:00
Fixed Lua errors
Changes: - Fixed Lua errors
This commit is contained in:
parent
9c8076684b
commit
b20def2974
@ -133,7 +133,7 @@ function Public.wave_size_rng() -- random variance in attack sizes
|
||||
local memory = Memory.get_crew_memory()
|
||||
local destination = Common.current_destination()
|
||||
|
||||
local rng_scale = Common.crew_scale()^(1/4) -- slightly dampen wave variance for small crews as they can't handle it
|
||||
local rng_scale = Balance.crew_scale()^(1/4) -- slightly dampen wave variance for small crews as they can't handle it
|
||||
|
||||
-- prevent situation where when player reveals spawner, he immediately gets surrounded by massive amount of biters (especially late game)
|
||||
if destination and destination.type == SurfacesCommon.enum.ISLAND then
|
||||
|
@ -592,8 +592,10 @@ local function maze_walls_resistance(event)
|
||||
if e2.valid then e2.destroy() end
|
||||
end
|
||||
else
|
||||
if string.sub(event.cause.force.name, 1, 4) == 'crew' then --player damage only
|
||||
event.entity.health = event.entity.health + damage * 0.9
|
||||
if event.cause and event.cause.valid then
|
||||
if string.sub(event.cause.force.name, 1, 4) == 'crew' then --player damage only
|
||||
event.entity.health = event.entity.health + damage * 0.9
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -707,34 +707,39 @@ function Public.click(event)
|
||||
|
||||
if eventname == 'join_crew' then
|
||||
local listbox = flow.ongoing_runs.body.ongoing_runs_listbox
|
||||
local crewid = tonumber(listbox.get_item(listbox.selected_index)[2])
|
||||
|
||||
local memory = global_memory.crew_memories[crewid]
|
||||
-- It was observed that "listbox.get_item(listbox.selected_index)" can produce "Index out of range error"
|
||||
-- This is to prevent that error.
|
||||
if listbox.selected_index >= 1 and listbox.selected_index <= #listbox.items then
|
||||
local crewid = tonumber(listbox.get_item(listbox.selected_index)[2])
|
||||
|
||||
-- If run is private
|
||||
if global_memory.crew_memories[crewid].run_is_private then
|
||||
if global_memory.crew_memories[crewid].private_run_password == flow.ongoing_runs.body.password_namefield.text then
|
||||
local memory = global_memory.crew_memories[crewid]
|
||||
|
||||
-- If run is private
|
||||
if global_memory.crew_memories[crewid].run_is_private then
|
||||
if global_memory.crew_memories[crewid].private_run_password == flow.ongoing_runs.body.password_namefield.text then
|
||||
Crew.join_crew(player, crewid)
|
||||
flow.ongoing_runs.body.join_private_crew_info.visible = false
|
||||
flow.ongoing_runs.body.password_namefield.visible = false
|
||||
|
||||
if memory.run_is_protected and (not Roles.captain_exists()) then
|
||||
Common.notify_player_expected(player, {'pirates.player_joins_protected_run_with_no_captain'})
|
||||
Common.notify_player_expected(player, {'pirates.create_new_crew_tip'})
|
||||
end
|
||||
else
|
||||
Common.notify_player_error(player, {'pirates.gui_join_private_run_error_wrong_password'})
|
||||
end
|
||||
else
|
||||
Crew.join_crew(player, crewid)
|
||||
flow.ongoing_runs.body.join_private_crew_info.visible = false
|
||||
flow.ongoing_runs.body.password_namefield.visible = false
|
||||
|
||||
if memory.run_is_protected and (not Roles.captain_exists()) then
|
||||
Common.notify_player_expected(player, {'pirates.player_joins_protected_run_with_no_captain'})
|
||||
Common.notify_player_expected(player, {'pirates.create_new_crew_tip'})
|
||||
end
|
||||
else
|
||||
Common.notify_player_error(player, {'pirates.gui_join_private_run_error_wrong_password'})
|
||||
end
|
||||
else
|
||||
Crew.join_crew(player, crewid)
|
||||
|
||||
if memory.run_is_protected and (not Roles.captain_exists()) then
|
||||
Common.notify_player_expected(player, {'pirates.player_joins_protected_run_with_no_captain'})
|
||||
Common.notify_player_expected(player, {'pirates.create_new_crew_tip'})
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if eventname == 'propose_crew' then
|
||||
|
@ -393,8 +393,13 @@ function Public.tick_quest_structure_entry_price_check()
|
||||
if removed > 0 then
|
||||
local count = 1
|
||||
for k, v in pairs(entry_price.batchRawMaterials) do
|
||||
red_invs[count].insert({name = k, count = v * removed / entry_price.batchSize});
|
||||
count = count + 1
|
||||
local item_count = v * removed / entry_price.batchSize
|
||||
if item_count > 0 then
|
||||
red_invs[count].insert({name = k, count = item_count});
|
||||
count = count + 1
|
||||
else
|
||||
log('Error (non-critical): item_count is not positive. v: ' .. v .. '; removed: ' .. removed .. '; entry_price.batchSize: ' .. entry_price.batchSize)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -402,8 +407,4 @@ function Public.tick_quest_structure_entry_price_check()
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return Public
|
Loading…
x
Reference in New Issue
Block a user