mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-11 14:49:24 +02:00
tweaks and fixes!
This commit is contained in:
parent
2cd5ac5779
commit
4a1ce15e07
95
maps/fish_defender/commands.lua
Normal file
95
maps/fish_defender/commands.lua
Normal file
@ -0,0 +1,95 @@
|
||||
local Server = require 'utils.server'
|
||||
local FDT = require 'maps.fish_defender.table'
|
||||
|
||||
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
|
||||
|
||||
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 param == 'restart' or param == 'shutdown' or param == 'reset' or param == 'restartnow' then
|
||||
goto continue
|
||||
else
|
||||
p('[ERROR] Arguments are:\nrestart\nshutdown\nreset\nrestartnow')
|
||||
return
|
||||
end
|
||||
|
||||
::continue::
|
||||
|
||||
local this = FDT.get()
|
||||
local reset_map = require 'maps.fish_defender.main'
|
||||
|
||||
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 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.')
|
||||
return
|
||||
end
|
||||
elseif param == 'restartnow' then
|
||||
this.reset_are_you_sure = nil
|
||||
p(player.name .. ' has restarted the game.')
|
||||
Server.start_scenario('Fish_Defender')
|
||||
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 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.')
|
||||
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(true)
|
||||
p('[WARNING] Game has been reset!')
|
||||
return
|
||||
end
|
||||
end
|
||||
)
|
@ -3,13 +3,15 @@
|
||||
--require "modules.rpg"
|
||||
|
||||
require 'maps.fish_defender.market'
|
||||
require 'maps.fish_defender.commands'
|
||||
require 'maps.fish_defender.on_entity_damaged'
|
||||
require 'modules.rocket_launch_always_yields_science'
|
||||
require 'modules.launch_fish_to_win'
|
||||
require 'modules.biters_yield_coins'
|
||||
require 'modules.dangerous_goods'
|
||||
require 'modules.custom_death_messages'
|
||||
require 'modules.launch_fish_to_win'
|
||||
|
||||
local AntiGrief = require 'antigrief'
|
||||
local Terrain = require 'maps.fish_defender.terrain'
|
||||
local Unit_health_booster = require 'modules.biter_health_booster'
|
||||
local Difficulty = require 'modules.difficulty_vote'
|
||||
@ -1134,8 +1136,10 @@ local function on_init(reset)
|
||||
|
||||
local this = FDT.get()
|
||||
|
||||
AntiGrief.reset_tables()
|
||||
FDT.reset_table()
|
||||
Poll.reset()
|
||||
global.fish_in_space = 0
|
||||
|
||||
local difficulties = {
|
||||
[1] = {
|
||||
@ -1168,9 +1172,12 @@ local function on_init(reset)
|
||||
Diff.difficulty_poll_closing_timeout = this.wave_grace_period
|
||||
get_score.score_table = {}
|
||||
|
||||
game.remove_offline_players()
|
||||
|
||||
local map_gen_settings = {}
|
||||
map_gen_settings.height = 2048
|
||||
map_gen_settings.water = 0.10
|
||||
map_gen_settings.seed = math_random(10000, 99999)
|
||||
map_gen_settings.terrain_segmentation = 3
|
||||
map_gen_settings.cliff_settings = {cliff_elevation_interval = 32, cliff_elevation_0 = 32}
|
||||
map_gen_settings.autoplace_controls = {
|
||||
|
@ -6,7 +6,7 @@ local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
|
||||
|
||||
commands.add_command(
|
||||
'mf_commands',
|
||||
'scenario',
|
||||
'Usable only for admins - controls the scenario!',
|
||||
function(cmd)
|
||||
local p
|
||||
|
@ -33,7 +33,11 @@ local artillery_target_entities = {
|
||||
'car',
|
||||
'furnace',
|
||||
'straight-rail',
|
||||
'curved-rail'
|
||||
'curved-rail',
|
||||
'locomotive',
|
||||
'cargo-wagon',
|
||||
'fluid-wagon',
|
||||
'artillery-wagon'
|
||||
}
|
||||
|
||||
local function fast_remove(tbl, index)
|
||||
|
@ -316,6 +316,10 @@ function Public.update_gui(player)
|
||||
local rpg_extra = RPG_Settings.get('rpg_extra')
|
||||
local this = WPT.get()
|
||||
|
||||
if not validate_player(player) then
|
||||
return
|
||||
end
|
||||
|
||||
if not player.gui.top[main_frame_name] then
|
||||
return
|
||||
end
|
||||
|
@ -229,6 +229,7 @@ function Public.changed_surface(event)
|
||||
|
||||
if Functions.get_player_surface(ic, player) then
|
||||
Public.toggle_button(player)
|
||||
Public.minimap(player, surface)
|
||||
if wd and wd.visible then
|
||||
wd.visible = false
|
||||
end
|
||||
|
123
modules/rpg/commands.lua
Normal file
123
modules/rpg/commands.lua
Normal file
@ -0,0 +1,123 @@
|
||||
local RPG = require 'modules.rpg.table'
|
||||
local Utils = require 'utils.core'
|
||||
local Color = require 'utils.color_presets'
|
||||
|
||||
local round = math.round
|
||||
|
||||
local validate_args = function(data)
|
||||
local player = data.player
|
||||
local target = data.target
|
||||
local rpg_t = data.rpg_t
|
||||
|
||||
if not target then
|
||||
return false
|
||||
end
|
||||
|
||||
if not target.valid then
|
||||
return false
|
||||
end
|
||||
|
||||
if not target.character then
|
||||
return false
|
||||
end
|
||||
|
||||
if not target.connected then
|
||||
return false
|
||||
end
|
||||
|
||||
if not game.players[target.index] then
|
||||
return false
|
||||
end
|
||||
|
||||
if not player then
|
||||
return false
|
||||
end
|
||||
|
||||
if not player.valid then
|
||||
return false
|
||||
end
|
||||
|
||||
if not player.character then
|
||||
return false
|
||||
end
|
||||
|
||||
if not player.connected then
|
||||
return false
|
||||
end
|
||||
|
||||
if not game.players[player.index] then
|
||||
return false
|
||||
end
|
||||
|
||||
if not target or not game.players[target.index] then
|
||||
Utils.print_to(player, 'Invalid name.')
|
||||
return false
|
||||
end
|
||||
|
||||
if not rpg_t[target.index] then
|
||||
Utils.print_to(player, 'Invalid target.')
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local print_stats = function(target, tbl)
|
||||
if not target then
|
||||
return
|
||||
end
|
||||
if not tbl then
|
||||
return
|
||||
end
|
||||
local t = tbl[target.index]
|
||||
local level = t.level
|
||||
local xp = round(t.xp)
|
||||
local strength = t.strength
|
||||
local magicka = t.magicka
|
||||
local dexterity = t.dexterity
|
||||
local vitality = t.vitality
|
||||
local output = '[color=blue]' .. target.name .. '[/color] has the following stats: \n'
|
||||
output = output .. '[color=green]Level:[/color] ' .. level .. '\n'
|
||||
output = output .. '[color=green]XP:[/color] ' .. xp .. '\n'
|
||||
output = output .. '[color=green]Strength:[/color] ' .. strength .. '\n'
|
||||
output = output .. '[color=green]Magic:[/color] ' .. magicka .. '\n'
|
||||
output = output .. '[color=green]Dexterity:[/color] ' .. dexterity .. '\n'
|
||||
output = output .. '[color=green]Vitality:[/color] ' .. vitality
|
||||
|
||||
return output
|
||||
end
|
||||
|
||||
commands.add_command(
|
||||
'stats',
|
||||
'Check what stats a user has!',
|
||||
function(cmd)
|
||||
local player = game.player
|
||||
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local param = cmd.parameter
|
||||
|
||||
local target = game.players[param]
|
||||
if not target or not target.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local rpg_t = RPG.get('rpg_t')
|
||||
|
||||
local data = {
|
||||
player = player,
|
||||
target = target,
|
||||
rpg_t = rpg_t
|
||||
}
|
||||
|
||||
if validate_args(data) then
|
||||
local msg = print_stats(target, rpg_t)
|
||||
player.play_sound {path = 'utility/scenario_message', volume_modifier = 1}
|
||||
player.print(msg)
|
||||
else
|
||||
player.print('Please type a name of a player who is connected.', Color.warning)
|
||||
end
|
||||
end
|
||||
)
|
@ -7,6 +7,7 @@ local WD = require 'modules.wave_defense.table'
|
||||
local Math2D = require 'math2d'
|
||||
|
||||
--RPG Modules
|
||||
require 'modules.rpg.commands'
|
||||
local RPG = require 'modules.rpg.table'
|
||||
local Functions = require 'modules.rpg.functions'
|
||||
local RPG_GUI = require 'modules.rpg.gui'
|
||||
|
@ -326,7 +326,7 @@ local vote_to_jail = function(player, griefer, msg)
|
||||
end
|
||||
|
||||
local vote_to_free = function(player, griefer)
|
||||
if votefree[griefer] and not votefree[griefer] then
|
||||
if not votefree[griefer] then
|
||||
votefree[griefer] = {index = 0, actor = player.name}
|
||||
local message = player.name .. ' has started a vote to free player ' .. griefer
|
||||
Utils.print_to(nil, message)
|
||||
|
Loading…
x
Reference in New Issue
Block a user