How to detect freeplay?

Place to get help with not working mods / modding interface.
hoho
Filter Inserter
Filter Inserter
Posts: 684
Joined: Sat Jan 18, 2014 11:23 am
Contact:

How to detect freeplay?

Post by hoho »

I'm trying to update Pocket Bots Start to 0.13. I got it so far that it does everything it's supposed to do but only if I comment out the way it detects if it's running in freeplay mode.

I would like to post the update on forums but not before I make it not to add stuff to players when they are playing scenarios. In other words, I need to find if the game is in freeplay mode or not.


In 0.12 it used this code to detect it:

Code: Select all

if remote.interfaces.freeplay then
....
but freeplay interface doesn't seem to exist.

Running

Code: Select all

/c game.player.print(serpent.block(remote.interfaces))
gave me interfaces for the other mods I was running but nothing related to what mode the game was in.


Does anyone know how to detect the freeplay in 0.13?
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: How to detect freeplay?

Post by DaveMcW »

This is the script the freeplay runs:

Code: Select all

script.on_event(defines.events.on_player_created, function(event)
  local player = game.players[event.player_index]
  player.insert{name="iron-plate", count=8}
  player.insert{name="pistol", count=1}
  player.insert{name="firearm-magazine", count=10}
  player.insert{name="burner-mining-drill", count = 1}
  player.insert{name="stone-furnace", count = 1}
  if (#game.players <= 1) then
    game.show_message_dialog{text = {"msg-intro"}}
  end
  player.force.chart(player.surface, {{player.position.x - 200, player.position.y - 200}, {player.position.x + 200, player.position.y + 200}})
end)
So you could detect whether a player has exactly that inventory.
hoho
Filter Inserter
Filter Inserter
Posts: 684
Joined: Sat Jan 18, 2014 11:23 am
Contact:

Re: How to detect freeplay?

Post by hoho »

Problem with that is that there are other mods that also change what player gets into their inventory when they spawn.
Post Reply

Return to “Modding help”