PDA

View Full Version : Potential Issue with Module.setModule Permissions and activate



Mad Nomad
April 14th, 2022, 16:30
The Module.setModulePermissions() function does not seem to be working for me. I've tried everything I can think of, but calling it just doesn't seem to have any impact.

Here's some sample code which I called onInit and also I tried calling it onDesktopInit too in case that might be impacting it. But both have the same result.

Module.setModulePermissions("5E Items Effects Coding - Weapons",true,true) ;

Debug.chat(Module.getModuleInfo("5E Items Effects Coding - Weapons"))

It prints the below info. As you can see, it doesn't seem to change the loading parameter. It also seems to be using a string for loading paremeter, but the value is bFalse. I suspect that might have something to do with it. Maybe some associated function is looking for a boolean value but you are storing a string?

{ s'replaces' = { }, s'loaded' = bTRUE, s'author' = s'Rob Twohy (rob2e)', s'anyflag' = bFALSE, s'installed' = bTRUE, s'permission' = s'allow', s'name' = s'5E Items Effects Coding - Weapons', s'category' = s'5E Rob Twohy (rob2e) Modules', s'loading' = bFALSE, s'intact' = bTRUE, s'displayname' = s'5E Items Effects Coding - Weapons' }


I tried using the Module.activate() function for client as well, but I get same result.

Module.activate("5E Items Effects Coding - Weapons") ;

Moon Wizard
April 14th, 2022, 17:12
The Module.setModulePermissions and Module.activate functions are used in the Module Activation window that is part of CoreRPG; so it appears to be working as expected.

The correct calls are:
Module.setModulePermissions(lookupname, "allow"|"disallow");
Module.activate(lookupname);

Regards,
JPG

Mad Nomad
April 14th, 2022, 17:28
Sorry if I am being dense.


I see this function below in ruleset, which I think you are referencing, but neither "allow" nor "disallow" actually uses "true" on the 3rd parameter, which is supposed to control autoloading.

function setModulePermissions(sModule, sPermission)
if sPermission == "disallow" then
Module.setModulePermissions(sModule, false, false);
elseif sPermission == "allow" then
Module.setModulePermissions(sModule, true, false);
end
end

from wiki, I'm focused on the autoload parameter.

function setModulePermissions(name, allow, autoload)
Sets the loading permissions for the given module. This function will fail if called from a client mode script.

Parameters

name (string)
The name of the module being targeted by the operation

allow (boolean)
A value of true to allow clients to load the module, or false to prohibit loading

autoload (boolean)
If true, all clients that can access the module will automatically load it. The second parameter must be true for this parameter to have any effect.

mattekure
April 14th, 2022, 17:44
The Module.setModulePermissions and Module.activate functions are used in the Module Activation window that is part of CoreRPG; so it appears to be working as expected.

The correct calls are:
Module.setModulePermissions(lookupname, "allow"|"disallow");
Module.activate(lookupname);

Regards,
JPG

The function setModulePermissions thats defined in Core moduleselection.lua has the format setModulePermissions(lookupname, "allow"|"disallow");

But the Module.setModulePermissions API call is called like this in that function.


function setModulePermissions(sModule, sPermission)
if sPermission == "disallow" then
Module.setModulePermissions(sModule, false, false);
elseif sPermission == "allow" then
Module.setModulePermissions(sModule, true, false);
end
end

The issue seems to be that the last parameter in the function Module.setModulePermissions(name, allow, autoload) isnt respecting the autoload even when set to true.

Moon Wizard
April 14th, 2022, 18:31
The autoload was previously removed in FGC, and never part of FGU; I will update the documentation.

Regards,
JPG

jharp
April 14th, 2022, 21:25
So I presume the solution is an OOB message to the client to load the module once permissions are set.

Jason