Event for on-permissions-changed?

Kovus
Inserter
Inserter
Posts: 23
Joined: Sat Feb 27, 2016 5:25 pm
Contact:

Event for on-permissions-changed?

Post by Kovus »

Any chance that an event could be raised when the base-game permissions are changed?

I leave it up to the author of such a possible event as to whether it would raise with details for every change, or just general updates.
User avatar
kizrak
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Thu Jul 19, 2018 1:27 am
Contact:

Re: Event for on-permissions-changed?

Post by kizrak »

Kovus wrote: Sat Mar 16, 2019 9:47 pm Any chance that an event could be raised when the base-game permissions are changed?

I leave it up to the author of such a possible event as to whether it would raise with details for every change, or just general updates.
I would also love to have this feature!! :D

I would not even care if the event contained any permission change details...

And if multiple permissions changed in the same tick (assuming that changes happen during the GUI-close-tick (similar to on_runtime_mod_setting_changed event)) one event during that tick would be sufficient for what I'm trying to do.

Maybe there is just a way to tell when a user closed the permissions GUI? (Exploring this idea now...) :geek:

Please & Thanks!
-Kizrak
User avatar
kizrak
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Thu Jul 19, 2018 1:27 am
Contact:

Re: Event for on-permissions-changed?

Post by kizrak »

Code: Select all

local function on_gui_closed(event)
	local gui_type = event.gui_type

	if gui_type == defines.gui_type.permissions then
		log("resetPermissions()")
	end
end

script.on_event({
	defines.events.on_gui_closed,
},on_gui_closed)
I'm using this code to detect the permissions window closing. So far from ideal for detecting permissions change events (as it won't pick up mods/etc), it hopefully will get the job done.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14316
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Event for on-permissions-changed?

Post by Rseding91 »

I'm not against adding this event but I want to make sure I'm understanding what kind of event is being asked for. Do you just want to know "when anything permissions changes" or more gradual?

Right now these are the sets of actions that can happen:

Player added/removed from permission group
Permission group created/deleted
Permission group permission enabled/disabled
Permission group all permissions enabled/disabled

A singular "something changed" event is easy. I just want to be sure that's ok rather than having to make a bunch of different logic for conveying all the permissions actions through events.
If you want to get ahold of me I'm almost always on Discord.
User avatar
kizrak
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Thu Jul 19, 2018 1:27 am
Contact:

Re: Event for on-permissions-changed?

Post by kizrak »

I don't want to speak for Kovus, but my current goal just involves tracking permission changes any time the player (or another mod) updates them.

In my mod, players do not have a body (like a RTS) so I'm using permissions to disable crafting/mining/any-type-of-inventory-usage, and basically players have to build a base entirely with ghosts that robots construct. If they want to move something, they have to have logistic bots move it. If they want to build something, they must use construction bots. I want to ensure when new forces/permissions/players are added, that they retain their body-less permissions.

Currently/hackily, any time any permission change is detected (AKA the GUI close event for permissions window) I disable all desired permissions for all permission groups.
Kovus
Inserter
Inserter
Posts: 23
Joined: Sat Feb 27, 2016 5:25 pm
Contact:

Re: Event for on-permissions-changed?

Post by Kovus »

It's been over a year. At the time, I was implementing a mod to be a super-set of permissions (which could be exported/imported between games). Since we couldn't create custom permissions (primarily for multiplayer administrative tools), I was looking to grab updates from the permissions changes to keep in sync.

The more granular, the less work I'd have to do on the mod side. Though, that might come at the cost of calling the same event handler(s) multiple times in a single tick; provided permissions are modified on-save as kizrak suggested.
User avatar
MewMew
Long Handed Inserter
Long Handed Inserter
Posts: 55
Joined: Thu May 19, 2016 11:02 am
Contact:

Re: Event for on-permissions-changed?

Post by MewMew »

It seems, it is impossible to know who is changing permissions, if there are multiple admins in the same game.

This is a bit of an issue and could be solved by having an event.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14316
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Event for on-permissions-changed?

Post by Rseding91 »

Ok, I added the following events for the next release: on_permission_group_edited, on_pre_permission_string_imported, on_permission_string_imported, on_per_permission_group_deleted, on_permission_group_deleted, and on_permission_group_added.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Implemented mod requests”