1
0
mirror of https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git synced 2024-12-04 09:43:00 +02:00

Adding in player colored chat messages. Comment out log spam events. Add destroy decoratives to template scenario.

This commit is contained in:
Oarcinae 2024-11-29 13:50:38 -05:00
parent 8a077190ec
commit 3f6f92e4aa
3 changed files with 20 additions and 11 deletions

View File

@ -61,7 +61,8 @@ remote.add_interface("oarc_scenario", oarc_scenario_interface)
local util = require("util")
-- You can require files to use them if you want like this:
-- You can require files to use them if you want like this. (Ignore the diagnostic warning.)
---@diagnostic disable-next-line: different-requires
require("__oarc-mod__/lib/oarc_gui_utils")
-- This will keep a local copy of the mod's config so you can use it in your custom events.
@ -99,6 +100,9 @@ script.on_event("oarc-mod-on-chunk-generated-near-spawn", function(event)
---@type OarcModOnChunkGeneratedNearSpawnEvent
local custom_event = event
-- Remove decoratives (grass/roots/enemy-decal)
custom_event.surface.destroy_decoratives {area = custom_event.chunk_area}
-- Get the spawn config from our local copy.
local general_spawn_config = storage.ocfg_copy.spawn_general
local surface_spawn_config = storage.ocfg_copy.surfaces_config[custom_event.surface.name].spawn_config

View File

@ -216,14 +216,16 @@ end)
---@field surface LuaSurface
---@field chunk_area BoundingBox
---@field spawn_data OarcUniqueSpawn
script.on_event("oarc-mod-on-chunk-generated-near-spawn", function(event)
log("EVENT - oarc-mod-on-chunk-generated-near-spawn:" .. serpent.block(event --[[@as OarcModOnChunkGeneratedNearSpawnEvent]]))
end)
-- script.on_event("oarc-mod-on-chunk-generated-near-spawn", function(event)
-- I wouldn't recommend any logging inside this event as it is called for every chunk generated near a spawn.
-- log("EVENT - oarc-mod-on-chunk-generated-near-spawn:" .. serpent.block(event --[[@as OarcModOnChunkGeneratedNearSpawnEvent]]))
-- end)
---@class OarcModOnConfigChangedEvent: OarcCustomEventBase
script.on_event("oarc-mod-on-config-changed", function(event)
log("EVENT - oarc-mod-on-config-changed:" .. serpent.block(event --[[@as OarcModOnConfigChangedEvent]]))
end)
-- script.on_event("oarc-mod-on-config-changed", function(event)
-- This can get called quite a lot during init or importing of settings.
-- log("EVENT - oarc-mod-on-config-changed:" .. serpent.block(event --[[@as OarcModOnConfigChangedEvent]]))
-- end)
-- I raise this event whenever teleporting the player!
script.on_event(defines.events.script_raised_teleported, function(event)

View File

@ -1,6 +1,8 @@
-- My general purpose utility functions and constants for factorio
-- Also contains some constants
-- (Ignore the diagnostic warning.)
---@diagnostic disable-next-line: different-requires
require("lib/oarc_gui_utils")
require("mod-gui")
@ -147,11 +149,11 @@ function SendBroadcastMsg(msg)
end
---Send a message to a player, safely checks if they exist and are online.
---@param playerName string
---@param player_name string
---@param msg LocalisedString
---@return nil
function SendMsg(playerName, msg)
local player = game.players[playerName]
function SendMsg(player_name, msg)
local player = game.players[player_name]
if ((player ~= nil) and (player.connected)) then
CompatSend(player, msg)
end
@ -454,10 +456,11 @@ function ShareChatBetweenForces(player, msg)
(force.name ~= "neutral") and
(force.name ~= "player") and
(force ~= player.force)) then
CompatSend(force, {"", player.name, ": ", msg})
CompatSend(force, {"", player.name, ": ", msg}, { color = player.color, sound_path = nil})
end
end
end
game.play_sound { path = "utility/scenario_message", volume_modifier = 1 }
end
-- -- Merges force2 INTO force1 but keeps all research between both forces.