The Driver Syndicate/Addon System: Difference between revisions

From Equilibrium Engine Wiki
Jump to navigation Jump to search
(The start of the making a Addon's page.)
 
Line 1: Line 1:
To create a Addon first you must set up the file directory and the Modinit lua script.  
The Driver Syndicate allows you to create the separate layer of code and data that is best described as '''addon'''.  


== Addons Directory ==
It allows creators to expand the basic features. For example, it allows:


Depending on the needs of the mod you want to develop, the following directories can be used.
# Adding new levels and missions
# Extend game with new game modes, sounds and vehicles
# Apply modifiers to the game's behaviour
# Override base game resources such as HUD, main menu styles


'''Addons/YourCoolMod/''' - YourCoolMod (example name) is the starting folder, inside of this will be the following folder directories and the Modinit.lua script.  
== Overview ==
[[File:AddonSystem.png|thumb|340x340px|Brief look at how addons are layering on base game]]
The first important feature of '''Addon system''' is to introduce layers to the '''filesystem''' of the game and then it is further supported by the '''Lua scripting features''' of the game.


'''editor_prefabs folder''' for prefabs used in your cities. See the wiki page on level editor prefabs for more information on this.  
Game's '''Filesystem''' is a crucial part that allows to add and even override the files of the base game. Although overriding files ''is not recommended'' at most times, it still can have benefit of extending the game functionality.


'''levels folder''' - stores your level.lev files and <levelname>_editor folders.
When Addon is enabled, it's files becoming visible to the game and it's not possible to use them as if they would be in the '''GameData''' folder.


'''materials folder''' - in this directory you will store textures and materials.
== Addon directory ==


'''materialsSRC folder''' - the future of DrvSyn modding. For now it's used to generate levelmaps.  
Now that you have an idea how addons work and [[The Driver Syndicate/Addon System/Installing Addons|already installed a few ones]], let's make our own addon.  


'''models folder''' - in this directory you will store dynamic objects and scriptable objects.  
# You need to create the folder for your addon, just name it anything you want.
# Create '''ModInit.lua''' - a special file that will let game know that this folder contains addon data. You will need to put it inside your Addon folder.


''<small>Note: Typically level makers do not pack in static level models with their cities. However, .egf models are required pack-ins due to scripting and object definitions.</small>''


'''replayData folder''' - here you store replays for cutscenes, pursuit chases and more!
Example of '''ModInit.lua'''<syntaxhighlight lang="lua" line="1">
local ModInit = {
Title = "Your crazy mod name here",


'''resources folder''' - for level resources, HUD elements, and loading screens. Files in this directory are saved in .res format. 
CreatedBy = "Mod Author Name",
Version = "1.0",
}


'''scripts folder''' - this directory is for many types of scripts. Menus, Environment, Music, Missions, Game Modes, Level Events, and more! Lots of possibilities!
-- initialization function
function ModInit:Init()
    -- initialize your code stuff here
end,


'''sounds folder''' - this directory is for storing sounds. See the wiki page that deals with the game's sound system.  
-- deinitialization function
function ModInit:DeInit()
-- de-initialize your code stuff here
end
</syntaxhighlight>In this example '''Title''' is the name of your addon that will be visible in '''Settings - Addons''' menu.  


== Modinit.lua ==
And that's it, you now have your addon created.  


TODO: Add good Modinit example.
=== What's next? ===
[[File:ComCarsExample.png|thumb|CommunityCars addon folder]]
As we already know, addon folder is a layer over GameData. So you can create folders depending on your modding needs, just like in the GameData.
 
In the example screenshot seen here, there is a CommunityCars addon and it extends few GameData folders like '''materials''', '''models''' and '''scripts'''.
 
Other examples of Addons might include folders like '''levels''', '''replayData''', '''resources''', '''scripts''' and '''sounds''' folders.
{| class="wikitable"
|'''editor_prefabs'''
|Used forr prefabs used in your cities. See the [[The Driver Syndicate/Level Editor/Prefabs|level editor prefabs]] for more information.
|-
|'''levels'''
|Stores your level.lev files and <levelname>_editor folders.
|-
|'''materials'''
|Stores your textures and materials.
|-
|'''materialsSRC'''
|'''(Should be not shipped)''' Stores source TGA textures and material files used to generate shipping DDS and MAT files
|-
|'''models'''
|Stores your EGF models for game objects and vehicles
|-
|'''replayData'''
|Store replays for cutscenes, pursuit chases and more
|-
|'''resources'''
|Stores localization texts, UI schemes such as menus, HUD, loading screens
|-
|'''scripts'''
|Stores many types of scripts. Vehicle scripts, environment properties, sound scripts and Lua scripts for menus, world missions and game modes.
|-
|'''sounds'''
|Stores all WAV and OGG files.
|}
 
== Further work with your addon ==
Some of the game tools like '''EGFMan''' and '''Level Editor''' can be used work within your Addon scope.
 
You can put two separate BAT files in your addon folder with those contents to run<syntaxhighlight lang="bat" line="1">
cd ..\..\Bin64\
start egfman -devAddon "Addons/YourAddonFolderName"
</syntaxhighlight>For Level Editor it will be the same<syntaxhighlight lang="bat" line="1">
cd ..\..\Bin64\
start LevelEditor -devAddon "Addons/YourAddonFolderName"
</syntaxhighlight>
 
== See also ==
[[The Driver Syndicate/Scripting/Lua Reference#ModInit|Lua Reference - ModInit]]

Revision as of 15:17, 2 February 2023

The Driver Syndicate allows you to create the separate layer of code and data that is best described as addon.

It allows creators to expand the basic features. For example, it allows:

  1. Adding new levels and missions
  2. Extend game with new game modes, sounds and vehicles
  3. Apply modifiers to the game's behaviour
  4. Override base game resources such as HUD, main menu styles

Overview

Brief look at how addons are layering on base game

The first important feature of Addon system is to introduce layers to the filesystem of the game and then it is further supported by the Lua scripting features of the game.

Game's Filesystem is a crucial part that allows to add and even override the files of the base game. Although overriding files is not recommended at most times, it still can have benefit of extending the game functionality.

When Addon is enabled, it's files becoming visible to the game and it's not possible to use them as if they would be in the GameData folder.

Addon directory

Now that you have an idea how addons work and already installed a few ones, let's make our own addon.

  1. You need to create the folder for your addon, just name it anything you want.
  2. Create ModInit.lua - a special file that will let game know that this folder contains addon data. You will need to put it inside your Addon folder.


Example of ModInit.lua

local ModInit = {
	Title = "Your crazy mod name here",

	CreatedBy = "Mod Author Name",
	Version = "1.0",
}

-- initialization function
function ModInit:Init()
    -- initialize your code stuff here
end,

-- deinitialization function
function ModInit:DeInit()
	-- de-initialize your code stuff here
end

In this example Title is the name of your addon that will be visible in Settings - Addons menu.

And that's it, you now have your addon created.

What's next?

CommunityCars addon folder

As we already know, addon folder is a layer over GameData. So you can create folders depending on your modding needs, just like in the GameData.

In the example screenshot seen here, there is a CommunityCars addon and it extends few GameData folders like materials, models and scripts.

Other examples of Addons might include folders like levels, replayData, resources, scripts and sounds folders.

editor_prefabs Used forr prefabs used in your cities. See the level editor prefabs for more information.
levels Stores your level.lev files and <levelname>_editor folders.
materials Stores your textures and materials.
materialsSRC (Should be not shipped) Stores source TGA textures and material files used to generate shipping DDS and MAT files
models Stores your EGF models for game objects and vehicles
replayData Store replays for cutscenes, pursuit chases and more
resources Stores localization texts, UI schemes such as menus, HUD, loading screens
scripts Stores many types of scripts. Vehicle scripts, environment properties, sound scripts and Lua scripts for menus, world missions and game modes.
sounds Stores all WAV and OGG files.

Further work with your addon

Some of the game tools like EGFMan and Level Editor can be used work within your Addon scope.

You can put two separate BAT files in your addon folder with those contents to run

cd ..\..\Bin64\
start egfman -devAddon "Addons/YourAddonFolderName"

For Level Editor it will be the same

cd ..\..\Bin64\
start LevelEditor -devAddon "Addons/YourAddonFolderName"

See also

Lua Reference - ModInit