Difference between revisions of "ScriptHook: Script"

From Nomad DB
 
(14 intermediate revisions by 3 users not shown)
Line 1: Line 1:
A Script is a collection of Lua scripts that are loaded by [[WD2 ScriptHook]]. Scripts are loaded upon starting the game with ScriptHook installed.
+
A Script is a collection of Lua scripts that are loaded by ScriptHook. Scripts are loaded upon starting the game with ScriptHook installed. This guide will give you an overview of the structure behind those Scripts.
  
'''This guide will give you an overview of the structure behind those Scripts.'''
+
If you have used WD2 or MDE ScriptHook, check out the list of '''[[WDL Scripting Changes|notable ScriptHook changes for Legion]]'''.
  
== Guides ==
+
==Guides==
* [[WD2 ScriptHook: Key Binds]]
 
* [[WD2 ScriptHook: Console Commands]]
 
* [[WD2 ScriptHook: Script Table]]
 
  
== Directory Structure ==
+
*[[ScriptHook: Key Binds]]
 +
*[[ScriptHook: Console Commands]]
 +
*[[ScriptHook: Script Table]]
 +
*[[ScriptHook: UI]]
 +
*[[ScriptHook: Rendering]]
 +
*[[ScriptHook: Events]]
 +
 
 +
==Directory Structure==
 
<pre>
 
<pre>
 
data/scripts
 
data/scripts
Line 16: Line 20:
 
</pre>
 
</pre>
  
=== manifest.json ===
+
===manifest.json===
The manifest holds information about a Script. Name, Author & Version can be specified here. The "entrypoint" is the Lua script that is loaded.
+
The manifest holds information about a Script. Name, Author & Version can be specified here. The "entrypoint" is the Lua script that is loaded. The example below shows the ''manifest.json'' for the [[WD2 ScriptHook: Trainer|ScriptHook Trainer]].
  
 
<syntaxhighlight lang="json">
 
<syntaxhighlight lang="json">
Line 32: Line 36:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
== Concepts ==
+
==Concepts==
=== Script Table ===
+
===Script Table===
Within Scripts, you can call the function ''[[WD2 ScriptHook: Script Table|Script()]]''. It returns a Lua table that can be used for two things:
+
or more information, check out
# Storing variables for the Script
+
* [[WDL ScriptHook: Script Table|WDL Script Table]]
# Callback / Event Handlers
+
* [[WD2 ScriptHook: Script Table|WD2 Script Table]]
Using the Event Handlers is also the only way to properly unregister event listeners from the Game's event system.
+
* [[MDE ScriptHook: Script Table|MDE Script Table]]
 +
 
 +
===Key Bindings===
 +
You can bind Keys to Lua functions. Key Bindings are configured within the ''manifest.json'' section.
 +
 
 +
'''Check out [[ScriptHook: Key Binds]].'''
 +
 
 +
===Console Commands===
 +
Scripts can register custom Console Commands. These commands are registered directly within Lua.
  
=== Key Bindings ===
+
'''Read more about [[ScriptHook: Console Commands]].'''
You can bind Keys to Lua functions. Key Bindings are configured within the ''manifest.json'' section. For more information, check out [[WD2 ScriptHook: Key Binds]].
 
  
=== Console Commands ===
+
===ScriptHook Lua Functions===
Scripts can register custom Console Commands. These commands are registered directly within Lua. Check out [[WD2 ScriptHook: Console Commands]].
+
In addition to the built-in Lua functions, ScriptHook registers custom Lua functions that you can use. Those functions are used for Menus, Console Commands, and some alter the Game's world.
  
 +
[[Category:ScriptHook]]
 
[[Category:WD2 ScriptHook]]
 
[[Category:WD2 ScriptHook]]
 +
[[Category:MDE ScriptHook]]

Latest revision as of 08:44, 5 May 2021

A Script is a collection of Lua scripts that are loaded by ScriptHook. Scripts are loaded upon starting the game with ScriptHook installed. This guide will give you an overview of the structure behind those Scripts.

If you have used WD2 or MDE ScriptHook, check out the list of notable ScriptHook changes for Legion.

Guides

Directory Structure

data/scripts
data/scripts/[name]
data/scripts/[name]/manifest.json
data/scripts/[name]/[...].lua

manifest.json

The manifest holds information about a Script. Name, Author & Version can be specified here. The "entrypoint" is the Lua script that is loaded. The example below shows the manifest.json for the ScriptHook Trainer.

{
	"name": "Simple Trainer",
	"author": "Nomad Group",
	"version": "1.0",
	
	"entrypoint": "main.lua",
	"keyBinds": {
		"menu": "F4"
	}
}

Concepts

Script Table

or more information, check out

Key Bindings

You can bind Keys to Lua functions. Key Bindings are configured within the manifest.json section.

Check out ScriptHook: Key Binds.

Console Commands

Scripts can register custom Console Commands. These commands are registered directly within Lua.

Read more about ScriptHook: Console Commands.

ScriptHook Lua Functions

In addition to the built-in Lua functions, ScriptHook registers custom Lua functions that you can use. Those functions are used for Menus, Console Commands, and some alter the Game's world.