Difference between revisions of "Talk:RegisterForModEvent - Form"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Darkconsole
(Created page with "== On Game Load Requirement == * ''"Registrations have to be refreshed after each game load."'' * ''"You must register for ModEvents after every game load!"'' My experience...")
 
imported>Darkitow
Line 9: Line 9:


--[[User:Darkconsole|Darkconsole]] ([[User talk:Darkconsole|talk]]) 2015-01-23T12:42:27 (EST)
--[[User:Darkconsole|Darkconsole]] ([[User talk:Darkconsole|talk]]) 2015-01-23T12:42:27 (EST)
== Dinamically creating ModEvents? ==
Since you gotta specify both the handle '''and''' the event name when you register a form for a modEvent, but you only need to specify the event name when you write its code, is it possible to trigger modEvents with the same name using different handles?
For example, let's say that I got a modEvent called "OnSomething" in two different actors:
<source lang=papyrus>
    event OnSomething()
        ;does things
    endEvent
</source>
then I use:
<source lang=papyrus>
    actor_1.registerForModEvent("something_1", "OnSomething")
    actor_2.registerForModEvent("something_2", "OnSomething")
</source>
So, when I call this:
<source lang=papyrus>
    int handle = ModEvent.Create("something_1")
    if (handle)
        ModEvent.Send(handle)
    endIf
</source>
I assume that only the first actor would get the modEvent, even though both have the same valid code. This means I can control whether they get the modEvent triggered, isn't it?

Revision as of 05:32, 17 April 2015

On Game Load Requirement

  • "Registrations have to be refreshed after each game load."
  • "You must register for ModEvents after every game load!"

My experience suggests that these statements are no longer true. Additionally, if you change a script after registering, the game will actually prefer the version already in the save over the hard copy.

  • warning: Function dcc_ut_QuestController..OnEncounterEnd in stack frame 0 in stack 629647 differs from the in-game resource files - using version from save

--Darkconsole (talk) 2015-01-23T12:42:27 (EST)

Dinamically creating ModEvents?

Since you gotta specify both the handle and the event name when you register a form for a modEvent, but you only need to specify the event name when you write its code, is it possible to trigger modEvents with the same name using different handles?

For example, let's say that I got a modEvent called "OnSomething" in two different actors:

    event OnSomething()
        ;does things
    endEvent

then I use:

    actor_1.registerForModEvent("something_1", "OnSomething")
    actor_2.registerForModEvent("something_2", "OnSomething")

So, when I call this:

    int handle = ModEvent.Create("something_1")
    if (handle)
        ModEvent.Send(handle)
    endIf

I assume that only the first actor would get the modEvent, even though both have the same valid code. This means I can control whether they get the modEvent triggered, isn't it?