JackRob Posted November 9, 2018 Share Posted November 9, 2018 I'm trying to develop a system where I can sync actor values with global values so perk effects can be modified very fluidly (since perk formulas can utilize actor values, whereas if I want to use Global values, I'd need to attach a condition to check that global value and make a perk entry for each global value possibility, which can be numerous depending on range of input values). This system is to be used in conjunction with MCM, which will modify the global value. My initial lead was to use MCM's custom event "OnMCMSettingChange", but this seems like a dead end as if this can help me, I can't figure out how to utilize it correctly. In this instance, I was hoping to avoid simply using OnTimer to constantly check whether the values matched, even though this would be simpler. My current attempt script, I'm sure I did something wrong here. A lot of it was piggy-backed from example script here: GitHub: MCM wiki Scriptname JacksScripts:JFORMCMScript extends Quest Actor Property PlayerRef auto GlobalVariable Property GVFoodHealMultDur auto ActorValue Property AVFoodHealMultDur auto Event OnQuestInit() RegisterForRemoteEvent(PlayerRef, "OnPlayerLoadGame") RegisterCustomEvents() Debug.Notification("JFOR MCM Quest Script Initiated") EndEvent Event Actor.OnPlayerLoadGame(Actor akSender) RegisterCustomEvents() Debug.Notification("JFOR MCM Script: Player Loaded") EndEvent Function RegisterCustomEvents() RegisterForExternalEvent("OnMCMSettingChange|JFO_Rebuild", "OnMCMSettingChange") Debug.Notification("Registered JFOR for OnMCMSettingChange") EndFunction Event OnMCMSettingChange(string modName, string id) Debug.Notification("JFOR's MCMSettingChange activated!") If PlayerRef.GetValue(AVFoodHealMultDur) != GVFoodHealMultDur.GetValue() PlayerRef.SetValue(AVFoodHealMultDur, GVFoodHealMultDur.GetValue()) Debug.Notification("Values did not match and were adjusted...") EndIf EndEvent Compile error states: "new event onmcmsettingchange cannot be defined because the script is not flagged as native" So the main question is: Can I use "OnMCMSettingChange" to catch when a global value gets change by MCM, then modify actor values accordingly, or is this not possible and I should rely on "OnTimer" to constantly check for changes to global value? Any help is appreciated. Link to comment Share on other sites More sharing options...
DieFeM Posted November 10, 2018 Share Posted November 10, 2018 (edited) I look at the source code of the F4SE's papyrus scripts, looking for some comments about RegisterForExternalEvent because there's nothing in creationkit.com, and found out this: ; Callback is the function name that is called when the event is triggered Function RegisterForExternalEvent(string eventName, string callback) nativeThen I searched on google for OnMCMSettingChange, and I landed on this page: https://github.com/Neanka/MCM_0.1_AS3/wiki/Advanced-Papyrus-IntegrationIt seems you should define a function as callback instead of an event: Function OnMCMSettingChange(string modName, string id) If (modName == "MCM_Demo") ; if you registered with OnMCMSettingChange|MCM_Demo this should always be true If (id == "control_id") Debug.Notification("control_id value was changed!") EndIf EndIf EndFunction Edited November 10, 2018 by DieFeM Link to comment Share on other sites More sharing options...
Recommended Posts