Jump to content

HUD Framework - Send Message


Crosstieger

Recommended Posts

Guten Tag!

 

I'm currently creating my first hud widget. I created a new hud element using Adobe Animate. Basically I copied mostly Registrator's test hud.

 

Now, I can load the widget and have it displayed ingame but I cannot update for example the text. My textbox is called "cl_Head" and is set to a dynamic text.

 

This is my ActionScript

package  {
	
	import flash.display.MovieClip;
	import flash.text.TextField;
	
	import hudframework.IHUDWidget;
	
	/**
	* A sample HUD widget utilizing HUDFramework.
	* Counts the number of kills that the player has made.
	*/
	public class Main extends MovieClip implements IHUDWidget{
		// HUDFramework Config
		private static const WIDGET_IDENTIFIER:String = "wttf.swf";
		
		// Command IDs
		private static const Command_UpdatePerk:int = 100;
		
		// Hello World Textfield
		public var cl_Head:TextField;
		
		public function Main() {}
		
		public function processMessage(command:String, params:Array):void {
			switch(command) {
				case String(Command_UpdatePerk):
					cl_Head.text = String(int(params[0]));
					break;
			}
		}
	}
	
}

And this my papyrus script:

Scriptname AAA_WTFHudManager extends Quest

import AAA_WTFCoreScript

import mcm

import HUDFramework

String Property WTTF_Widget = "wttf.swf" AutoReadOnly

Group WidgetCommands
    int Property Command_UpdatePerk = 100 AutoReadOnly
EndGroup

HUDFramework hud

;===================
;= Magic Functions =
;===================

Function WTFInitHud()

	hud = HUDFramework.GetInstance()
	
	if (hud)
		Debug.Trace("WTTF - Loading HUD widget ...")
		hud.RegisterWidget(Self, WTTF_Widget, afX = 10.0, afY = 10.0, abLoadNow = True, abAutoLoad = True)
	Else		
		Debug.Messagebox("Workout Through The Fallout\n\n HUD Framework not detected! GetInstance returned 'none'")
	EndIf

EndFunction


; This function is called by HUDFramework when the widget is loaded.
Function HUD_WidgetLoaded(string asWidget)
	If (asWidget == WTTF_Widget)
		Debug.Trace("WTTF - Widget loaded")
		WTFUpdateHUD()
	EndIf
EndFunction


;Update the information on the widget
Function WTFUpdateHUD()
	hud = HUDFramework.GetInstance()
	debug.Trace("WTTF - Updating widget")
	hud.SendMessage(WTTF_Widget, Command_UpdatePerk, 2)
EndFunction


;================
;= Magic Events =
;================

Event OnInit()
	utility.wait(5)
	Debug.Trace("WTTF - HUD quest started")
	
	WTFInitHud()
	
EndEvent

There are no errors when compiling the papyrus script and no errors in the papyrus log files.

 

If you want you can take a look at it: https://gamemania.org/wp-content/uploads/2018/01/Source.zip

 

Link to comment
Share on other sites

WTFUpdateHUD is called:

 

Function HUD_WidgetLoaded(string asWidget)
If (asWidget == WTTF_Widget)
Debug.Trace("WTTF - Widget loaded")
WTFUpdateHUD()
EndIf
EndFunction

 

The function HUD_WidgetLoaded will be called by HUD Framework once the widget is loaded and ready to receive input.

 

However I found my issue. For some reason the Action Script wasn't truly connected to my flash file. When clicking on the pen icon inside Adobe Animate to open the class definition an empty ActionsScript would appear.

Edited by Crosstieger
Link to comment
Share on other sites

  • Recently Browsing   0 members

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