LUA console_command

Angamara
Inserter
Inserter
Posts: 39
Joined: Mon Oct 30, 2017 3:52 pm
Contact:

LUA console_command

Post by Angamara »

Good evening,

Here are some additions that would be interesting to have for the management of a server with LUA.

Currently to have a moderation equivalent on a server, we must give the rank of admin to a player. Even if one can disable certain command, it would be non-constructive to private the owner of the server of any command to contain the potential abuse of power of a lambda player.

Could we have something like this:

game.console_command (player_index, command, parameters)
  • Contains
    player_index :: uint (optional): The player if any.
    command :: string: The command without the preceeding forward slash ('/').
    parameters :: string: The parameters provided if any.
This would have several types of rank, for example, the moderator could only kick, and the admin could ban and kick. By adding a ranking system that the API already allows.

And since we are talking about adding commands to the API, here is a small additional list:

- To be able to read all the settings of the game. (Like the name, description or authorized player limit): Just useful for information in the game
- Show server date: Useful for logger

Cya
Rseding91
Factorio Staff
Factorio Staff
Posts: 14912
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LUA console_command

Post by Rseding91 »

There's already an event which will tell you any time anyone runs any command in the game: http://lua-api.factorio.com/latest/even ... le_command and you can create your own commands which work for anyone typing in the console. I'm not sure how that would differ from what you're asking.

Regarding server settings/date: none of those are deterministic and as such aren't available for mods to read.

You don't need any date/time because any calls you do to log(...) automatically have the time stamp added to them.
If you want to get ahold of me I'm almost always on Discord.
Angamara
Inserter
Inserter
Posts: 39
Joined: Mon Oct 30, 2017 3:52 pm
Contact:

Re: LUA console_command

Post by Angamara »

As English is not my native language, it may not be understanding.

Are we in the right place in the forum to request / propose improvements in the API?

To be even more precise, I'm not talking about a command that can be sent by the game console but by a script lua

I know there is an event that reads the send command. This does not prevent the command from being sent or from being able to send a kick command in LUA.

The "kick" command exists, but what I'm looking for is to be able to allow this command to a person who has not been promoted admin and to send the command by the script and not a natural person.

About the server settings, they must and surely store somewhere, a command to access it is by definition possible.

Speaking of log, I was talking about history, Manually create files containing real dates ,it does not help me to know that an action was made at 785642 ticks.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14912
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LUA console_command

Post by Rseding91 »

Angamara wrote:About the server settings, they must and surely store somewhere, a command to access it is by definition possible.
You don't seem to understand how Factorio multiplayer works. If something is not deterministic mods aren't allowed to access it or it would desync multiplayer and break replays.

So your request isn't actually about Lua console commands - you want to be able to do the same things console commands are doing through script?
If you want to get ahold of me I'm almost always on Discord.
Angamara
Inserter
Inserter
Posts: 39
Joined: Mon Oct 30, 2017 3:52 pm
Contact:

Re: LUA console_command

Post by Angamara »

Rseding91 wrote:So your request isn't actually about Lua console commands - you want to be able to do the same things console commands are doing through script?
It's exactly that
Angamara
Inserter
Inserter
Posts: 39
Joined: Mon Oct 30, 2017 3:52 pm
Contact:

Re: LUA console_command

Post by Angamara »

Rseding91 wrote:You don't seem to understand how Factorio multiplayer works. If something is not deterministic mods aren't allowed to access it or it would desync multiplayer and break replays.
Tell me, how does connectivity work? It must not be very different from other games

If we are connected to a server, we have somehow access to these data at one time or another.

If the client needs to store this data to access it then it would be enough for the client to temporarily store the information of the server on which it connects.

We already have access to the setting of pollution or the expanssion of bitters, why not the rest?
Rseding91
Factorio Staff
Factorio Staff
Posts: 14912
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LUA console_command

Post by Rseding91 »

You can read how multiplayer works here: https://www.factorio.com/blog/post/fff-55
If you want to get ahold of me I'm almost always on Discord.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14912
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LUA console_command

Post by Rseding91 »

Specifically: the server host name and player limit are not part of the game state. They don't change how the game runs from the internal game logic perspective - the name could be "orange tree glass" or "tin can" and it wouldn't change how a single calculation in the game works. If mods could read it, then it would need to be included in the save file and updated through the input action system every time it changed - sending it over the network to all connected players. Because it's not, it's not deterministic and only known by the server host - and as such mods are not allowed to access it because they have no idea what it is.
If you want to get ahold of me I'm almost always on Discord.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14912
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LUA console_command

Post by Rseding91 »

I've added methods to LuaGameScript to kick, ban, unban, mute, unmute, and perge for 0.16. Scripts can run them however they like and if a player tries to use them from the console and he's not an admin it just does nothing and tells him he can't do it because he's not an admin.
If you want to get ahold of me I'm almost always on Discord.
Angamara
Inserter
Inserter
Posts: 39
Joined: Mon Oct 30, 2017 3:52 pm
Contact:

Re: LUA console_command

Post by Angamara »

Thanks for that
Post Reply

Return to “Implemented mod requests”