1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-04 00:15:45 +02:00

Fix issues found by luacheck

This commit is contained in:
Eric Anderson 2022-03-29 22:44:51 -07:00
parent 79e9bdee7e
commit 9abbd226da
6 changed files with 21 additions and 24 deletions

View File

@ -53,8 +53,8 @@ end
local function dirtlands(surface, room) local function dirtlands(surface, room)
local dungeontable = DungeonsTable.get_dungeontable() local dungeontable = DungeonsTable.get_dungeontable()
max_spawn = math.floor(dungeontable.depth[surface.index] / 8) local max_spawn = math.floor(dungeontable.depth[surface.index] / 8)
max_worm = max_spawn + 1 local max_worm = max_spawn + 1
local path_tile = 'dirt-' .. math_random(1, 3) local path_tile = 'dirt-' .. math_random(1, 3)
for _, tile in pairs(room.path_tiles) do for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = path_tile, position = tile.position}}, true) surface.set_tiles({{name = path_tile, position = tile.position}}, true)

View File

@ -363,18 +363,6 @@ end
-- --
-- 1000 science (all types) = 9822 coal, 13492 stone, 48736 copper, 63018 iron -- 1000 science (all types) = 9822 coal, 13492 stone, 48736 copper, 63018 iron
-- 20 27 98 127 max-stones -- 20 27 98 127 max-stones
local function get_ore_amount_old(surface_index)
local scaling = game.forces.player.mining_drill_productivity_bonus
local amount = 5000 * Public.get_dungeon_evolution_factor(surface_index) * (1 + scaling)
if amount > 500 then
amount = 500
end
amount = math_random(math_floor(amount * 0.7), math_floor(amount * 1.3))
if amount < 1 then
amount = 1
end
return amount
end
local function get_ore_amount(surface_index) local function get_ore_amount(surface_index)
local d = DungeonsTable.get_dungeontable() local d = DungeonsTable.get_dungeontable()
@ -440,7 +428,7 @@ function Public.rocky_loot(event)
end end
local player = game.players[event.player_index] local player = game.players[event.player_index]
local amount = math.ceil(get_ore_amount(player.surface.index)) local amount = math.ceil(get_ore_amount(player.surface.index))
local rock_mining = {} local rock_mining
local floor = player.surface.index - DungeonsTable.get_dungeontable().original_surface_index; local floor = player.surface.index - DungeonsTable.get_dungeontable().original_surface_index;
if floor < 10 then if floor < 10 then
-- early game science uses less copper and more iron/stone -- early game science uses less copper and more iron/stone

View File

@ -75,12 +75,12 @@ function Fixed.Init()
end end
end end
local function get_surface_research(index) local function get_surface_research(index)
return locked_researches[floor_num(index)] return locked_researches[floor_num(index)]
end end
function Fixed.techs_remain(index) function Fixed.techs_remain(index)
local tech = get_surface_research(index) local tech = get_surface_research(index)
if tech and game.forces.player.technologies[tech].enabled == false then if tech and game.forces.player.technologies[tech].enabled == false then
return 1 return 1
end end
@ -104,6 +104,11 @@ function Fixed.room_is_lab(index)
return tech and game.forces.player.technologies[tech].enabled == false return tech and game.forces.player.technologies[tech].enabled == false
end end
function Fixed.noop()
end
Fixed.noop() -- eliminate luacheck warning
-- Variant 2, all research needs unlocking, several can be found on each floor -- Variant 2, all research needs unlocking, several can be found on each floor
-- and the research is semi-randomly distributed. Research packs occur at the -- and the research is semi-randomly distributed. Research packs occur at the
-- first half of the ranges. -- first half of the ranges.
@ -357,7 +362,7 @@ function Variable.calculate_distribution()
table.shuffle_table(all_research) table.shuffle_table(all_research)
local technologies = game.forces.player.technologies local technologies = game.forces.player.technologies
for i = 1, #all_research do for i = 1, #all_research do
v = all_research[i] local v = all_research[i]
local floor1 = math.random(v.min, v.max) local floor1 = math.random(v.min, v.max)
local floor2 = math.random(v.min, v.max) local floor2 = math.random(v.min, v.max)
local res1 = get_research_by_floor(floor1) local res1 = get_research_by_floor(floor1)
@ -505,4 +510,9 @@ function Variable.room_is_lab(index)
return rooms_opened(index) >= res[1].room return rooms_opened(index) >= res[1].room
end end
function Variable.noop()
end
Variable.noop() -- eliminate luacheck warning if return Fixed is used
-- return Fixed
return Variable return Variable

View File

@ -56,11 +56,11 @@ local disabled_for_deconstruction = {
} }
local function enable_hard_rooms(position, surface_index) local function enable_hard_rooms(position, surface_index)
dungeon_table = DungeonsTable.get_dungeontable() local dungeon_table = DungeonsTable.get_dungeontable()
floor = surface_index - dungeon_table.original_surface_index local floor = surface_index - dungeon_table.original_surface_index
-- can make it out to ~200 before hitting the "must explore more" limit -- can make it out to ~200 before hitting the "must explore more" limit
-- 140 puts hard rooms halfway between the only dirtlands and the edge -- 140 puts hard rooms halfway between the only dirtlands and the edge
floor_mindist = 140 - floor * 10 local floor_mindist = 140 - floor * 10
if floor_mindist < 80 then -- all dirtlands within this if floor_mindist < 80 then -- all dirtlands within this
return true return true
end end

View File

@ -1,5 +1,4 @@
local Event = require 'utils.event' local Event = require 'utils.event'
local Global = require 'utils.global'
local Tabs = require 'comfy_panel.main' local Tabs = require 'comfy_panel.main'
local SpamProtection = require 'utils.spam_protection' local SpamProtection = require 'utils.spam_protection'
local Token = require 'utils.token' local Token = require 'utils.token'

View File

@ -88,8 +88,8 @@ local function change_to_ranged(player)
if main_inv == nil or gun_inv == nil or ammo_inv == nil then if main_inv == nil or gun_inv == nil or ammo_inv == nil then
return false return false
end end
local gun_moved = try_move_from_main(main_inv, gun_inv, moved.gun) try_move_from_main(main_inv, gun_inv, moved.gun)
local ammo_moved = try_move_from_main(main_inv, ammo_inv, moved.ammo) try_move_from_main(main_inv, ammo_inv, moved.ammo)
state[player.index] = {} state[player.index] = {}
return true return true
end end