PDA

View Full Version : Suggested change for CoreRPG manager_gmidentity.lua



cscase
September 22nd, 2013, 02:21
I found that while you can switch to any NPC identity (whether it already exists or not) by typing "/id <name>," there's no way to switch with a slash command back to the GM ID. If you use /gmid, it changes the name of the GM ID, but doesn't activate it. And if you type /id <your GM id here>, the UI gets into a borked state where it creates an ID with the same name as the GM ID and neither one of them work right. From there you have to reload in order to have IDs work right again.

A small change to the id slash command handler function both fixes the bug and also allows you to use the /id command to activate the GM identity. I changed the function on line 18 of manager_gmidentity.lua as follows. Added code in blue:



function slashCommandHandlerId(sCommand, sParams)
if not User.isHost() then
return;
end
if string.upper(sParams) == string.upper(CampaignRegistry.gmidentity) then
activateGMIdentity();
return;
else
addIdentity(sParams, false);
end
end

Thoughts?

Andraax
September 22nd, 2013, 07:00
I'm getting the following:

Script Error: [string "scripts/gm_id.lua"]:10: bad argument #1 to 'upper' (string expected, got nil)

(I put your code into an extension, which is why the module has a different name.)

Andraax
September 22nd, 2013, 07:14
And here is the fixed version (my copy of gm_id.lua, which is installed as an extension so that I don't have to mess around with the CoreRPG ruleset).


-- Replacement for /id, allows use of /id gm
function onInit()
Comm.registerSlashHandler("identity", slashCommandHandlerId);
end

function slashCommandHandlerId(sCommand, sParams)
if not User.isHost() then
return;
end
local GMname = CampaignRegistry.gmidentity or "GM";
if string.upper(sParams) == string.upper(GMname) then
GmIdentityManager.activateGMIdentity();
else
GmIdentityManager.addIdentity(sParams, false);
end
end

cscase
September 22nd, 2013, 07:57
Aha, that campaign registry value is nil if no custom name has been set, I guess. I had one set at the time I tried this and didn't catch that! Thanks, Andraax!!

Moon Wizard
September 22nd, 2013, 08:04
Got it in the queue for the next cycle.

Thanks,
JPG