Hello and good time of day.
How to ensure that (existing, my own) mod work well in multiplayer?
Many scripting, many new entities.
Is there some recomedndations somewhere?
Thanks in advance.
How to make MP-compatible mod?
Re: How to make MP-compatible mod?
Just a few things:
- Store all of your mutable variables in the "global" table. If you don't know what mutable means - just store all of your variables in the "global" table.
- Only run code in reaction to a event
- Make sure you don't mutate things in the on_load event. If you don't know what that means just avoid the on_load event.
If you want to get ahold of me I'm almost always on Discord.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: How to make MP-compatible mod?
use game.players[#]. instead of game.player.
Re: How to make MP-compatible mod?
game.player also doesn't work in singleplayer... it's only available from the console, nowhere elsebobingabout wrote:use game.players[#]. instead of game.player.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: How to make MP-compatible mod?
you'd be surprised how many mods fail to work because they've used game.player in their scripting.Bilka wrote:game.player also doesn't work in singleplayer... it's only available from the console, nowhere elsebobingabout wrote:use game.players[#]. instead of game.player.
-
- Filter Inserter
- Posts: 952
- Joined: Sat May 23, 2015 12:10 pm
- Contact:
Re: How to make MP-compatible mod?
but don't ever hardcode game.players[1], instead either loop over all players or use the player involved in whatever event that triggered the codebobingabout wrote:use game.players[#]. instead of game.player.