Jump to content

Easy Question: Calling RefCollectionAlias script function from MCM button


Recommended Posts

I have a RefCollectionAlias that is a Quest Alias of a Quest that has a script function I want to call from a MCM menu button. I am sure this is easy, but there is some small Michael Bolton detail that is hanging me up. "01001732" is the Form ID of the Quest.

 

Here is the function:

ScriptName louisthird_SecretFormula_Script extends RefCollectionAlias

Quest Property louisthird_SecretFormula_Quest Auto Const


...... lots more script code ......


Function CheckRunning()
  If louisthird_SecretFormula_Quest.IsRunning()
    Debug.Notification("Secret Formula is running")
  Else
    Debug.Notification("Secret Formula is not running")
  EndIf
EndFunction

Here is the MCM JSON snippet:

 

      {
         "pageDisplayName":"Debug",
         "content":[
            {
               "text": "<p align='center'><b><font size='24'>louisthird's Secret Formula <font size='10'>(v1.0.0)</font></font></b></p>",
               "html": true,
               "type": "text"
            },
            {
               "text": "Debug",
               "type": "section"
            },
            {
               "text": "Mod Running Check",
               "type": "button",
               "help": "Checks if the mod is currently running",
               "action": {
                  "type": "CallFunction",
                  "form": "louisthird_SecretFormula.esp|01001732",
                  "script": "louisthird_SecretFormula_Script",
                  "function": "CheckRunning"
               }
            }
         ]
      }

What did I miss?

 

Link to comment
Share on other sites

I don't know MCM but trying to call alias scripts remotely via GerFormFromFile is a nightmare so I cheat and create a local quest script function that calls the alias script function.


Recent example source quest/alias/script:





Scriptname SKK_UCFQuestScript extends Quest Conditional

Quest Property pSKK_UCFQuest Auto Const Mandatory
RefCollectionAlias Property Alias_NeedStimpak Auto Const Mandatory

Function ApplyStimpak(ObjectReference ThisREF)
(Alias_NeedStimpak as SKK_UCFNeedStimpakAliasScript).ApplyStimpak(TargetREF = ThisREF, SourceREF = pPlayerREF)
EndFunction


Remote calling script



Scriptname SKK_AnotherModScript extends Quest

Function CallRemoteStimpakScript(ObjectReference ThisREF)
Quest rSKK_UCFQuest = Game.GetFormFromFile(0x0002058e, "SKKUnlimitedCombatFollowers.esp") as Quest
Var[] vParams = new Var[1]
Params[0] = ThisREF as ObjectReference
(rSKK_UCFQuest as SKK_UCFQuestScript).CallFunction("ApplyStimpak", vParams)
EndFunction


Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...