Jump to content

SendModEvent with actor information?


Fredas

Recommended Posts

Topic.  Really dumb newbie question with a simple answer that I nonetheless can't pull out of a hat.  I want to send actor information along with a mod event.  Perhaps doing so involves converting the actor into some other type of variable and back.  I can't claim to be able to make a good guess at it.  Example lines of code would be the most help.

 

Thanks in advance!

 

Link to comment
Guest carywinton

Variables are typically used to set a numeric value or check for a numeric value on an NPC or Player, they are used to either look for an item that exists or to give an item that does not exists. They can also be used for conversation trees (dialog) to check if a line has been spoken or responded to. These are just a few examples of variables, of course, but the most common. You state you want to send the current state of an actor with an event of some kind. This would require a script to check for the actors current state , using a variable, then send this along with event or trigger.

Perhaps a brief example of the situation you are desiring to use this for would be helpful.

Link to comment

What actor info did you want to send?

 

SendModEvent(eventName = "MyEvent", strArg = akActor.GetName(), numArg = akActor.GetAvPercentage("Magicka"))

 

There's also the sender form that you get on the receiving end, but haven't needed it so I don't know what you actually receive. If you use SendModEvent from an alias script it might be the alias or actor making things easier as you could just cast it back to actor (or alias). Other than that if you need to send more data, probably better that you just use something to ID the actor on the event, like name for the string argument and then fetch the actor from somewhere.

Link to comment

Yeah I wasn't being specific enough.  In a nutshell, at the other end of the event, in the other script, I need whatever qualifies as the "actor" variable type in the capacity required by the Play function (play sound) so I can play a sound from the correct actor.  I am thinking GetFormID as float might do the trick for the numArg.

 

Bizarrely, the trouble I'm having now is figuring out where the mod I'm working on (not mine) references its main script, so I can start editing it and seeing if anything works.  (Puppet Master is the mod in question.)  Between TES5Edit and CK, I'm just not finding it, despite knowing the filename.

 

Link to comment

Yeah I wasn't being specific enough.  In a nutshell, at the other end of the event, in the other script, I need whatever qualifies as the "actor" variable type in the capacity required by the Play function (play sound) so I can play a sound from the correct actor.  I am thinking GetFormID as float might do the trick for the numArg.

 

Bizarrely, the trouble I'm having now is figuring out where the mod I'm working on (not mine) references its main script, so I can start editing it and seeing if anything works.  (Puppet Master is the mod in question.)  Between TES5Edit and CK, I'm just not finding it, despite knowing the filename.

 

If I understand correctly your just trying to play a sound from a specific actor. If the actor is set up in an alias you can use this "Yoursound.Play(MyAlias.GetRef()) " it works for me in getting the golddown sound from another actor already set up in an alias.

Link to comment

Hmm.  Still struggling with this one.  SendModEvent lets me send a string or a float.  With that, I can send an actor's name or "actor as float".  But what I need at the other end, where the mod event gets picked up, is the variable type "actor" which would work with Play.  So whatever I can send through SendModEvent and then successfully convert back to the variable that Play wants, that's what I need.

 

Link to comment

I got a small lead on this.  It was suggested I look into the ModEvent function that's part of SKSE.  But that hint didn't take me very far, as I need to send an actor variable, and ModEvent only seems to enable bool, int, float, string and form.

 

Link to comment

More tinkering and Googling eventually led me to replace SendModEvent with ModEvent.  Unfortunately, while everything compiles happily, either no event is being sent or it's not being captured.  I can't be sure this is not attributable to the badly-documented nature of ModEvent.  Here are the relevant bits which ultimately do not produce a result:

; Script1
int handle = ModEvent.Create("Def_event") 
ModEvent.PushForm(handle, akActor as Form) 
ModEvent.Send(handle)
 
-----
 
; Script2
Event OnInit
   RegisterForModEvent("Def_event", "DefEvent")
endEvent
 
Event DefEvent(Form akActorForm)
   actor akActor = akActorForm as Actor
   Debug.Notification("Event captured.")
endEvent

If anyone wants to take a crack at what I'm doing wrong, feel free.  Pretty much nothing left for me to try at this point except wait. ;p  (For what it's worth, SendModEvent was working fine in the above example, but of course is not capable of forwarding an actor or anything similarly useful.)

 

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use