Creating a mod for the game Avorion that allows fighters to be instantly transported back to the hangar when they are returning home, given a transport subsystem is installed, involves several steps. This modding project will require some knowledge of Lua, as Avorion scripting is primarily done in this language. Here’s a basic outline on how you can approach this:
-
Set Up Your Environment:
- Ensure you have a proper text editor or IDE for scripting (like Visual Studio Code, Notepad++, etc.).
- Have a working installation of Avorion and ensure you can access its modding tools and directories.
-
Locate the Relevant Files:
- Avorion stores its scripts in the
data directory of the game files. Most relevant files for ships and fighters are found under scripts and data/scripts.
-
Create Your Mod Directory:
- Create a new directory in the
Avorion/mods folder for your transport subsystem mod. For example, Avorion/mods/InstantTransport.
-
Modify or Extend Script Functionality:
- You need to hook into the fighter management scripts to check if the transport subsystem is installed and then enable instant transportation if it is. This usually means modifying the server-side scripts that manage fighter behavior.
Here is a step-by-step approach:
Step 1: Create the Transport Subsystem
Create a new subsystem item or modify an existing one that will have the transport capability.
Example: data/scripts/systems/transporter.lua
package.path = package.path .. ";data/scripts/lib/?.lua"
local SystemUpgrade = include("systemupgrade")
function create(id, seed, rarity, permanent)
local upgrade = SystemUpgrade(id, seed, rarity, permanent)
upgrade.name = "Transport Module"%_t
upgrade.icon = "data/textures/icons/transporter.png"
upgrade.category = Category.Utility
upgrade.blockPenetration = 0.05
upgrade.finalizeUpgrade()
return upgrade
end
Step 2: Hook Into Fighter Management
Find the script that is responsible for managing fighters returning home. This is typically found in the ship scripts.
Example: data/scripts/entity/ai/fightercontroller.lua
Modify the fighter returning logic to check for the transport subsystem:
function FighterController:onFighterReturning(fighterIndex)
local ship = Entity()
local subsystemInstalled = false
-- Check if the transport subsystem is installed
for _, system in pairs(ship:getSystems()) do
if system.script == "data/scripts/systems/transporter.lua" then
subsystemInstalled = true
break
end
end
-- If the transport subsystem is installed, instantly return the fighter to the hangar
if subsystemInstalled then
local hangar = Hangar(ship.id)
hangar:addFighter(fighterIndex)
else
-- Original behavior (whatever it is, for example, fly back)
self:flyFighterHome(fighterIndex)
end
end
Step 3: Test Your Mod
Ensure your newly written or modified scripts are saved correctly in your mod directory. Also, make sure the mod is installed and activated in Avorion:
- Copy your
InstantTransport folder to Avorion/mods/.
- Add a modinfo.lua file to describe your mod (this helps the game recognize and manage the mod):
Example: modinfo.lua
meta = {
id = "instant_transport",
name = "Instant Transport Mod",
version = "1.0",
author = "Your Name",
description = "Instantly transports fighters returning home to the hangar if the transport subsystem is installed.",
dependencies = {
{id = "Avorion", min = "0.20.0", max = "1.0.*"}
}
}
scripts = {
{ path = "data/scripts/systems/transporter.lua" },
{ path = "data/scripts/entity/ai/fightercontroller.lua" }
}
Step 4: Debugging
- Run the game and test your mod. Debug any issues by checking the game logs typically located in the
Avorion/Avorion log files.
- Use print statements in Lua to diagnose issues if the subsystem isn't working as expected.
Additional Tips:
- Ensure to backup original game files before modifying them.
- Check community forums or existing mods for more references on how scripts are structured and managed.
By following these steps, you can create a mod that facilitates instant transportation of returning fighters into your ship's hangar when the transport subsystem is installed.