Page 1 of 1

LuaRemote and multiplayer ?

Posted: Sun Apr 10, 2016 3:23 pm
by binbinhfr
Hi,

I wonder how I should write a remote/interface function to be consistent with multiplayer...

For example, if I want to write a function that launches the creation of a building by the player who is launching the remote command ?

I cannot use game.local_player to get some infos, because it is only accessible from console...
I cannot use game.player either, only accessible under solo game.

ex: the force of the object that is created must be the force of the player emitting the remote command.
I also need the position of the player to place the building close to the player.

And I wonder if a remote.call on one computer will be sent/replicate to other computer in the game ?...

Re: LuaRemote and multiplayer ?

Posted: Mon Apr 11, 2016 11:01 am
by ratchetfreak
all mod code will run exactly the same on all peers/clients-server

Re: LuaRemote and multiplayer ?

Posted: Mon Apr 11, 2016 2:11 pm
by binbinhfr
ratchetfreak wrote:all mod code will run exactly the same on all peers/clients-server
OK, I understand that, so (for example) how would you write a remote interface that create a building close to the player that run the interface command in the console ? And so that creation appears on all clients at the right place ?

Re: LuaRemote and multiplayer ?

Posted: Mon Apr 11, 2016 3:45 pm
by ratchetfreak
like with a gui? the gui event includes the player that clicked the button.

Re: LuaRemote and multiplayer ?

Posted: Mon Apr 11, 2016 4:09 pm
by binbinhfr
ratchetfreak wrote:like with a gui? the gui event includes the player that clicked the button.
no, I know how to do it with the GUI, I'd like to do it from the interface :
http://lua-api.factorio.com/0.12.30/LuaRemote.html

Re: LuaRemote and multiplayer ?

Posted: Mon Apr 11, 2016 6:12 pm
by ratchetfreak
That's for mods calling to other mods, if you want them to work on a player then tell them to pass the player to work with.

Re: LuaRemote and multiplayer ?

Posted: Tue Apr 12, 2016 11:19 am
by binbinhfr
ratchetfreak wrote:That's for mods calling to other mods, if you want them to work on a player then tell them to pass the player to work with.
Yes, I finally end to this same conclusion... Thanks for your help.