2022-06-01 20:50:36 +02:00
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/danielmartin0/ComfyFactorio-Pirates.
2022-03-19 23:20:55 +02:00
--luacheck: ignore
--luacheck ignores because mass requires is a code templating choice...
2021-10-13 10:21:53 +02:00
local Color = require ' utils.color_presets '
local Server = require ' utils.server '
local Math = require ' maps.pirates.math '
local Ai = require ' maps.pirates.ai '
local Memory = require ' maps.pirates.memory '
local Common = require ' maps.pirates.common '
local CoreData = require ' maps.pirates.coredata '
local PlayerColors = require ' maps.pirates.player_colors '
local Utils = require ' maps.pirates.utils_local '
local Crew = require ' maps.pirates.crew '
local Roles = require ' maps.pirates.roles.roles '
local Boats = require ' maps.pirates.structures.boats.boats '
local Surfaces = require ' maps.pirates.surfaces.surfaces '
local Overworld = require ' maps.pirates.overworld '
local Islands = require ' maps.pirates.surfaces.islands.islands '
local Progression = require ' maps.pirates.progression '
local Crowsnest = require ' maps.pirates.surfaces.crowsnest '
2022-05-29 13:36:27 +02:00
local PiratesApiEvents = require ' maps.pirates.api_events '
2021-10-13 10:21:53 +02:00
local Upgrades = require ' maps.pirates.boat_upgrades '
local Effects = require ' maps.pirates.effects '
local Kraken = require ' maps.pirates.surfaces.sea.kraken '
2022-03-19 23:20:55 +02:00
local _inspect = require ' utils.inspect ' . inspect
2021-10-13 10:21:53 +02:00
local simplex_noise = require ' utils.simplex_noise ' . d2
local Token = require ' utils.token '
local Task = require ' utils.task '
local Highscore = require ' maps.pirates.highscore '
2022-03-13 03:44:32 +02:00
local CustomEvents = require ' maps.pirates.custom_events '
2022-03-13 20:19:59 +02:00
local Classes = require ' maps.pirates.roles.classes '
2021-10-13 10:21:53 +02:00
2022-07-28 19:15:31 +02:00
local Gui = require ' maps.pirates.gui.gui '
2021-10-13 10:21:53 +02:00
2022-06-02 15:47:23 +02:00
2022-06-02 20:54:47 +02:00
local function cmd_set_memory ( cmd )
2022-06-15 23:00:18 +02:00
local player = game.players [ cmd.player_index ]
local crew_id = Common.get_id_from_force_name ( player.force . name )
2022-06-02 20:54:47 +02:00
Memory.set_working_id ( crew_id )
end
2022-06-02 15:47:23 +02:00
local function check_admin ( cmd )
local Session = require ' utils.datastore.session_data '
local player = game.players [ cmd.player_index ]
2022-06-07 22:48:42 +02:00
--local trusted = Session.get_trusted_table()
2022-06-02 15:47:23 +02:00
local p
if player then
if player ~= nil then
p = player.print
2022-07-02 17:42:22 +02:00
--@temporary
if player.name == " Piratux " then
return true
end
2022-06-02 15:47:23 +02:00
if not player.admin then
2022-06-07 22:48:42 +02:00
p ( { ' pirates.cmd_error_not_admin ' } , Color.fail )
2022-06-02 15:47:23 +02:00
return false
end
else
p = log
end
end
return true
end
local function check_captain ( cmd )
local player = game.players [ cmd.player_index ]
local p
if player then
if player ~= nil then
p = player.print
if not Common.validate_player ( player ) then return end
if not ( Roles.player_privilege_level ( player ) >= Roles.privilege_levels . CAPTAIN ) then
2022-06-07 22:48:42 +02:00
p ( { ' pirates.cmd_error_not_captain ' } , Color.fail )
2022-06-02 15:47:23 +02:00
return false
end
else
p = log
end
end
return true
end
local function check_captain_or_admin ( cmd )
local player = game.players [ cmd.player_index ]
local p
if player then
if player ~= nil then
p = player.print
if not Common.validate_player ( player ) then return end
if not ( player.admin or Roles.player_privilege_level ( player ) >= Roles.privilege_levels . CAPTAIN ) then
2022-06-07 22:48:42 +02:00
p ( { ' pirates.cmd_error_not_captain ' } , Color.fail )
2022-06-02 15:47:23 +02:00
return false
end
else
p = log
end
end
return true
end
2023-02-20 18:56:41 +02:00
-- @UNUSED
-- local function check_trusted(cmd)
-- local Session = require 'utils.datastore.session_data'
-- local player = game.players[cmd.player_index]
-- local trusted = Session.get_trusted_table()
-- local p
-- if player then
-- if player ~= nil then
-- p = player.print
-- if not (trusted[player.name] or player.admin) then
-- p('[ERROR] Only admins and trusted weebs are allowed to run this command!', Color.fail)
-- return false
-- end
-- else
-- p = log
-- end
-- end
-- return true
-- end
2022-06-02 15:47:23 +02:00
commands.add_command (
' set_max_crews ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_set_max_crews ' } ,
2022-06-02 15:47:23 +02:00
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local global_memory = Memory.get_global_memory ( )
if tonumber ( param ) then
global_memory.active_crews_cap = tonumber ( param )
2022-06-07 22:48:42 +02:00
Common.notify_player_expected ( player , { ' pirates.cmd_notify_set_max_crews ' , param } )
2022-06-02 15:47:23 +02:00
end
end
end )
commands.add_command (
' sail ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_sail ' } ,
2022-06-02 15:47:23 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-07 22:01:45 +02:00
local memory = Memory.get_crew_memory ( )
if not Common.is_id_valid ( memory.id ) then return end
2022-06-07 22:48:42 +02:00
--local param = tostring(cmd.parameter)
2022-06-02 15:47:23 +02:00
if check_admin ( cmd ) then
2022-06-07 22:48:42 +02:00
--local player = game.players[cmd.player_index]
2022-06-02 15:47:23 +02:00
Crew.summon_crew ( )
if memory.boat . state == Boats.enum_state . ATSEA_WAITING_TO_SAIL then
Progression.at_sea_begin_to_set_sail ( )
end
end
end )
commands.add_command (
' setcaptain ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_setcaptain ' } ,
2022-06-02 15:47:23 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-07 22:01:45 +02:00
local memory = Memory.get_crew_memory ( )
if not Common.is_id_valid ( memory.id ) then return end
2022-06-02 15:47:23 +02:00
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
if param and game.players [ param ] and game.players [ param ] . index then
Roles.make_captain ( game.players [ param ] )
else
2022-06-07 22:48:42 +02:00
Common.notify_player_error ( player , { ' pirates.cmd_error_invalid_player_name ' , param } )
2022-06-02 15:47:23 +02:00
end
end
end )
commands.add_command (
' summoncrew ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_summoncrew ' } ,
2022-06-02 15:47:23 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-07 22:01:45 +02:00
local memory = Memory.get_crew_memory ( )
if not Common.is_id_valid ( memory.id ) then return end
2022-06-07 22:48:42 +02:00
--local param = tostring(cmd.parameter)
2022-06-02 15:47:23 +02:00
if check_admin ( cmd ) then
Crew.summon_crew ( )
end
end )
2021-10-13 10:21:53 +02:00
commands.add_command (
' ok ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_ok ' } ,
2021-10-13 10:21:53 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-07 22:01:45 +02:00
local memory = Memory.get_crew_memory ( )
if not Common.is_id_valid ( memory.id ) then return end
2022-06-02 20:54:47 +02:00
local player = game.players [ cmd.player_index ]
2021-10-13 10:21:53 +02:00
if not Common.validate_player ( player ) then return end
2022-07-16 20:46:23 +02:00
2022-06-07 22:48:42 +02:00
--local memory = Memory.get_crew_memory()
2022-03-01 17:57:23 +02:00
Roles.player_confirm_captainhood ( player )
2021-10-13 10:21:53 +02:00
end )
2022-02-27 18:42:25 +02:00
-- Disabled for information-flow reasons:
-- commands.add_command(
-- 'classes',
-- 'Prints the available classes in the game.',
-- function(cmd)
-- local player = game.players[cmd.player_index]
-- if not Common.validate_player(player) then return end
-- player.print('[color=gray]' .. Roles.get_classes_print_string() .. '[/color]')
-- end)
2022-06-02 15:07:17 +02:00
commands.add_command (
2022-07-08 14:53:31 +02:00
' classinfo ' ,
{ ' pirates.cmd_explain_classinfo ' } ,
2022-06-02 15:07:17 +02:00
function ( cmd )
2022-06-03 15:41:49 +02:00
cmd_set_memory ( cmd )
2022-06-02 15:07:17 +02:00
local param = tostring ( cmd.parameter )
local player = game.players [ cmd.player_index ]
if not Common.validate_player ( player ) then return end
if param and param ~= ' nil ' then
2022-07-08 14:53:31 +02:00
local string = Roles.get_class_print_string ( param , true )
2022-06-02 15:07:17 +02:00
if string then
2022-06-07 22:48:42 +02:00
Common.notify_player_expected ( player , { ' ' , { ' pirates.class_definition_for ' } , ' ' , string } )
2022-06-02 15:07:17 +02:00
else
2022-06-07 22:48:42 +02:00
Common.notify_player_error ( player , { ' pirates.cmd_error_invalid_class_name ' , param } )
2022-06-02 15:07:17 +02:00
end
else
2022-07-08 14:53:31 +02:00
Common.notify_player_expected ( player , { ' ' , ' /classinfo ' , { ' pirates.cmd_explain_classinfo ' } } )
2022-06-02 15:07:17 +02:00
end
end )
2022-03-13 20:19:59 +02:00
commands.add_command (
' take ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_take ' } ,
2022-03-13 20:19:59 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-07 22:01:45 +02:00
local memory = Memory.get_crew_memory ( )
if not Common.is_id_valid ( memory.id ) then return end
2022-03-13 20:19:59 +02:00
local param = tostring ( cmd.parameter )
local player = game.players [ cmd.player_index ]
if not Common.validate_player ( player ) then return end
2022-07-16 20:46:23 +02:00
2022-03-13 20:19:59 +02:00
if param and param ~= ' nil ' then
2022-05-29 13:36:27 +02:00
for _ , class in pairs ( Classes.enum ) do
if Classes.eng_form [ class ] : lower ( ) == param : lower ( ) then
2022-07-07 22:01:45 +02:00
Classes.assign_class ( player.index , class )
2022-03-13 20:19:59 +02:00
return true
end
end
--fallthrough:
2022-06-07 22:48:42 +02:00
Common.notify_player_error ( player , { ' pirates.cmd_error_invalid_class_name ' , param } )
2022-03-13 20:19:59 +02:00
return false
else
2022-06-07 22:48:42 +02:00
Common.notify_player_expected ( player , { ' ' , ' /take ' , { ' pirates.cmd_explain_take ' } } )
2022-03-13 20:19:59 +02:00
end
end )
commands.add_command (
' giveup ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_giveup ' } ,
2022-03-13 20:19:59 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-07 22:01:45 +02:00
local memory = Memory.get_crew_memory ( )
if not Common.is_id_valid ( memory.id ) then return end
2022-06-07 22:48:42 +02:00
--local param = tostring(cmd.parameter)
2022-03-13 20:19:59 +02:00
local player = game.players [ cmd.player_index ]
if not Common.validate_player ( player ) then return end
2022-06-02 20:54:47 +02:00
2022-07-07 22:01:45 +02:00
Classes.assign_class ( player.index , nil )
2022-02-27 18:42:25 +02:00
end )
2021-10-13 10:21:53 +02:00
commands.add_command (
' ccolor ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_ccolor ' } ,
2021-10-13 10:21:53 +02:00
function ( cmd )
local param = tostring ( cmd.parameter )
local player_index = cmd.player_index
if player_index then
local player = game.players [ player_index ]
if player and player.valid then
2022-02-24 21:39:03 +02:00
if cmd.parameter then
2022-02-25 02:01:28 +02:00
if PlayerColors.colors [ param ] then
2022-02-25 02:15:32 +02:00
local rgb = PlayerColors.colors [ param ]
player.color = rgb
player.chat_color = rgb
2022-05-29 13:36:27 +02:00
local message = { ' ' , ' [color= ' .. rgb.r .. ' , ' .. rgb.g .. ' , ' .. rgb.b .. ' ] ' , { ' pirates.choose_chat_color ' , player.name , param } , ' [/color] (via /ccolor). ' }
-- local message = '[color=' .. rgb.r .. ',' .. rgb.g .. ',' .. rgb.b .. ']' .. player.name .. ' chose the color ' .. param .. '[/color] (via /ccolor).'
2022-02-27 18:42:25 +02:00
Common.notify_game ( message )
2022-02-24 21:39:03 +02:00
else
2022-06-07 22:48:42 +02:00
Common.notify_player_error ( player , { ' pirates.cmd_error_color_not_found ' , param } )
2022-02-24 21:39:03 +02:00
end
2021-10-13 10:21:53 +02:00
else
2022-03-12 00:53:36 +02:00
local color = PlayerColors.bright_color_names [ Math.random ( # PlayerColors.bright_color_names ) ]
2022-02-25 02:15:32 +02:00
local rgb = PlayerColors.colors [ color ]
2022-02-26 15:55:36 +02:00
if not rgb then return end
2022-02-25 02:15:32 +02:00
player.color = rgb
player.chat_color = rgb
2022-05-29 13:36:27 +02:00
local message = { ' ' , ' [color= ' .. rgb.r .. ' , ' .. rgb.g .. ' , ' .. rgb.b .. ' ] ' , { ' pirates.randomize_chat_color ' , player.name , color } , ' [/color] (via /ccolor). ' } --'randomly became' was amusing, but let's not
-- local message = '[color=' .. rgb.r .. ',' .. rgb.g .. ',' .. rgb.b .. ']' .. player.name .. '\'s color randomized to ' .. color .. '[/color] (via /ccolor).' --'randomly became' was amusing, but let's not
2022-02-27 18:42:25 +02:00
Common.notify_game ( message )
2022-02-25 02:01:28 +02:00
-- disabled due to lag:
-- GUIcolor.toggle_window(player)
2021-10-13 10:21:53 +02:00
end
end
end
end )
2023-01-28 15:21:41 +02:00
commands.add_command (
' fixpower ' ,
{ ' pirates.cmd_explain_fixpower ' } ,
function ( cmd )
cmd_set_memory ( cmd )
2021-10-13 10:21:53 +02:00
2023-01-28 15:21:41 +02:00
local memory = Memory.get_crew_memory ( )
if not Common.is_id_valid ( memory.id ) then return end
Boats.force_reconnect_boat_poles ( )
end )
2021-10-13 10:21:53 +02:00
local go_2 = Token.register (
function ( data )
2022-07-16 20:46:23 +02:00
Memory.set_working_id ( data.id )
2021-10-13 10:21:53 +02:00
local memory = Memory.get_crew_memory ( )
2022-03-19 23:20:55 +02:00
2021-10-13 10:21:53 +02:00
memory.mapbeingloadeddestination_index = 1
memory.loadingticks = 0
2022-03-07 20:41:42 +02:00
2023-01-28 15:21:41 +02:00
-- local surface = game.surfaces[Common.current_destination().surface_name]
2022-03-07 20:41:42 +02:00
-- surface.request_to_generate_chunks({x = 0, y = 0}, 10)
-- surface.force_generate_chunk_requests()
2021-10-13 10:21:53 +02:00
Progression.go_from_starting_dock_to_first_destination ( )
end
)
local go_1 = Token.register (
function ( data )
2022-07-16 20:46:23 +02:00
Memory.set_working_id ( data.id )
2021-10-13 10:21:53 +02:00
local memory = Memory.get_crew_memory ( )
Overworld.ensure_lane_generated_up_to ( 0 , Crowsnest.Data . visibilitywidth / 2 )
Overworld.ensure_lane_generated_up_to ( 24 , Crowsnest.Data . visibilitywidth / 2 )
Overworld.ensure_lane_generated_up_to ( - 24 , Crowsnest.Data . visibilitywidth / 2 )
memory.currentdestination_index = 1
2022-03-13 03:44:32 +02:00
script.raise_event ( CustomEvents.enum [ ' update_crew_progress_gui ' ] , { } )
2021-10-13 10:21:53 +02:00
Surfaces.create_surface ( Common.current_destination ( ) )
2022-07-16 20:46:23 +02:00
Task.set_timeout_in_ticks ( 60 , go_2 , { id = data.id } )
2021-10-13 10:21:53 +02:00
end
)
2022-02-28 18:36:46 +02:00
commands.add_command (
2022-03-09 01:36:03 +02:00
' plank ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_plank ' } ,
2022-02-28 18:36:46 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-07 22:01:45 +02:00
local memory = Memory.get_crew_memory ( )
if not Common.is_id_valid ( memory.id ) then return end
2022-03-09 01:36:03 +02:00
local player = game.players [ cmd.player_index ]
local param = tostring ( cmd.parameter )
2022-03-13 20:19:59 +02:00
if check_captain_or_admin ( cmd ) then
2022-03-09 01:36:03 +02:00
if param and game.players [ param ] and game.players [ param ] . index then
Crew.plank ( player , game.players [ param ] )
else
2022-06-07 22:48:42 +02:00
Common.notify_player_error ( player , { ' pirates.cmd_error_invalid_player_name ' , param } )
2022-03-09 01:36:03 +02:00
end
2022-02-28 18:36:46 +02:00
end
end )
2022-03-09 01:36:03 +02:00
commands.add_command (
' officer ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_officer ' } ,
2022-03-09 01:36:03 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-07 22:01:45 +02:00
local memory = Memory.get_crew_memory ( )
if not Common.is_id_valid ( memory.id ) then return end
2022-07-16 20:46:23 +02:00
2022-03-09 01:36:03 +02:00
local player = game.players [ cmd.player_index ]
local param = tostring ( cmd.parameter )
2022-03-13 20:19:59 +02:00
if check_captain_or_admin ( cmd ) then
2022-03-09 01:36:03 +02:00
if param and game.players [ param ] and game.players [ param ] . index then
2022-10-11 20:38:53 +02:00
if Common.is_officer ( game.players [ param ] . index ) then
2022-03-09 01:36:03 +02:00
Roles.unmake_officer ( player , game.players [ param ] )
else
Roles.make_officer ( player , game.players [ param ] )
end
else
2022-06-07 22:48:42 +02:00
Common.notify_player_error ( player , { ' pirates.cmd_error_invalid_player_name ' , param } )
2022-03-09 01:36:03 +02:00
end
end
end )
2022-02-28 18:36:46 +02:00
2023-06-24 22:49:36 +02:00
-- Try undock from an island or dock
2022-03-12 00:53:36 +02:00
commands.add_command (
' undock ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_undock ' } ,
2022-03-12 00:53:36 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-07 22:01:45 +02:00
local memory = Memory.get_crew_memory ( )
if not Common.is_id_valid ( memory.id ) then return end
2022-07-16 20:46:23 +02:00
2022-06-07 22:48:42 +02:00
--local param = tostring(cmd.parameter)
2022-03-13 20:19:59 +02:00
if check_captain_or_admin ( cmd ) then
2022-03-12 00:53:36 +02:00
local player = game.players [ cmd.player_index ]
if memory.boat . state == Boats.enum_state . DOCKED then
2022-03-12 13:51:11 +02:00
Progression.undock_from_dock ( true )
2022-03-12 00:53:36 +02:00
elseif memory.boat . state == Boats.enum_state . LANDED then
2022-03-14 14:44:30 +02:00
Progression.try_retreat_from_island ( player , true )
2022-03-12 00:53:36 +02:00
end
end
end )
2023-06-24 22:49:36 +02:00
-- Force undock from an island or dock
commands.add_command (
' ret ' ,
{ ' pirates.cmd_explain_dev ' } ,
function ( cmd )
cmd_set_memory ( cmd )
local memory = Memory.get_crew_memory ( )
if not Common.is_id_valid ( memory.id ) then return end
-- local param = tostring(cmd.parameter)
if check_admin ( cmd ) then
if memory.boat . state == Boats.enum_state . DOCKED then
Progression.undock_from_dock ( true )
elseif memory.boat . state == Boats.enum_state . LANDED then
Progression.retreat_from_island ( true )
end
end
end )
2022-03-13 20:19:59 +02:00
commands.add_command (
2022-05-06 14:43:59 +02:00
' tax ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_tax ' } ,
2022-03-13 20:19:59 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-07 22:01:45 +02:00
local memory = Memory.get_crew_memory ( )
if not Common.is_id_valid ( memory.id ) then return end
2022-07-16 20:46:23 +02:00
2022-06-07 22:48:42 +02:00
--local param = tostring(cmd.parameter)
2022-03-13 20:19:59 +02:00
if check_captain ( cmd ) then
2022-06-07 22:48:42 +02:00
--local player = game.players[cmd.player_index]
2022-05-06 14:43:59 +02:00
Roles.captain_tax ( memory.playerindex_captain )
2022-06-02 19:06:38 +02:00
end --@TODO: else
2022-03-13 20:19:59 +02:00
end )
2022-11-20 21:07:04 +02:00
commands.add_command (
' clear_north_tanks ' ,
{ ' pirates.cmd_explain_clear_north_tanks ' } ,
function ( cmd )
cmd_set_memory ( cmd )
local memory = Memory.get_crew_memory ( )
if not Common.is_id_valid ( memory.id ) then return end
if check_captain ( cmd ) then
Boats.clear_fluid_from_ship_tanks ( 1 )
end --@TODO: else
end )
commands.add_command (
' clear_south_tanks ' ,
{ ' pirates.cmd_explain_clear_south_tanks ' } ,
function ( cmd )
cmd_set_memory ( cmd )
local memory = Memory.get_crew_memory ( )
if not Common.is_id_valid ( memory.id ) then return end
if check_captain ( cmd ) then
Boats.clear_fluid_from_ship_tanks ( 2 )
end --@TODO: else
end )
2022-02-28 18:36:46 +02:00
commands.add_command (
2022-03-09 01:36:03 +02:00
' dump_highscores ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-02-28 18:36:46 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-16 20:46:23 +02:00
2022-02-28 18:36:46 +02:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
if not Common.validate_player ( player ) then return end
2022-03-09 01:36:03 +02:00
Highscore.dump_highscores ( )
player.print ( ' Highscores dumped. ' )
2022-02-28 18:36:46 +02:00
end
end )
2022-03-01 23:59:48 +02:00
commands.add_command (
' setevo ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-03-01 23:59:48 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-16 20:46:23 +02:00
2022-03-01 23:59:48 +02:00
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
Common.set_evo ( tonumber ( param ) )
end
end )
2022-02-26 20:25:48 +02:00
commands.add_command (
' modi ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-02-26 20:25:48 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-16 20:46:23 +02:00
2022-02-26 20:25:48 +02:00
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local memory = Memory.get_crew_memory ( )
local surface = game.surfaces [ Common.current_destination ( ) . surface_name ]
local entities = surface.find_entities_filtered { position = player.position , radius = 500 }
for _ , e in pairs ( entities ) do
if e and e.valid then
2022-03-04 19:57:58 +02:00
-- e.force = memory.force
2022-02-26 20:25:48 +02:00
e.minable = true
e.destructible = true
e.rotatable = true
2021-10-13 10:21:53 +02:00
end
end
2022-02-26 20:25:48 +02:00
player.print ( ' nearby entities made modifiable ' )
end
end )
2021-10-13 10:21:53 +02:00
2022-07-16 20:46:23 +02:00
-- Move overworld boat right by a lot (you can jump over islands that way to skip them)
2022-03-11 00:11:51 +02:00
commands.add_command (
' jump ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-03-11 00:11:51 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-16 20:46:23 +02:00
2022-03-11 00:11:51 +02:00
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
Overworld.try_overworld_move_v2 ( { x = 40 , y = 0 } )
end
end )
2022-07-16 20:46:23 +02:00
-- Move overworld boat up
2022-03-11 00:11:51 +02:00
commands.add_command (
' advu ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-03-11 00:11:51 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-16 20:46:23 +02:00
2022-03-11 00:11:51 +02:00
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
Overworld.try_overworld_move_v2 { x = 0 , y = - 24 }
end
end )
2022-07-16 20:46:23 +02:00
-- Move overworld boat down
2022-03-11 00:11:51 +02:00
commands.add_command (
' advd ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-03-11 00:11:51 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-16 20:46:23 +02:00
2022-03-11 00:11:51 +02:00
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
Overworld.try_overworld_move_v2 { x = 0 , y = 24 }
end
end )
2022-02-26 20:25:48 +02:00
2022-03-15 20:50:19 +02:00
commands.add_command (
' overwrite_scores_specific ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-03-15 20:50:19 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-16 20:46:23 +02:00
2022-03-15 20:50:19 +02:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
if not Common.validate_player ( player ) then return end
local memory = Memory.get_crew_memory ( )
if Highscore.overwrite_scores_specific ( ) then player.print ( ' Highscores overwritten. ' ) end
end
end )
2022-07-28 19:15:31 +02:00
-- Unlock a class
commands.add_command (
' unlock ' ,
{ ' pirates.cmd_explain_dev ' } ,
function ( cmd )
cmd_set_memory ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local memory = Memory.get_crew_memory ( )
if not Common.is_id_valid ( memory.id ) then return end
local player = game.players [ cmd.player_index ]
2022-10-11 19:52:23 +02:00
if not Classes.try_unlock_class ( param , player , true ) then
Common.notify_player_error ( player , { ' pirates.cmd_error_invalid_class_name ' , param } )
end
2022-07-28 19:15:31 +02:00
end
end )
-- Remove all classes
commands.add_command (
' remove_classes ' ,
{ ' pirates.cmd_explain_dev ' } ,
function ( cmd )
cmd_set_memory ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local memory = Memory.get_crew_memory ( )
if not Common.is_id_valid ( memory.id ) then return end
if not Gui.classes then return end
memory.classes_table = { }
2023-02-20 18:56:41 +02:00
memory.spare_classes = { }
memory.recently_purchased_classes = { }
2022-07-28 19:15:31 +02:00
memory.unlocked_classes = { }
memory.available_classes_pool = Classes.initial_class_pool ( )
2023-02-20 18:56:41 +02:00
memory.class_entry_count = 0
2022-07-28 19:15:31 +02:00
local players = Common.crew_get_crew_members_and_spectators ( )
for _ , player in pairs ( players ) do
Gui.classes . full_update ( player , true )
end
end
end )
2022-02-26 20:25:48 +02:00
if _DEBUG then
2021-10-13 10:21:53 +02:00
2022-07-16 20:46:23 +02:00
-- Teleport player to available boat in lobby, automatically start journey and arrive at sea faster
2022-03-04 19:57:58 +02:00
commands.add_command (
' go ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-03-04 19:57:58 +02:00
function ( cmd )
2022-07-16 20:46:23 +02:00
cmd_set_memory ( cmd )
2022-03-04 19:57:58 +02:00
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
2022-07-02 17:42:22 +02:00
-- Doesn't completely prevent server from crashing when used twice at lobby, but at least saves from crashing when boat leaves lobby
if not Common.get_id_from_force_name ( player.character . force.name ) then
local proposal = {
capacity_option = 3 ,
2023-02-01 16:24:42 +02:00
difficulty_option = 4 ,
2022-07-02 17:42:22 +02:00
-- mode_option = 'left',
endorserindices = { 1 } ,
name = " AdminRun "
}
2022-07-16 20:46:23 +02:00
2022-07-02 17:42:22 +02:00
Crew.initialise_crew ( proposal )
Crew.initialise_crowsnest ( ) --contains a Task
2022-07-16 20:46:23 +02:00
2022-07-02 17:42:22 +02:00
local memory = Memory.get_crew_memory ( )
local boat = Utils.deepcopy ( Surfaces.Lobby . StartingBoats [ memory.id ] )
2022-07-16 20:46:23 +02:00
2022-07-02 17:42:22 +02:00
for _ , p in pairs ( game.connected_players ) do
p.teleport ( { x = - 30 , y = boat.position . y } , game.surfaces [ boat.surface_name ] )
end
2022-07-16 20:46:23 +02:00
2022-07-02 17:42:22 +02:00
Progression.set_off_from_starting_dock ( )
2022-07-16 20:46:23 +02:00
2022-07-02 17:42:22 +02:00
-- local memory = Memory.get_crew_memory()
-- local boat = Utils.deepcopy(Surfaces.Lobby.StartingBoats[memory.id])
-- memory.boat = boat
-- boat.dockedposition = boat.position
-- boat.decksteeringchests = {}
-- boat.crowsneststeeringchests = {}
2022-07-16 20:46:23 +02:00
Task.set_timeout_in_ticks ( 120 , go_1 , { id = memory.id } )
2022-07-02 17:42:22 +02:00
else
game.print ( ' Can \' t use this command when run has already launched ' )
2022-03-04 19:57:58 +02:00
end
end
end )
2022-03-19 23:20:55 +02:00
2022-03-09 01:36:03 +02:00
commands.add_command (
' chnk ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-03-09 01:36:03 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-16 20:46:23 +02:00
2022-03-09 01:36:03 +02:00
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local memory = Memory.get_crew_memory ( )
2022-03-19 23:20:55 +02:00
2022-03-09 01:36:03 +02:00
for i = 0 , 13 do
for j = 0 , 13 do
2022-05-29 13:36:27 +02:00
PiratesApiEvents.event_on_chunk_generated ( { surface = player.surface , area = { left_top = { x = - 7 * 32 + i * 32 , y = - 7 * 32 + j * 32 } } } )
2022-03-09 01:36:03 +02:00
end
end
game.print ( ' chunks generated ' )
end
end )
2022-03-19 23:20:55 +02:00
2022-03-09 01:36:03 +02:00
commands.add_command (
' spd ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-03-09 01:36:03 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-16 20:46:23 +02:00
2022-03-09 01:36:03 +02:00
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local memory = Memory.get_crew_memory ( )
memory.boat . speed = 60
end
end )
2022-03-19 23:20:55 +02:00
2022-03-09 01:36:03 +02:00
commands.add_command (
' stp ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-03-09 01:36:03 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-16 20:46:23 +02:00
2022-03-09 01:36:03 +02:00
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local memory = Memory.get_crew_memory ( )
memory.boat . speed = 0
end
end )
2022-03-19 23:20:55 +02:00
2022-03-09 01:36:03 +02:00
commands.add_command (
' rms ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-03-09 01:36:03 +02:00
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local rms = 0
local n = 100000
local seed = Math.random ( n ^ 2 )
for i = 1 , n do
local noise = simplex_noise ( i , 7.11 , seed )
rms = rms + noise ^ 2
end
rms = rms / n
game.print ( rms )
end
end )
2022-03-19 23:20:55 +02:00
2022-03-09 01:36:03 +02:00
commands.add_command (
' pro ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-03-09 01:36:03 +02:00
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local global_memory = Memory.get_global_memory ( )
2022-03-19 23:20:55 +02:00
2022-03-09 01:36:03 +02:00
local proposal = {
capacity_option = 3 ,
difficulty_option = 2 ,
-- mode_option = 'left',
endorserindices = { 2 } ,
name = " TestRun "
}
2022-03-19 23:20:55 +02:00
2022-03-09 01:36:03 +02:00
global_memory.crewproposals [ # global_memory.crewproposals + 1 ] = proposal
2022-03-19 23:20:55 +02:00
2022-03-09 01:36:03 +02:00
end
end )
2022-03-19 23:20:55 +02:00
2022-07-16 20:46:23 +02:00
-- Leave island, or dock immediately
2022-03-09 01:36:03 +02:00
commands.add_command (
' lev ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-03-09 01:36:03 +02:00
function ( cmd )
2022-07-16 20:46:23 +02:00
cmd_set_memory ( cmd )
2022-03-09 01:36:03 +02:00
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local memory = Memory.get_crew_memory ( )
Progression.go_from_currentdestination_to_sea ( )
end
end )
2022-03-19 23:20:55 +02:00
2022-07-16 20:46:23 +02:00
-- Add another hold
2022-03-09 01:36:03 +02:00
commands.add_command (
' hld ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-03-09 01:36:03 +02:00
function ( cmd )
2022-07-16 20:46:23 +02:00
cmd_set_memory ( cmd )
2022-03-09 01:36:03 +02:00
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local memory = Memory.get_crew_memory ( )
Upgrades.execute_upgade ( Upgrades.enum . EXTRA_HOLD )
end
end )
2022-03-19 23:20:55 +02:00
2022-07-16 20:46:23 +02:00
-- Upgrade power generators
2022-03-09 01:36:03 +02:00
commands.add_command (
' pwr ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-03-09 01:36:03 +02:00
function ( cmd )
2022-07-16 20:46:23 +02:00
cmd_set_memory ( cmd )
2022-03-09 01:36:03 +02:00
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local memory = Memory.get_crew_memory ( )
Upgrades.execute_upgade ( Upgrades.enum . MORE_POWER )
end
end )
2022-03-19 23:20:55 +02:00
2022-03-09 01:36:03 +02:00
commands.add_command (
' score ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-03-09 01:36:03 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-03-09 01:36:03 +02:00
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local memory = Memory.get_crew_memory ( )
2022-03-19 23:20:55 +02:00
2022-03-09 01:36:03 +02:00
game.print ( ' faking a highscore... ' )
2022-05-29 13:36:27 +02:00
Highscore.write_score ( memory.secs_id , ' fakers ' , 0 , 40 , CoreData.version_string , 1 , 1 )
2022-03-09 01:36:03 +02:00
end
end )
2022-03-19 23:20:55 +02:00
2022-03-09 01:36:03 +02:00
commands.add_command (
' scrget ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-03-09 01:36:03 +02:00
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
game.print ( ' running Highscore.load_in_scores() ' )
Highscore.load_in_scores ( )
end
end )
2021-10-13 10:21:53 +02:00
commands.add_command (
' tim ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2021-10-13 10:21:53 +02:00
function ( cmd )
2022-07-16 20:46:23 +02:00
cmd_set_memory ( cmd )
2021-10-13 10:21:53 +02:00
local param = tostring ( cmd.parameter )
2022-02-26 20:25:48 +02:00
if check_admin ( cmd ) then
2022-07-16 20:46:23 +02:00
local player = game.players [ cmd.player_index ]
2021-10-13 10:21:53 +02:00
local memory = Memory.get_crew_memory ( )
Common.current_destination ( ) . dynamic_data.timer = 88
game.print ( ' time set to 88 seconds ' )
end
end )
2022-07-16 20:46:23 +02:00
-- Add 20000 coal fuel to ship
2021-10-13 10:21:53 +02:00
commands.add_command (
' gld ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2021-10-13 10:21:53 +02:00
function ( cmd )
2022-07-16 20:46:23 +02:00
cmd_set_memory ( cmd )
2021-10-13 10:21:53 +02:00
local param = tostring ( cmd.parameter )
2022-02-26 20:25:48 +02:00
if check_admin ( cmd ) then
2022-07-16 20:46:23 +02:00
local player = game.players [ cmd.player_index ]
2021-10-13 10:21:53 +02:00
local memory = Memory.get_crew_memory ( )
2022-02-24 21:39:03 +02:00
memory.stored_fuel = memory.stored_fuel + 20000
2021-10-13 10:21:53 +02:00
end
end )
2022-03-19 23:20:55 +02:00
2021-10-13 10:21:53 +02:00
commands.add_command (
' rad ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2021-10-13 10:21:53 +02:00
function ( cmd )
2022-07-16 20:46:23 +02:00
cmd_set_memory ( cmd )
2021-10-13 10:21:53 +02:00
local param = tostring ( cmd.parameter )
2022-02-26 20:25:48 +02:00
if check_admin ( cmd ) then
2023-02-01 16:24:42 +02:00
local destination = Common.current_destination ( )
2021-10-13 10:21:53 +02:00
Islands.spawn_enemy_boat ( Boats.enum . RAFT )
2023-02-01 16:24:42 +02:00
local boat = destination.dynamic_data . enemyboats [ 1 ]
2022-02-28 18:36:46 +02:00
Ai.spawn_boat_biters ( boat , 0.89 , Boats.get_scope ( boat ) . Data.capacity , Boats.get_scope ( boat ) . Data.width )
2021-10-13 10:21:53 +02:00
game.print ( ' enemy boat spawned ' )
end
end )
2022-03-19 23:20:55 +02:00
2022-02-28 18:36:46 +02:00
commands.add_command (
' rad2 ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-02-28 18:36:46 +02:00
function ( cmd )
2022-07-16 20:46:23 +02:00
cmd_set_memory ( cmd )
2022-02-28 18:36:46 +02:00
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
2023-02-01 16:24:42 +02:00
local destination = Common.current_destination ( )
2022-02-28 18:36:46 +02:00
Islands.spawn_enemy_boat ( Boats.enum . RAFTLARGE )
2023-02-01 16:24:42 +02:00
local boat = destination.dynamic_data . enemyboats [ 1 ]
2022-02-28 18:36:46 +02:00
Ai.spawn_boat_biters ( boat , 0.89 , Boats.get_scope ( boat ) . Data.capacity , Boats.get_scope ( boat ) . Data.width )
game.print ( ' large enemy boat spawned ' )
end
end )
2021-10-13 10:21:53 +02:00
2022-07-16 20:46:23 +02:00
-- Spawns kraken if at sea
2021-10-13 10:21:53 +02:00
commands.add_command (
' krk ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2021-10-13 10:21:53 +02:00
function ( cmd )
2022-07-16 20:46:23 +02:00
cmd_set_memory ( cmd )
2021-10-13 10:21:53 +02:00
local param = tostring ( cmd.parameter )
2022-02-26 20:25:48 +02:00
if check_admin ( cmd ) then
2022-07-16 20:46:23 +02:00
local player = game.players [ cmd.player_index ]
2021-10-13 10:21:53 +02:00
local memory = Memory.get_crew_memory ( )
Kraken.try_spawn_kraken ( )
end
end )
2022-07-16 20:46:23 +02:00
-- Sets game speed to 0.25
2022-05-26 13:47:05 +02:00
commands.add_command (
' 1/4 ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-05-26 13:47:05 +02:00
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
2022-07-16 20:46:23 +02:00
local player = game.players [ cmd.player_index ]
game.speed = 0.25
2022-05-26 13:47:05 +02:00
end
end )
2022-07-16 20:46:23 +02:00
-- Sets game speed to 0.5
2022-05-26 13:47:05 +02:00
commands.add_command (
' 1/2 ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-05-26 13:47:05 +02:00
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
2022-07-16 20:46:23 +02:00
local player = game.players [ cmd.player_index ]
2022-05-26 13:47:05 +02:00
game.speed = 0.5
end
end )
2022-07-16 20:46:23 +02:00
-- Sets game speed to 1
2021-10-13 10:21:53 +02:00
commands.add_command (
' 1 ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2021-10-13 10:21:53 +02:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 20:25:48 +02:00
if check_admin ( cmd ) then
2022-07-16 20:46:23 +02:00
local player = game.players [ cmd.player_index ]
2021-10-13 10:21:53 +02:00
game.speed = 1
end
end )
2022-03-19 23:20:55 +02:00
2022-07-16 20:46:23 +02:00
-- Sets game speed to 2
2022-03-04 19:57:58 +02:00
commands.add_command (
' 2 ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2022-03-04 19:57:58 +02:00
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
2022-07-16 20:46:23 +02:00
local player = game.players [ cmd.player_index ]
2022-03-04 19:57:58 +02:00
game.speed = 2
end
end )
2022-03-19 23:20:55 +02:00
2022-07-16 20:46:23 +02:00
-- Sets game speed to 4
2021-10-13 10:21:53 +02:00
commands.add_command (
' 4 ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2021-10-13 10:21:53 +02:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 20:25:48 +02:00
if check_admin ( cmd ) then
2022-07-16 20:46:23 +02:00
local player = game.players [ cmd.player_index ]
2021-10-13 10:21:53 +02:00
game.speed = 4
end
end )
2022-03-19 23:20:55 +02:00
2022-07-16 20:46:23 +02:00
-- Sets game speed to 8
2021-10-13 10:21:53 +02:00
commands.add_command (
' 8 ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2021-10-13 10:21:53 +02:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 20:25:48 +02:00
if check_admin ( cmd ) then
2022-07-16 20:46:23 +02:00
local player = game.players [ cmd.player_index ]
2021-10-13 10:21:53 +02:00
game.speed = 8
end
end )
2022-03-19 23:20:55 +02:00
2022-07-16 20:46:23 +02:00
-- Sets game speed to 16
2021-10-13 10:21:53 +02:00
commands.add_command (
' 16 ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2021-10-13 10:21:53 +02:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 20:25:48 +02:00
if check_admin ( cmd ) then
2022-07-16 20:46:23 +02:00
local player = game.players [ cmd.player_index ]
2021-10-13 10:21:53 +02:00
game.speed = 16
end
end )
2022-03-19 23:20:55 +02:00
2022-07-16 20:46:23 +02:00
-- Sets game speed to 32
2021-10-13 10:21:53 +02:00
commands.add_command (
' 32 ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2021-10-13 10:21:53 +02:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 20:25:48 +02:00
if check_admin ( cmd ) then
2022-07-16 20:46:23 +02:00
local player = game.players [ cmd.player_index ]
2021-10-13 10:21:53 +02:00
game.speed = 32
end
end )
2022-03-19 23:20:55 +02:00
2022-07-16 20:46:23 +02:00
-- Sets game speed to 64
2021-10-13 10:21:53 +02:00
commands.add_command (
' 64 ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2021-10-13 10:21:53 +02:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 20:25:48 +02:00
if check_admin ( cmd ) then
2022-07-16 20:46:23 +02:00
local player = game.players [ cmd.player_index ]
2021-10-13 10:21:53 +02:00
game.speed = 64
end
end )
2022-03-19 23:20:55 +02:00
2021-10-13 10:21:53 +02:00
commands.add_command (
' ef1 ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2021-10-13 10:21:53 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-16 20:46:23 +02:00
2021-10-13 10:21:53 +02:00
local param = tostring ( cmd.parameter )
2022-02-26 20:25:48 +02:00
if check_admin ( cmd ) then
2022-07-16 20:46:23 +02:00
local player = game.players [ cmd.player_index ]
2021-10-13 10:21:53 +02:00
local memory = Memory.get_crew_memory ( )
local surface = game.surfaces [ Common.current_destination ( ) . surface_name ]
Effects.worm_movement_effect ( surface , { x = - 45 , y = 0 } , false , true )
end
end )
2022-03-19 23:20:55 +02:00
2021-10-13 10:21:53 +02:00
commands.add_command (
' ef2 ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2021-10-13 10:21:53 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-16 20:46:23 +02:00
2021-10-13 10:21:53 +02:00
local param = tostring ( cmd.parameter )
2022-02-26 20:25:48 +02:00
if check_admin ( cmd ) then
2022-07-16 20:46:23 +02:00
local player = game.players [ cmd.player_index ]
2021-10-13 10:21:53 +02:00
local memory = Memory.get_crew_memory ( )
local surface = game.surfaces [ Common.current_destination ( ) . surface_name ]
Effects.worm_movement_effect ( surface , { x = - 45 , y = 0 } , false , false )
end
end )
2022-03-19 23:20:55 +02:00
2021-10-13 10:21:53 +02:00
commands.add_command (
' ef3 ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2021-10-13 10:21:53 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-16 20:46:23 +02:00
2021-10-13 10:21:53 +02:00
local param = tostring ( cmd.parameter )
2022-02-26 20:25:48 +02:00
if check_admin ( cmd ) then
2022-07-16 20:46:23 +02:00
local player = game.players [ cmd.player_index ]
2021-10-13 10:21:53 +02:00
local memory = Memory.get_crew_memory ( )
local surface = game.surfaces [ Common.current_destination ( ) . surface_name ]
Effects.worm_movement_effect ( surface , { x = - 45 , y = 0 } , true , false )
end
end )
2022-03-19 23:20:55 +02:00
2021-10-13 10:21:53 +02:00
commands.add_command (
' ef4 ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2021-10-13 10:21:53 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-16 20:46:23 +02:00
2021-10-13 10:21:53 +02:00
local param = tostring ( cmd.parameter )
2022-02-26 20:25:48 +02:00
if check_admin ( cmd ) then
2022-07-16 20:46:23 +02:00
local player = game.players [ cmd.player_index ]
2021-10-13 10:21:53 +02:00
local memory = Memory.get_crew_memory ( )
local surface = game.surfaces [ Common.current_destination ( ) . surface_name ]
Effects.worm_emerge_effect ( surface , { x = - 45 , y = 0 } )
end
end )
2022-03-19 23:20:55 +02:00
2021-10-13 10:21:53 +02:00
commands.add_command (
' ef5 ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2021-10-13 10:21:53 +02:00
function ( cmd )
2022-06-02 20:54:47 +02:00
cmd_set_memory ( cmd )
2022-07-16 20:46:23 +02:00
2021-10-13 10:21:53 +02:00
local param = tostring ( cmd.parameter )
2022-02-26 20:25:48 +02:00
if check_admin ( cmd ) then
2022-07-16 20:46:23 +02:00
local player = game.players [ cmd.player_index ]
2021-10-13 10:21:53 +02:00
local memory = Memory.get_crew_memory ( )
local surface = game.surfaces [ Common.current_destination ( ) . surface_name ]
Effects.biters_emerge ( surface , { x = - 30 , y = 0 } )
end
end )
2022-03-19 23:20:55 +02:00
2021-10-13 10:21:53 +02:00
commands.add_command (
' emoji ' ,
2022-06-07 22:48:42 +02:00
{ ' pirates.cmd_explain_dev ' } ,
2021-10-13 10:21:53 +02:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 20:25:48 +02:00
if check_admin ( cmd ) then
2022-07-16 20:46:23 +02:00
local player = game.players [ cmd.player_index ]
2022-10-23 18:03:43 +02:00
Server.to_discord_embed_raw ( CoreData.comfy_emojis . despair )
2021-10-13 10:21:53 +02:00
end
end )
2022-06-02 15:07:17 +02:00
2022-07-16 20:46:23 +02:00
-- Spawn friendly gun turrets with ammo to defend your ship
commands.add_command (
' def ' ,
{ ' pirates.cmd_explain_dev ' } ,
function ( cmd )
cmd_set_memory ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local memory = Memory.get_crew_memory ( )
if not Common.is_id_valid ( memory.id ) then return end
2022-10-21 19:16:42 +02:00
2022-07-16 20:46:23 +02:00
local boat = memory.boat
local scope = Boats.get_scope ( boat )
2022-10-21 19:16:42 +02:00
local surface = game.surfaces [ boat.surface_name ]
if not surface then return end
2022-07-16 20:46:23 +02:00
if scope.Data . cannons then
for i = - 2 , 2 do
local p1 = scope.Data . cannons [ 1 ]
local p2 = { x = boat.position . x + p1.x + i * 2 , y = boat.position . y + p1.y - 4 }
2022-10-21 19:16:42 +02:00
local e = surface.create_entity ( { name = ' gun-turret ' , position = p2 , force = boat.force_name , create_build_effect_smoke = false } )
2022-07-16 20:46:23 +02:00
if e and e.valid then
e.insert ( { name = " uranium-rounds-magazine " , count = 200 } )
end
end
for i = - 2 , 2 do
local p1 = scope.Data . cannons [ 2 ]
2023-02-01 16:24:42 +02:00
local p2 = { x = boat.position . x + p1.x + i * 2 , y = boat.position . y + p1.y + 3 }
2022-10-21 19:16:42 +02:00
local e = surface.create_entity ( { name = ' gun-turret ' , position = p2 , force = boat.force_name , create_build_effect_smoke = false } )
2022-07-16 20:46:23 +02:00
if e and e.valid then
e.insert ( { name = " uranium-rounds-magazine " , count = 200 } )
end
end
end
end
end )
-- Spawn friendly gun turrets with ammo around you
commands.add_command (
' atk ' ,
{ ' pirates.cmd_explain_dev ' } ,
function ( cmd )
cmd_set_memory ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local memory = Memory.get_crew_memory ( )
if not Common.is_id_valid ( memory.id ) then return end
local boat = memory.boat
local p = player.character . position
local turret_positions = {
{ x = p.x - 2 , y = p.y - 2 } ,
{ x = p.x - 2 , y = p.y + 2 } ,
{ x = p.x + 2 , y = p.y - 2 } ,
{ x = p.x + 2 , y = p.y + 2 } ,
}
for _ , pos in pairs ( turret_positions ) do
local e = player.surface . create_entity ( { name = ' gun-turret ' , position = pos , force = boat.force_name , create_build_effect_smoke = false } )
if e and e.valid then
e.insert ( { name = " uranium-rounds-magazine " , count = 200 } )
end
end
end
end )
-- Give advanced starter kit to make exploration easier
commands.add_command (
' kit ' ,
{ ' pirates.cmd_explain_dev ' } ,
function ( cmd )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
player.insert { name = ' substation ' , count = 50 }
player.insert { name = ' solar-panel ' , count = 50 }
2022-10-11 22:11:49 +02:00
player.insert { name = ' vehicle-machine-gun ' , count = 1 }
2022-07-16 20:46:23 +02:00
player.insert { name = ' uranium-rounds-magazine ' , count = 200 }
player.insert { name = ' raw-fish ' , count = 100 }
player.insert { name = ' coin ' , count = 50000 }
2023-01-08 21:28:39 +02:00
player.insert { name = ' cluster-grenade ' , count = 100 }
2022-10-11 22:11:49 +02:00
player.insert { name = ' steel-chest ' , count = 50 }
2023-01-08 21:28:39 +02:00
player.insert { name = ' express-loader ' , count = 50 }
player.insert { name = ' burner-inserter ' , count = 50 }
2023-02-03 23:24:11 +02:00
player.insert { name = ' accumulator ' , count = 50 }
2022-07-16 20:46:23 +02:00
end
end )
2022-06-02 15:07:17 +02:00
commands.add_command (
' piratux_test ' ,
' is a dev command of piratux. ' ,
function ( cmd )
2022-07-02 17:42:22 +02:00
game.print ( " hello there " )
2022-06-02 15:07:17 +02:00
end )
2021-10-13 10:21:53 +02:00
end