welcome message on player joined game

Place to get help with not working mods / modding interface.
Blood Angel
Inserter
Inserter
Posts: 21
Joined: Thu Dec 21, 2017 8:45 am
Contact:

welcome message on player joined game

Post by Blood Angel »

I want to send "welcome message" then player joins to the server like 'no one will survive' or something like this.
google says that I may add it to lua
I've changed data/base/script/freeplay/control.lua on server side

Code: Select all

-- The script runs on the on_player_joined_game event
script.on_event(defines.events.on_player_joined_game, function(event)
  local player = game.players[event.player_index]
  game.print({"no one will survive", player.name})
end)
but when I try to connect, I get error

Code: Select all

Cannot join. The following mod script files are not identical between you and the server:

level
in this case I'll have to manually sync control.lua with all players. sad thing. maybe there's another way to create server side script without syncing it with players?
Atraps003
Fast Inserter
Fast Inserter
Posts: 122
Joined: Thu Jan 04, 2018 6:34 am
Contact:

Re: welcome message on player joined game

Post by Atraps003 »

Create a new scenario on the server instead of modifying data/base/script/freeplay/

You can copy control.lua and freeplay.lua from data/base/script/freeplay/

scenarios/my-scenario/info.json
scenarios/my-scenario/description.json
scenarios/my-scenario/control.lua
scenarios/my-scenario/freeplay.lua

Then you load the scenario on headless server with this.

./bin/x64/factorio --start-server-load-scenario "my-scenario" --server-settings ./data/server-settings.json --map-gen-settings ./data/map-gen-settings.json --map-settings ./data/map-settings.json
Blood Angel
Inserter
Inserter
Posts: 21
Joined: Thu Dec 21, 2017 8:45 am
Contact:

Re: welcome message on player joined game

Post by Blood Angel »

Atraps003 wrote: Mon Oct 20, 2025 6:08 pm Create a new scenario on the server instead of modifying data/base/script/freeplay/
thank you. it works now
10-20-2025, 21-52-38.png
10-20-2025, 21-52-38.png (171.57 KiB) Viewed 167 times

cat data/base/scenarios/my-scenario/control.lua

Code: Select all

local handler = require("event_handler")
handler.add_lib(require("freeplay"))

if script.active_mods["space-age"] then
  handler.add_lib(require("space-finish-script"))
else
  handler.add_lib(require("silo-script"))
end
-- The script runs on the on_player_joined_game event
script.on_event(defines.events.on_player_joined_game, function(event)
  local player = game.players[event.player_index]
  game.print("no one will survive", {player.name})
end)
I'm not sure if the message will be shown to all active players or just those who have connected.
also the question: is it possible pop-up message instead of chat like this:
62mczdj88a7a1.png
62mczdj88a7a1.png (432.41 KiB) Viewed 167 times
Blood Angel
Inserter
Inserter
Posts: 21
Joined: Thu Dec 21, 2017 8:45 am
Contact:

Re: welcome message on player joined game

Post by Blood Angel »

If i create custom scenario, there are no achievements.
in this case, I created new default game, unzip save file, added script to control.lua and zip it again, start server with modified save. and "welcome message" works.
User avatar
Osmo
Fast Inserter
Fast Inserter
Posts: 186
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

Re: welcome message on player joined game

Post by Osmo »

Blood Angel wrote: Mon Oct 20, 2025 7:04 pm I'm not sure if the message will be shown to all active players or just those who have connected.
Since you use game.print, it will print the message to all players. Use player.print if you want to print a message for a specific player.
Blood Angel wrote: Mon Oct 20, 2025 7:04 pm also the question: is it possible pop-up message instead of chat like this:
62mczdj88a7a1.png
You'll have to create a gui for it and handle events for when the window is confirmed or button is pressed and close the window.
Post Reply

Return to “Modding help”