1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-11-27 22:38:18 +02:00

minor tweaks

This commit is contained in:
Gerkiz
2020-10-29 13:07:42 +01:00
parent 6506bb7df8
commit 6470842b72
6 changed files with 155 additions and 14 deletions

View File

@@ -1196,7 +1196,7 @@ stds.factorio_defines = {
'change_train_stop_station', 'change_train_stop_station',
'change_train_wait_condition', 'change_train_wait_condition',
'change_train_wait_condition_data', 'change_train_wait_condition_data',
'clean_cursor_stack', 'clear_cursor_stack',
'clear_selected_blueprint', 'clear_selected_blueprint',
'clear_selected_deconstruction_item', 'clear_selected_deconstruction_item',
'clear_selected_upgrade_item', 'clear_selected_upgrade_item',

View File

@@ -40,7 +40,7 @@ local function enemy_weapon_damage()
local e = game.forces.enemy local e = game.forces.enemy
local data = { local data = {
['artillery-shell'] = 0.001, ['artillery-shell'] = 0.05,
['biological'] = 0.08, ['biological'] = 0.08,
['bullet'] = 0.08, ['bullet'] = 0.08,
['capsule'] = 0.08, ['capsule'] = 0.08,

View File

@@ -221,13 +221,15 @@ local function output_cargo(wagon, passive_chest)
if not passive_chest.valid then if not passive_chest.valid then
return return
end end
local chest1 = passive_chest.get_inventory(defines.inventory.cargo_wagon) local chest1 = passive_chest.get_inventory(defines.inventory.chest)
local chest2 = wagon.entity.get_inventory(defines.inventory.cargo_wagon) local chest2 = wagon.entity.get_inventory(defines.inventory.cargo_wagon)
for k, v in pairs(chest1.get_contents()) do for i = 1, #chest1 do
local t = {name = k, count = v} local t = chest1[i]
local c = chest2.insert(t) if t and t.valid then
if (c > 0) then local c = chest2.insert(t)
chest1.remove({name = k, count = c}) if (c > 0) then
chest1.remove(t)
end
end end
end end
end end
@@ -427,14 +429,13 @@ function Public.create_wagon_room(icw, wagon)
end end
end end
for x = area.left_top.x, area.right_bottom.x - 1, 1 do --[[ for x = area.left_top.x, area.right_bottom.x - 1, 1 do
for y = area.left_top.y + 2, area.right_bottom.y - 3, 1 do for y = area.left_top.y + 2, area.right_bottom.y - 3, 1 do
if random(1, 16) == 1 then if random(1, 16) == 1 then
fishes[#fishes + 1] = {name = 'mineable-wreckage', position = {x, y}} fishes[#fishes + 1] = {name = crash_site[random(1, size_of_crash)], position = {x, y}, force = 'player'}
end end
end end
end end ]]
surface.set_tiles(tiles, true) surface.set_tiles(tiles, true)
for _, fish in pairs(fishes) do for _, fish in pairs(fishes) do

View File

@@ -22,6 +22,7 @@ local wagon_raffle = {
'locomotive', 'locomotive',
'fluid-wagon' 'fluid-wagon'
} }
local rock_raffle = { local rock_raffle = {
'sand-rock-big', 'sand-rock-big',
'sand-rock-big', 'sand-rock-big',
@@ -954,7 +955,7 @@ local function process_level_8_position(x, y, data, void_or_lab)
} }
end end
if random(1, 5) > 1 then if random(1, 5) > 1 then
entities[#entities + 1] = {name = 'mineable-wreckage', position = p} entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p}
end end
if random(1, 256) == 1 then if random(1, 256) == 1 then
entities[#entities + 1] = {name = 'land-mine', position = p, force = 'enemy'} entities[#entities + 1] = {name = 'land-mine', position = p, force = 'enemy'}

View File

@@ -474,7 +474,7 @@ end
--- Gives connected player some bonus xp if the map was preemptively shut down. --- Gives connected player some bonus xp if the map was preemptively shut down.
-- amount (integer) -- 10 levels -- amount (integer) -- 10 levels
-- local Public = require 'modules.rpg_v2' Public.give_xp(512) -- local Public = require 'modules.rpg.functions' Public.give_xp(512)
function Public.give_xp(amount) function Public.give_xp(amount)
for _, player in pairs(game.connected_players) do for _, player in pairs(game.connected_players) do
if not Public.validate_player(player) then if not Public.validate_player(player) then

139
utils/scenariohandler.lua Normal file
View File

@@ -0,0 +1,139 @@
local Color = require 'utils.color_presets'
local Server = require 'utils.server'
local Global = require 'utils.globals'
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
local Public = {}
local this = {
scenarioname = '',
reset_are_you_sure = false,
restart = false,
soft_reset = false,
shutdown = false,
accepted_params = {
['restart'] = true,
['resetnow'] = true,
['shutdown'] = true,
['restartnow'] = true
}
}
Global.register(
this,
function(t)
this = t
end
)
commands.add_command(
'scenario',
'Usable only for admins - controls the scenario!',
function(cmd)
local p
local player = game.player
if not player or not player.valid then
p = log
else
p = player.print
if not player.admin then
return
end
end
local param = cmd.parameter
if this.accepted_params[param] then
goto continue
else
p('[ERROR] Arguments was invalid.')
return
end
::continue::
if not this.reset_are_you_sure then
this.reset_are_you_sure = true
p(
'[WARNING] This command will disable the soft-reset feature, run this command again if you really want to do this!'
)
return
end
if param == 'restart' then
if this.restart then
this.reset_are_you_sure = nil
this.restart = false
this.soft_reset = true
p('[SUCCESS] Soft-reset is once again enabled.')
return
else
this.reset_are_you_sure = nil
this.restart = true
this.soft_reset = false
if this.shutdown then
this.shutdown = false
end
p('[WARNING] Soft-reset is disabled! Server will restart from scenario to load new changes.')
return
end
elseif param == 'restartnow' then
this.reset_are_you_sure = nil
p(player.name .. ' restarted the game.')
Server.start_scenario(this.scenarioname)
return
elseif param == 'shutdown' then
if this.shutdown then
this.reset_are_you_sure = nil
this.shutdown = false
this.soft_reset = true
p('[SUCCESS] Soft-reset is once again enabled.')
return
else
this.reset_are_you_sure = nil
this.shutdown = true
this.soft_reset = false
if this.restart then
this.restart = false
end
p('[WARNING] Soft-reset is disabled! Server will shutdown. Most likely because of updates.')
return
end
elseif param == 'reset' then
this.reset_are_you_sure = nil
if player and player.valid then
game.print(mapkeeper .. ' ' .. player.name .. ', has reset the game!', {r = 0.98, g = 0.66, b = 0.22})
else
game.print(mapkeeper .. ' server, has reset the game!', {r = 0.98, g = 0.66, b = 0.22})
end
reset_map()
p('[WARNING] Game has been reset!')
return
end
end
)
function Public.map_reset_callback(data, callback)
if not data then
return
end
if not callback then
return
end
if not string.find(callback, '%s') and not string.find(callback, 'return') then
callback = 'return ' .. callback
end
if type(callback) == 'function' then
local success, err = pcall(callback, data)
return success, err
else
local success, err = pcall(loadstring(callback), data)
return success, err
end
end
return Public