For mods, it would be useful if there was a `game.multiplayer` property to differentiate between MP and SP games.
Using #players <= 1 isn't reliable as MP games can potentially have periods where there's just one player. Likewise, the player.admin has some edge cases (like when loading an MP save in SP mode).
Background: viewtopic.php?f=25&t=33263
game.multiplayer
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
game.multiplayer
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Re: game.multiplayer
I don't see why you would need to know whether the game is multiplayer or singleplayer
Re: game.multiplayer
An obvious case would be to turn off mods that enable in-game forces setup via some gui. Having less clutter on screen is never bad.Klonan wrote:I don't see why you would need to know whether the game is multiplayer or singleplayer
Fairly certain there are other mods out there that only make sense in MP.
[edit]
Another nice thing to have would be to be able to detect if it's freeplay or a scenario. E.g I'd prefer not to have mods that modify starting inventory to interfere with scenarios.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: game.multiplayer
Looks like there's a way to determine if game is SP or MP via certain events: viewtopic.php?p=209277#p209277
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: game.multiplayer
BTW, reason I personally wanted to do it: In a mod I'm working on, I want player in SP game to have a lootable ship wreck, whereas if used in MP game that would be impractical and just get the lootable items immediately in their inventory.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Re: game.multiplayer
Seems easy enough to set a global.looted flag in on_player_created. Then give every other player the items in their inventory.
Re: game.multiplayer
aubergine18 wrote:For mods, it would be useful if there was a `game.multiplayer` property to differentiate between MP and SP games.
Using #players <= 1 isn't reliable as MP games can potentially have periods where there's just one player. Likewise, the player.admin has some edge cases (like when loading an MP save in SP mode).
Background: viewtopic.php?f=25&t=33263
I need this as well, would appreciate it!
Re: game.multiplayer
I have recently encountered a problem about a local save of a multiplayer game being loaded in singleplayer mode:
My custom permission system in Creative Mode determined the player as non-admin (not the first player in the game, player.index is 8 and player.admin is false), hence he cannot access some admin-only features.
I have also tried to check game.player.connected, but it is true.
The problem can be easily fixed if there is a way to determine if the current game is singleplayer mode, so I can grant the local player full access to all features.
My custom permission system in Creative Mode determined the player as non-admin (not the first player in the game, player.index is 8 and player.admin is false), hence he cannot access some admin-only features.
I have also tried to check game.player.connected, but it is true.
The problem can be easily fixed if there is a way to determine if the current game is singleplayer mode, so I can grant the local player full access to all features.
Re: game.multiplayer
2 new ideas to solve the problem:
1) player.admin always returns true in singleplayer mode, or
2) allow mods to change the value of player.admin (e.g. player.admin [RW], or LuaPlayer::promote_player(player) + LuaPlayer::demote_player(player), etc.)
1) player.admin always returns true in singleplayer mode, or
2) allow mods to change the value of player.admin (e.g. player.admin [RW], or LuaPlayer::promote_player(player) + LuaPlayer::demote_player(player), etc.)