Page 1 of 1

Weird idea: Websocket Server to interact with the game

Posted: Mon Jan 29, 2018 2:42 pm
by BrainFooLong
I had an idea that is, well, somewhat out of mind.
I am generally a passionate web developer with focus on cutting edge technologies and abstract ideas.

I wanted to create a mod that can interact with the game dynamically and that is able to control everything in-game from just a website.

What i had in mind was

- Create a mod that implement a lua websocket server. Well, isn't possible, i tried it. So it must be done by game devs directly.
- Let the websocket server trigger and submit all events so i am able to connect to the game and interact with it (via website websocket client basically)
- Play factorio completely script based - I modify my website scripts, reload the website and see if all work out as expected

So this way, i thought, i will have fun in a completely different way with factorio.
Create the best scripts and possible to program a complete play-through, script based, with just the use of javascript and websocket communication.
I think this would be a whole new challange, albeit it's for a small portion of the playerbase.

Just to imagine what i mean
- Factorio send event "on_player_mined_item" to websocket client (the website script that is connected with factorio).
- The website script check for this event, do something and send to the server "walk_player(x,y)".
- In-Game now the user walk to (x,y)

Or, if you think further, you can enhance factorio even more by your complete own tactics, helpers, charts, from just a website (local or online, it doesn't matter).
Let's think about having opened factorio on monitor 1 + on monitor 2 you have opened a screeen that show your current production stats or something like that.
So many ideas that comes to my mind. Let's call if "factorio pro tools" :)

I know, an idea out of any scope. Maybe the devs are also crazy and have an ear for this idea :)
IMHO it is not that complecated to add some support for that.
The first way just could be: Trigger and listen for everything what LUA events already do but just also for the websocket.
C++ servers are enough available.
Factorio than just listen to something like: "localhost:6666" and you are able to connect to it.

Ok, i stop dreaming here :)

Re: Weird idea: Websocket Server to interact with the game

Posted: Mon Jan 29, 2018 4:40 pm
by Tekky
According to the wiki page on the console, it seems to be possible to run arbitrary LUA commands over an RCON connection. I have never tried it, though.

With these LUA commands, it should be possible to query the game state to a certain degree, for example to find out all entities in the surrounding area of the player.

Re: Weird idea: Websocket Server to interact with the game

Posted: Mon Jan 29, 2018 5:05 pm
by BrainFooLong
RCON is just to send some commands to the server. But it's generally just a command-line interface.
No real event based system. RCON is basically just for server administrators.

As a second, the source RCON protocol is very basic per nature. I've made some programs for that protocol in the past.

Re: Weird idea: Websocket Server to interact with the game

Posted: Mon Jan 29, 2018 5:58 pm
by Tekky
BrainFooLong wrote:RCON is just to send some commands to the server. But it's generally just a command-line interface. No real event based system.
I guess it should be possible for your web application to regularily call a LUA function over RCON which returns whether any interesting new events have occured since the last function call. However, such a polling system is not very efficient. A proper event-based system would be better.

Re: Weird idea: Websocket Server to interact with the game

Posted: Tue Jan 30, 2018 7:09 am
by MCRCortex
I had asked the devs about that, using sockets in lua, and they said that it would cause an instantaneous de-sync with the client and server

Re: Weird idea: Websocket Server to interact with the game

Posted: Tue Jan 30, 2018 11:42 am
by BrainFooLong
MCRCortex wrote:I had asked the devs about that, using sockets in lua, and they said that it would cause an instantaneous de-sync with the client and server
Sure, it will probably only work as client only on localhost :)

But i don't talk about any LUA implementation here. My idea need to be directly in the game, unrelated to LUA.

As i've said, crazy idea. But factorio is one of the games that is predestined for such "programmer" ideas and the devs of factorio are somewhat open for experiments (Like the Razer Chroma and Razer Chroma Link support).

I will create some nice looking picture that explain more visually what i think of.

Re: Weird idea: Websocket Server to interact with the game

Posted: Tue Jan 30, 2018 11:58 am
by mrvn
Isn't clusterio doing sockets between the game and the outside?

Re: Weird idea: Websocket Server to interact with the game

Posted: Tue Jan 30, 2018 6:12 pm
by BrainFooLong
mrvn wrote:Isn't clusterio doing sockets between the game and the outside?
Not really. It's basically a HTTP request thingy. Not related to websockets and real-time communication.