Page 1 of 1

Event for on-permissions-changed?

Posted: Sat Mar 16, 2019 9:47 pm
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.

Re: Event for on-permissions-changed?

Posted: Sat May 23, 2020 6:16 pm
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

Re: Event for on-permissions-changed?

Posted: Thu Jun 04, 2020 5:14 pm
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.

Re: Event for on-permissions-changed?

Posted: Fri Jun 05, 2020 4:50 pm
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.

Re: Event for on-permissions-changed?

Posted: Thu Jun 11, 2020 2:07 am
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.

Re: Event for on-permissions-changed?

Posted: Mon Jul 06, 2020 2:53 pm
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.