Jump to content

Recommended Posts

I have run into issues with custom events.
I have the scripts 'talking' to each other via function calls that call the scripts by name. e.g.

quest script "FH_LifeScript01"

FH_LifeScript01 Function GetScript() Global
Return Game.GetFormFromFile(0x00008F0F, "FH03.esp") as FH_LifeScript01
EndFunction
Function testNPCScript(ObjectReference theNPC)
  FH_ActorLive01 targetScript = theNPC as FH_ActorLive01
   if targetScript != None
int test=targetScript.sendReply(1)
Debug.notification("script found. Recieved "+test)
endIf
endFunction

In actor

FH_LifeScript01 Property Scripts Auto Conditional Hidden

which can be used in a function like this

Function someFunction()
bool isDone=Scripts:CallQuestFunction(self)
return isDone
endFunction

Which all works nicely. So I can call the functions of the quest script in the actor script via the 'FH_LifeScript01 Scripts' property and functions in the Actor script via specific functions as demonstrated above.

Though when trying to add a function in the actor script to receive a custom event I run into issues.

 

In the quest script called "FH_LifeScript01"
CustomEvent LifeCall


event onInit()
  ; Send the LifeCall event with two arguments
  Var[] kargs = new Var[2]
  kargs[0] =self
  kargs[1] = true
  SendCustomEvent("LifeCall", kargs)
endEvent
In the Actor script
FH_LifeScript01 Property Scripts Auto Conditional Hidden
Event onInit()
RegisterForCustomEvent(Scripts , "LifeCall")
endEvent


;Event FH_LifeScript01.Lifecall(FH_LifeScript01 akSender, Var[] akArgs)
  ;Debug.Trace("We received the LifeCall event from " + akSender + " with arguments " + akArgs)
;EndEvent

The commented out section is the attempt to receive the event though the editor tells me that "FH_LifeScript01 is not a known script type" and so therefore cannot register an event.

 

Anyone have any clues what I am doing wrong?

Edited by Firehawk777
Link to comment
Share on other sites

Thanks though it was set. The issue I had was that my scripts are Conditional and custom events require native scripts apparently. So my work around was to create two scripts, one for the actor and one for the quest that are set to native. Then I simply join the native and the conditional scripts via the function call. So basically it goes like this. Conditional lfequestscript calls native lifequestscript to send event. Which is received by the native actor script then sent to the conditional actor script. Lol. Which all sounds much harder than it actually is.

It had me stumped for a few hours though the info is in the script reference guide. Just like many things it is very poorly explained.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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