PDA

View Full Version : Help with Local versus Host scripting



Paul Pratt
August 4th, 2017, 07:10
Hello,

I am working in some new territory here so any help is appreciated. I have been reading through the "User" portion of the developer guide and have only managed to get myself lost. I am trying to create an option that will modify a portion of the character sheet with an option players can set. It works, but if the GM has the same option set to a different setting the GM's display will be different.

Sample. The option can set a label to read X, Y, or Z. The player sets the label to X. The GM has the same option set to Y. The player's charsheet displays X, the GM opens the player's charsheet and will see Y. How can I set this so the GM is forced to see the option the player has chosen, i.e. X?

Code I have so far:


function onInit()
OptionsManager.registerCallback("CGS", updateDisplayGear);
updateDisplayGear();

end

function onClose()
OptionsManager.unregisterCallback("CGS", updateDisplayGear);
end
function updateDisplayGear()
local sOp = OptionsManager.getOption("CGS");
local bDH1 = sOp == "dh1";
local bRT = sOp == "rt";
local bDW = sOp == "dw";
local bBC = sOp == "bc";
local bOW = sOp == "ow";
local bDH2 = sOp == "dh2";

influence_label.setVisible(bDH1 or bRT or bDW or bOW or bDH2);
influence.setVisible(bDH1 or bRT or bDW or bOW or bDH2);
infamy_label.setVisible(bBC);
infamy.setVisible(bBC);

--Changes to fields
if bDH1 or bDH2 then
influence_label.setValue("INFLUENCE:");
elseif bRT then
influence_label.setValue("PROFIT FACTOR:");
elseif bDW then
influence_label.setValue("RENOWN:");
elseif bOW then
influence_label.setValue("LOGISTICS:");
end
end

Moon Wizard
August 4th, 2017, 07:32
If you want the player to be able to make changes on the PC sheet that stay with the PC sheet, then you should not use the options system, since the options system is for global settings. That's why the current user's option setting always controls the display.

Instead, you should create another button or field on the PC sheet which allows either the GM or player to toggle whether the extra fields will display. In that way, the data for whether the extra fields are displayed is stored with the PC.

This is similar to the way the Mode field on the PC sheet Actions tab is handled for 5E and 3.5E D&D. The mode is saved with the character data.

Regards,
JPG

Paul Pratt
August 4th, 2017, 16:32
OK, I can do that. Thank you.