ModEvent Script: Difference between revisions
Jump to navigation
Jump to search
no edit summary
imported>CraftySentinel m (Missing Categories zzzz) |
imported>Egocarib No edit summary |
||
| Line 7: | Line 7: | ||
ScriptName ModEvent Hidden | ScriptName ModEvent Hidden | ||
</source> | </source> | ||
== SKSE Global Functions == | == SKSE Global Functions == | ||
| Line 34: | Line 33: | ||
:'''[[PushForm - ModEvent|PushForm]](Int ''handle'', Form ''value'')''' | :'''[[PushForm - ModEvent|PushForm]](Int ''handle'', Form ''value'')''' | ||
:*Pushes a Form param into the event. | :*Pushes a Form param into the event. | ||
== Example == | |||
Script that is sending the event: | |||
<source lang=papyrus> | |||
SomeFunction() | |||
int handle = ModEvent.Create("ModPrefix_myCustomEvent") | |||
if (handle) | |||
ModEvent.PushForm(handle, self) | |||
ModEvent.PushForm(handle, someOtherForm) | |||
ModEvent.PushInt(handle, 1000) | |||
ModEvent.PushString(handle, "It worked!") | |||
UIDelegate.Send(handle) | |||
endIf | |||
EndFunction | |||
</source> | |||
Script that wishes to receive the event: | |||
<source lang=papyrus> | |||
Function OnInit() | |||
RegisterForModEvent("ModPrefix_myCustomEvent", "OnMyCustomEvent") | |||
EndFunction | |||
;note that the parameters of this event must match the number & order of parameters as they were pushed in the sending script. | |||
Event OnMyCustomEvent(Form sender, Form theForm, int theInt, string theString) | |||
if (sender as Actor) | |||
debug.trace("Our event was received from a script attached to an Actor!") | |||
endif | |||
int goldVal = someOtherForm.GetGoldValue() | |||
debug.trace("The other form recieved by our event has a gold value of " + goldVal) | |||
debug.trace("We recieved theInt, and it equals " + theInt) | |||
debug.trace(theString) ;prints "It worked!" | |||
EndEvent | |||
</source> | |||