Varsuuk
March 17th, 2019, 20:46
*** SOLVED ***
I was tracing the Options behavior so I added code to char_main to call my handler then register that handler for future changes.
When I open the sheet it prints the current option value.
When I open options and cycle to next option (there are 2 only) it runs my callback with the "old" then the "new" value.
Is it supposed to call with existing value on "onSet" and then once set on "onChanged" (paraphrasing)
Not sure using it correctly.
Console output:
Runtime Notice: Host session started
Runtime Notice: s'mgr.abil: onInit'
Runtime Notice: s'>onHRSavingThrowMethodChanged'
Runtime Notice: s'categories'
Runtime Notice: s'<onHRSavingThrowMethodChanged'
Runtime Notice: s'template_common_sw.xml' | s'linkfield->onInit()' | s'isEmpty()' | bTRUE
Runtime Notice: s'template_common_sw.xml' | s'linkfield->onValueChanged()' | s'isEmpty()' | bTRUE
>>> I click on button to change from displayed Categories to SingleValue
Runtime Notice: s'>onHRSavingThrowMethodChanged'
Runtime Notice: s'categories'
Runtime Notice: s'<onHRSavingThrowMethodChanged'
Runtime Notice: s'>onHRSavingThrowMethodChanged'
Runtime Notice: s'default'
Runtime Notice: s'<onHRSavingThrowMethodChanged'
>>> I click on button to change from displayed SingleValue to Categories
Runtime Notice: s'>onHRSavingThrowMethodChanged'
Runtime Notice: s'default'
Runtime Notice: s'<onHRSavingThrowMethodChanged'
Runtime Notice: s'>onHRSavingThrowMethodChanged'
Runtime Notice: s'categories'
Runtime Notice: s'<onHRSavingThrowMethodChanged'
...
function onInit()
if User.isHost() then
-- Add right-click menu options for DM to give an individual character a long or short rest.
registerMenuItem(Interface.getString("menu_rest"), "lockvisibilityon", MENU_REST_POS);
registerMenuItem(Interface.getString("message_restovernight"), "pointer_cone", MENU_REST_POS, MENU_REST_OVERNIGHT_POS);
registerMenuItem(Interface.getString("message_restfull"), "pointer_circle", MENU_REST_POS, MENU_REST_FULL_POS);
end
if User.isLocal() then
portrait.setVisible(false);
localportrait.setVisible(true);
end
OptionsManager.registerCallback("HouseRule_SavingThrowMethod", onHRSavingThrowMethodChanged);
onHRSavingThrowMethodChanged(); -- TODO put with other loading methods once work on that
end
function onClose()
OptionsManager.unregisterCallback("HouseRule_SavingThrowMethod", onHRSavingThrowMethodChanged);
end
function onHRSavingThrowMethodChanged()
Debug.console(">onHRSavingThrowMethodChanged");
local sOptHRSaves = OptionsManager.getOption("HouseRule_SavingThrowMethod");
Debug.console(sOptHRSaves);
Debug.console("<onHRSavingThrowMethodChanged");
-- TODO ---> Add real work for the handler
end
I was tracing the Options behavior so I added code to char_main to call my handler then register that handler for future changes.
When I open the sheet it prints the current option value.
When I open options and cycle to next option (there are 2 only) it runs my callback with the "old" then the "new" value.
Is it supposed to call with existing value on "onSet" and then once set on "onChanged" (paraphrasing)
Not sure using it correctly.
Console output:
Runtime Notice: Host session started
Runtime Notice: s'mgr.abil: onInit'
Runtime Notice: s'>onHRSavingThrowMethodChanged'
Runtime Notice: s'categories'
Runtime Notice: s'<onHRSavingThrowMethodChanged'
Runtime Notice: s'template_common_sw.xml' | s'linkfield->onInit()' | s'isEmpty()' | bTRUE
Runtime Notice: s'template_common_sw.xml' | s'linkfield->onValueChanged()' | s'isEmpty()' | bTRUE
>>> I click on button to change from displayed Categories to SingleValue
Runtime Notice: s'>onHRSavingThrowMethodChanged'
Runtime Notice: s'categories'
Runtime Notice: s'<onHRSavingThrowMethodChanged'
Runtime Notice: s'>onHRSavingThrowMethodChanged'
Runtime Notice: s'default'
Runtime Notice: s'<onHRSavingThrowMethodChanged'
>>> I click on button to change from displayed SingleValue to Categories
Runtime Notice: s'>onHRSavingThrowMethodChanged'
Runtime Notice: s'default'
Runtime Notice: s'<onHRSavingThrowMethodChanged'
Runtime Notice: s'>onHRSavingThrowMethodChanged'
Runtime Notice: s'categories'
Runtime Notice: s'<onHRSavingThrowMethodChanged'
...
function onInit()
if User.isHost() then
-- Add right-click menu options for DM to give an individual character a long or short rest.
registerMenuItem(Interface.getString("menu_rest"), "lockvisibilityon", MENU_REST_POS);
registerMenuItem(Interface.getString("message_restovernight"), "pointer_cone", MENU_REST_POS, MENU_REST_OVERNIGHT_POS);
registerMenuItem(Interface.getString("message_restfull"), "pointer_circle", MENU_REST_POS, MENU_REST_FULL_POS);
end
if User.isLocal() then
portrait.setVisible(false);
localportrait.setVisible(true);
end
OptionsManager.registerCallback("HouseRule_SavingThrowMethod", onHRSavingThrowMethodChanged);
onHRSavingThrowMethodChanged(); -- TODO put with other loading methods once work on that
end
function onClose()
OptionsManager.unregisterCallback("HouseRule_SavingThrowMethod", onHRSavingThrowMethodChanged);
end
function onHRSavingThrowMethodChanged()
Debug.console(">onHRSavingThrowMethodChanged");
local sOptHRSaves = OptionsManager.getOption("HouseRule_SavingThrowMethod");
Debug.console(sOptHRSaves);
Debug.console("<onHRSavingThrowMethodChanged");
-- TODO ---> Add real work for the handler
end