1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-09-16 09:06:21 +02:00

fixes, global to local

This commit is contained in:
MewMew
2019-10-13 12:57:54 +02:00
parent 5f72ac69f2
commit 82696e4c08
6 changed files with 16 additions and 12 deletions

View File

@@ -92,7 +92,7 @@ market.logistic = {
["fast-splitter"] = {value = 48, rarity = 4}, ["fast-splitter"] = {value = 48, rarity = 4},
["express-splitter"] = {value = 128, rarity = 7}, ["express-splitter"] = {value = 128, rarity = 7},
["loader"] = {value = 256, rarity = 2}, ["loader"] = {value = 256, rarity = 2},
["fast-loader'"] = {value = 512, rarity = 5}, ["fast-loader"] = {value = 512, rarity = 5},
["express-loader"] = {value = 768, rarity = 8}, ["express-loader"] = {value = 768, rarity = 8},
["burner-inserter"] = {value = 4, rarity = 1}, ["burner-inserter"] = {value = 4, rarity = 1},
["inserter"] = {value = 8, rarity = 1}, ["inserter"] = {value = 8, rarity = 1},

View File

@@ -34,17 +34,19 @@ end
local function accelerate() local function accelerate()
if not global.locomotive then return end if not global.locomotive then return end
if not global.locomotive.valid then return end if not global.locomotive.valid then return end
if global.locomotive.get_driver() then return end if global.locomotive.get_driver() then return end
global.locomotive_driver = global.locomotive.surface.create_entity({name = "character", position = global.locomotive.position, force = "player"}) local driver = global.locomotive.surface.create_entity({name = "character", position = global.locomotive.position, force = "player"})
global.locomotive_driver.driving = true driver.driving = true
global.locomotive_driver.riding_state = {acceleration = defines.riding.acceleration.accelerating, direction = defines.riding.direction.straight} driver.riding_state = {acceleration = defines.riding.acceleration.accelerating, direction = defines.riding.direction.straight}
end end
local function remove_acceleration() local function remove_acceleration()
if not global.locomotive then return end if not global.locomotive then return end
if not global.locomotive.valid then return end if not global.locomotive.valid then return end
if global.locomotive_driver then global.locomotive_driver.destroy() end local driver = global.locomotive.get_driver()
global.locomotive_driver = nil if not driver then return end
if driver.player then return end
driver.destroy()
end end
local function set_player_spawn_and_refill_fish() local function set_player_spawn_and_refill_fish()

View File

@@ -2,13 +2,13 @@
--require "modules.flashlight_toggle_button" --require "modules.flashlight_toggle_button"
--require "modules.biter_noms_you" --require "modules.biter_noms_you"
require "modules.biter_pets"
require "modules.biter_evasion_hp_increaser" require "modules.biter_evasion_hp_increaser"
require "modules.wave_defense.main" require "modules.wave_defense.main"
--require "modules.dense_rocks" --require "modules.dense_rocks"
require "functions.soft_reset" require "functions.soft_reset"
require "functions.basic_markets" require "functions.basic_markets"
require "modules.biters_yield_coins" require "modules.biters_yield_coins"
require "modules.biter_pets"
require "modules.no_deconstruction_of_neutral_entities" require "modules.no_deconstruction_of_neutral_entities"
require "modules.explosives" require "modules.explosives"
require "modules.rocks_broken_paint_tiles" require "modules.rocks_broken_paint_tiles"
@@ -91,7 +91,7 @@ end
local function protect_train(event) local function protect_train(event)
if event.entity.force.index ~= 1 then return end --Player Force if event.entity.force.index ~= 1 then return end --Player Force
if event.entity == global.locomotive or event.entity == global.locomotive_cargo then if event.entity == global.locomotive_cargo then
if event.cause then if event.cause then
if event.cause.force.index == 2 then if event.cause.force.index == 2 then
return return
@@ -136,7 +136,7 @@ local function hidden_biter(entity)
end end
local function hidden_biter_pet(event) local function hidden_biter_pet(event)
if math.random(1, 1024) ~= 1 then return end if math.random(1, 2048) ~= 1 then return end
wave_defense_set_unit_raffle(math.sqrt(event.entity.position.x ^ 2 + event.entity.position.y ^ 2) * 0.42) wave_defense_set_unit_raffle(math.sqrt(event.entity.position.x ^ 2 + event.entity.position.y ^ 2) * 0.42)
local unit local unit
if math.random(1,3) == 1 then if math.random(1,3) == 1 then

View File

@@ -284,7 +284,7 @@ local function process_chunk(surface, left_top)
if left_top.y > 32 then game.forces.player.chart(surface, {{left_top.x, left_top.y},{left_top.x + 31, left_top.y + 31}}) end if left_top.y > 32 then game.forces.player.chart(surface, {{left_top.x, left_top.y},{left_top.x + 31, left_top.y + 31}}) end
if left_top.y == 64 and left_top.x == 64 then if left_top.y == 64 and left_top.x == 64 then
local p = global.locomotive.position local p = global.locomotive.position
for _, entity in pairs(surface.find_entities_filtered({area = {{p.x - 3, p.y - 4},{p.x + 3, p.y + 8}}, force = "neutral"})) do entity.destroy() end for _, entity in pairs(surface.find_entities_filtered({area = {{p.x - 3, p.y - 4},{p.x + 3, p.y + 10}}, type = "simple-entity"})) do entity.destroy() end
end end
if left_top.y < 0 then rock_chunk(surface, left_top) return end if left_top.y < 0 then rock_chunk(surface, left_top) return end
if left_top.y > 96 then out_of_map(surface, left_top) return end if left_top.y > 96 then out_of_map(surface, left_top) return end

View File

@@ -29,7 +29,7 @@ local function tame_unit_effects(player, entity)
a = 1 a = 1
}, },
scale = 1.05, scale = 1.05,
font = "default-game", font = "default-large-semibold",
alignment = "center", alignment = "center",
scale_with_zoom = false scale_with_zoom = false
} }

View File

@@ -95,6 +95,7 @@ end
local function damage_entity(entity, cell) local function damage_entity(entity, cell)
if not entity.valid then return true end if not entity.valid then return true end
if not entity.health then return true end if not entity.health then return true end
if entity.health <= 0 then return true end
if not entity.destructible then return true end if not entity.destructible then return true end
if not entity.minable then return true end if not entity.minable then return true end
--if global.explosion_cells_reflect[entity.name] then --if global.explosion_cells_reflect[entity.name] then
@@ -111,6 +112,7 @@ local function damage_entity(entity, cell)
cell.health = cell.health - damage_required cell.health = cell.health - damage_required
if not entity then return true end if not entity then return true end
if not entity.valid then return true end if not entity.valid then return true end
if entity.health <= 0 then return true end
damage_required = math.floor(entity.health * (damage_required / damage_dealt)) + 1 damage_required = math.floor(entity.health * (damage_required / damage_dealt)) + 1
end end
end end