Avorion

Avorion

Not enough ratings
XSF: Sector Music System
   
Award
Favorite
Favorited
Unfavorite
Mods: Mod
File Size
Posted
Updated
189.189 KB
21 Feb, 2024 @ 4:53pm
10 Apr, 2024 @ 6:23am
2 Change Notes ( view )

Subscribe to download
XSF: Sector Music System

In 1 collection by LM13
eXtended Scripting Framework - Library collection
13 items
Description
Script only! Requires manual setup of music files. No music provided.


Advanced users only - requires manual editing

What is this?

A music system that can play same track for same sectors, while adapting to factions, region and contents.
In other words, sector at X,Y will always play same music - unless something big happens there.

This script was created for my own soundtrack from X3: Terran Conflict - but music files will not be uploaded.

Adding music

Folder structure has been prepared inside this mod.
  • Option A: Copy your music to mod folders
  • Option B: Create folder structure in your game folder ( data/music/background/ )

Custom music has to be in OGG format
Default export to OGG in Audacity software should be enough to convert music

FIles have to be in (1).ogg , (2).ogg naming style. It's easy to do batch renaming in windows.
You can search the internet with "windows batch rename files" for instructions

Setting up files in scripts

If you stick to default folders, all that need to change is 6 numbers at 6 lines.

Example:. putting 8 files into Common folder would need:
RegisterTracks( "Common", 1000, 13 )
being changed into:
RegisterTracks( "Common", 1000, 8 )

Snippet
Line 128 @ [data/scripts/lib/music.lua ]
--- @Example: -- #A: Folder "data/music/background/Common" -- #B: indexing at 1000 - 1013 -- #C: 13 files from (1) to (13).ogg #A: #B: #C: -- RegisterTracks( "Common", 1000, 13 ) -- ========================================== -- Custom Music Sets -- -- You can create custom folders, but no need to -- Put your tracks into those folders -- then change last argument to number of actual tracks -- ========================================== -- Had to be put into function - seems that client hangs and crashes a lot with those on script load function RegisterAllCustomTracks() -- FOLDER_NAME ID NUMBER_OF_TRACKS RegisterTracks( "Common", 1000, 13 ) RegisterTracks( "Friendly", 1100, 10 ) RegisterTracks( "Hostile", 1200, 6 ) RegisterTracks( "Mysterious", 1300, 6 ) RegisterTracks( "Noise", 1400, 3 ) RegisterTracks( "Uncertain", 1500, 4 ) end

Having music files in correct folders, with music.lua file corrected is enough to use custom music.

Advanced settings - Music selection logic
By default, music is picked based on faction relations, population, stations, asteroids and wreckages content. You can change that if you want

Snippet
Line 170 @ [data/scripts/player/client/musiccoordinator.lua ]
-- ------------------------------------ -- @Settings -- ------------------------------------ local BadRelation = -25000 local GoodRelation = 75000 local WreckageLimit = 50 local AsteroidLimit = 1250 local StationCoreLimit = 6 local StationEmptyLimit = 3

Snippet
Line 213 @ [data/scripts/player/client/musiccoordinator.lua ]

-- ------------------------------------ -- @Track Seletion Logic -- ------------------------------------ -- #Barely populated sectors: if stations < 2 then -- @With significant asteroid fields if asteroids > AsteroidLimit then primary = TrackCollection.Desolate() -- @That have nothing else else primary = TrackCollection.Empty() end -- #Small population sectors: elseif ...


Snippet
Line 270 @ [data/scripts/player/client/musiccoordinator.lua ]

-- ------------------------------------ -- @Assign Sector Unique tracks -- ------------------------------------ local _Min = 1 local _Max = #primary -- Don't use secondary tracks secondary = primary -- Use Xavorion Galaxy generator to pick unique tracks for this particular sector local _PrimaryIndex = IGalaxy.GetPredefinedInt(x, y, "SectorProperty.MusicPrimary", _Min, _Max) local _SecondaryIndex = IGalaxy.GetPredefinedInt(x, y, "SectorProperty.MusicSecondary", _Min, _Max) -- You can make up "SectorProperty.Music..." strings to roll more indices, adding more than 2 track to single sector