darrenan
June 3rd, 2024, 20:16
As the title says, I'm trying to change the client startup behavior to pop up the character selection window only if the User logging in currently has owned characters, and otherwise popup a different window on startup. Currently the code looks like this:
--
-- Please see the license.html file included with this distribution for
-- attribution and copyright information.
--
function onInit()
Desktop.onTabletopInit = onTabletopInit;
end
function onTabletopInit()
User.addEventHandler("onLogin", Desktop.onUserLogin);
if not Session.IsHost then
-- This user has any characters, then open the character selection window, otherwise open the playbook list.
aIdentities = User.getOwnedIdentities();
Debug.chat("Owned Identities:");
for _,sId in ipairs(aIdentities) do
Debug.chat(sId);
end
if #aIdentities == 0 then
Interface.openWindow("masterindex", "playbook");
else
Interface.openWindow("charselect_client", "");
end
end
Desktop.registerModuleSets();
if not CampaignRegistry or not CampaignRegistry.setup then
Interface.openWindow("setup", "");
end
end
(ignore the Debug. lines, that's just me trying to figure out what's going on). Currently, aIdentities always comes back empty, even after creating a character. Is this because the client doesn't have permissions to get that type of info? Is there something else I'm doing wrong here? I have also tried User.getActiveIdentities with the same results (I didn't expect that one to work since the user doesn't have any active identities on startup).
--
-- Please see the license.html file included with this distribution for
-- attribution and copyright information.
--
function onInit()
Desktop.onTabletopInit = onTabletopInit;
end
function onTabletopInit()
User.addEventHandler("onLogin", Desktop.onUserLogin);
if not Session.IsHost then
-- This user has any characters, then open the character selection window, otherwise open the playbook list.
aIdentities = User.getOwnedIdentities();
Debug.chat("Owned Identities:");
for _,sId in ipairs(aIdentities) do
Debug.chat(sId);
end
if #aIdentities == 0 then
Interface.openWindow("masterindex", "playbook");
else
Interface.openWindow("charselect_client", "");
end
end
Desktop.registerModuleSets();
if not CampaignRegistry or not CampaignRegistry.setup then
Interface.openWindow("setup", "");
end
end
(ignore the Debug. lines, that's just me trying to figure out what's going on). Currently, aIdentities always comes back empty, even after creating a character. Is this because the client doesn't have permissions to get that type of info? Is there something else I'm doing wrong here? I have also tried User.getActiveIdentities with the same results (I didn't expect that one to work since the user doesn't have any active identities on startup).