Jump to content

What is the correct target? (_root , invoke , CustomUI)


thilasx

Recommended Posts

Hey All!

I'm currently developing my own CustomMenu. Right now i have problems with papyrus communicating with the actionscript.

Things working:
- Menu shows up in Skyrim if i activate something
- Menu has clickable buttons, wich send events to papyrus via skse and are able to call functions inside the as.
- Events sent by buttons get to papyrus - showing me a notification that the button was pressed.

Things not working:
- calling a function in the as via papyrus.

Normally this would be done by the function UI.InvokeInt( "Menuname" , "_root.something" + "nameoffunction" , number)

Refering to the Code of UIExtentions for the textentrymenu: UI.InvokeString("CustomMenu" , "_root.textEntry.setTextEntryMenuText , string))

For my menu it would be UI.InvokeInt("CustomMenu" , " _root.Cmenu.setCount" , number)

But the number isn't going to change in my menu..

Edit: I think that the text behind _root. has to be the name of Instance of the Movieclip. In my case i had not named the Instance of my Movieclip(named Cmenu) - So i gave the Instance the name cMenu but the Invokefunction UI.InvokeInt("CustomMenu" , "_root.cMenu.SetCount" , 12 ) keeps unfunctional(?).

I guess that the _root Path isn't right or has to be created before refering to it or something else in that way..


my fla.:

http://www.file-upload.net/download-11068416/Cmenu.fla.html
Here is my Code (i'm in a early trial and error-learningprocess for papyrus and as right now..)
as:

class CmenuWidget extends MovieClip
{    
  /* STAGE ELEMENTS */
    
    public var countText: TextField;
      public var countText2: TextField;

  /* INITIALIZATION */

    public function CmenuWidget()
    {
        super();
        
        _visible = true;
        countText.text = "0";
        countText2.text = "0";
        
        
    }

    public function onLoad()
    {
        setName("hier mokkt der text");
        skse.SendModEvent("test");
    }
  /* PUBLIC FUNCTIONS */

    // @Papyrus
    public function setVisible(a_visible: Boolean): Void
    {
        _visible = a_visible;
    }
    
    // @Papyrus
    public function setCount(a_count: Number): Void
    {
        countText.text = String(a_count);
    }
     public function setName(a_name: String): Void
    {

        countText.text = a_name;

    }  
}

The papyruscode:

ScriptName Cmenumanager extends Quest



float property UpdateTimer auto


Event OnInit()
    debug.notification("hello")
    RegisterForSingleUpdate(UpdateTimer)
    self.Registercmdmenu()
EndEvent

Event OnUpdate()
    RegisterForSingleUpdate(UpdateTimer)
EndEvent

Event OnCmenuAuf(string eventName, string strArg, float numArg, Form formArg)
    debug.notification("event bekommen")
EndEvent

Event OnCmenuRef(string eventName, string strArg, float numArg, Form formArg)
    debug.notification("auch daar")
    UI.SetString("CustomMenu",  "_root.Menu_mc.countText.text", "20")
    UI.SetString("CustomMenu",  "_root.Cmenu.countText.text", "20")
    UI.InvokeInt("CustomMenu",  "_root.Menu_mc.setCount", 20)
    UI.InvokeInt("CustomMenu",  "_root.Cmenu.setCount", 20)
    UI.SetString("CustomMenu",  "_root.Menu_mc.Cmenu.countText.text", "20")
    UI.InvokeInt("CustomMenu",  "_root.Menu_mc.Cmenu.setCount", 20)
    UI.SetString("CustomMenu",  "_root.Menu_mc.CmenuWidget.countText.text", "20")
    UI.InvokeInt("CustomMenu",  "_root.Menu_mc.CmenuWidget.setCount", 20)
    
EndEvent

function Registercmdmenu()
    RegisterForModEvent("CmenuRef", "OnCmenuRef")
    RegisterForModEvent("CmenuAuf", "OnCmenuAuf")
    self.RegisterForControl("Activate")
    
EndFunction

function OnControlDown(String act)
    
    UI.OpenCustomMenu("Cmenu")
    Utility.WaitMenuMode(5.0)
    UI.CloseCustomMenu()
    
    
EndFunction

I really hope that someone is able and willing to help me cause it seems that i'm stuck here >.<
Any help would be appreciated!
LG thilasx


Edit: cleaned some code

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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