Difference between revisions of "WD2 ScriptHook: Events"

From Nomad DB
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[WD2ScriptHook: Script|Scripts]] can listen to Events. You should be familiar with the concept of [[WD2 ScriptHook: Script Table|Script Tables]] in order to follow this guide.
+
[[WD2 ScriptHook: Script|Scripts]] can listen to Events. You should be familiar with the concept of [[WD2 ScriptHook: Script Table|Script Tables]] in order to follow this guide.
  
== ScriptHook Events ==
+
*[[WD2 ScriptHook: Events|ScriptHook Events]]
ScriptHook provides a couple of Events that can be used within Scripts. These event listeners are functions in the [[WD2 ScriptHook: Script Table|Script Table]]. The most important ones are the ''OnLoad'' and ''OnUnload'' events.
+
*[[WD2 Lua Events|Game Events]]
 +
 
 +
==ScriptHook Events==
 +
ScriptHook provides a couple of Events that can be used within Scripts. These event listeners are functions in the [[WD2 ScriptHook: Script Table|Script Table]]. The most important ones are the ''[[Event: Script:OnLoad|OnLoad]]'' and ''[[Event: Script:OnUnload|OnUnload]]'' events. For rendering onto the Screen, [[Event: Script:OnRender|OnRender]] can be used.
  
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
Line 12: Line 15:
 
function script:OnUnload()
 
function script:OnUnload()
 
print("OnUnload")
 
print("OnUnload")
 +
end
 +
 +
function script:OnRender()
 +
    print("OnRender")
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
== Game Events ==
+
=== Game Events ===
To-Do
+
 
 +
*[[Event: Script:OnUpdate|OnUpdate]]
 +
 
 +
==Related Pages==
  
== Related Pages ==
+
*[[WD2 ScriptHook: Script Table]]
* [[WD2 ScriptHook: Script Table]]
+
*[[WD2 ScriptHook: Rendering]]
  
 
[[Category:WD2 ScriptHook]]
 
[[Category:WD2 ScriptHook]]

Revision as of 21:23, 2 August 2020

Scripts can listen to Events. You should be familiar with the concept of Script Tables in order to follow this guide.

ScriptHook Events

ScriptHook provides a couple of Events that can be used within Scripts. These event listeners are functions in the Script Table. The most important ones are the OnLoad and OnUnload events. For rendering onto the Screen, OnRender can be used.

local script = Script()
function script:OnLoad()
	print("OnLoad")
end

function script:OnUnload()
	print("OnUnload")
end

function script:OnRender()
    print("OnRender")
end

Game Events

Related Pages