Sim Constructor + Sequential Mod Loader

If you liked this item, please rate it up on Steam Workshop page.

Author: cyberboy2000

Last revision: 23 Jun, 2025 at 21:34 UTC (2)

File size: 86.55 KB

On Steam Workshop

Description:

The Sim Constructor is a tool that gives mod makers more freedom while maintaining compability.

These are the current modules:
1) Early, late, and unload options for mod loading.
2) Modding existing generation options and customizing new options(more than one value, default to false etc).
3) Defining required mods. These mods will always be loaded before your. (I did not make this module. Credit goes to Lemonhead).
4) Adding Agent banter.
5) Customizing hud elements.
6) Modifiers now use a fixed order of operations that can be customized. Also adds convenience functions for working with modifiers as well as new modifiers for clamping values and custom behaviour.
7) Provides public access to certain local variables, by adding them to simdefs.
8) New debug mode for debugging modifiers.

The mod also provides a few fixes to existing crashes and bugs, as well as a few quality of life improvements, like sorting mods alphabetically and allowing you to compact them, on the generation options screen.

If you are using a mod that is made using the Sim Constructor, you need to have the Sim Constructor to run it.

How to use it (for mod makers)

–Change an existing generation option –Defined by option name, not simdef name –Reference can be found in clientstatesstate-generation-options rawset(simdefs.CUSTOM_OPTIONS,anyname,{ name, tip, check, strings, values, apply, retrieve }) –Customized generation option –If enabled=false this ption will start unchecked(ignored if Values is defined) –Values is a table that holds different alternatives –Strings contains names that match values(optional) –Value is default value(optional) modApi:addGenerationOption(optionName, name , tip, {enabled,values,strings,value} ) –Modify a hud file –The files that can be modified are all files located in gui.kwad/gui (you need to use kwad extractor to see these files) –data is deepmerged, so you only need to include the info that you are changing –You can use a new filename to create new screens, when doing this, do NOT provide a filename extension (.lua) simdefs.SCREEN_CUSTOMS = util.extend(simdefs.SCREEN_CUSTOMS) { [filename] = { data } } –Set a game param directly –This feature has not been fully tested, use at your own risk –This code needs to be called in the load function instead of the init function modApi.mod_manager.genOptions[option] = options[option] –Loading mod content before or after other mods, or if the mod is disabled local function earlyLoad( modApi, options ) end local function earlyUnload( modApi, options ) end local function unload( modApi, options ) end local function lateLoad( modApi, options ) end local function lateUnload( modApi, options ) end –Add agent banter (use in load function after adding guard to agentdef, not in the init function) modApi:addBanter( { agents = {id,id},–The agents that are talking dialogue = { {id,string},–Id is the talking agent, string is what they say {id,string}, }, } ) –Set required mods modApi.requirements = { mods } –Adding modifiers: Required parameter –trait: name of the trait to change. –name: identifier for managing trait. Does not have to be unique unlike in the base game. –op: Operation to perform: ADD, MULT, CLA, SET, or FN –val: Parameter for operation (optional for CLA and FN) –Optional parameters: –min/max: Min and max value the operation will result in. Note that unless you’re using the CLA operator, this will not –cause a value that is already out of range to become in range. –priority: Higher priority will go first. Standard value is 0. –opPriority: Define custom order of operations, standard values goes from 4 to 0. local modifier = unit:getModifiers():add( trait, name, op, val, min, max, priority, opPriority ) –Searchs for and returns first modifier matching name and, optionally, trait. local modifier = unit:getModifiers():has( trait, name ) –Find and change the first found modifier matching name and optional trait. local modifier unit:getModifiers():change( trait, name, op, val, min, max, priority, opPriority ) –Change the given modifier (needed when changing priority, as this automatically reorders modifiers) –Note trait is optional local modifier unit:getModifiers():change( trait, modifier, op, val, min, max, priority, opPriority ) –Manually reevaluate modifiers (when changing a modifier without using the change function) unit:getModifiers():reeval( trait ) –Insert modifier unit:getModifiers():insert( trait, modifier ) –Find and remove the first found modifier that matches the name and trait. –Returns 1 if successfully removed and 0 otherwise. Use a loop if you want to remove all matching modifiers. local removedCount = unit:getModifiers():remove( name, trait ) –Find and remove the first found modifier for each trait matching name and returns the total number removed. –Use a loop if you want to remove all matching modifiers. local removedCount= unit:getModifiers():remove( name ) –Find and remove the given modifier. Returns 1 if successfully removed and 0 otherwise. local removedCount = unit:getModifiers():remove( modifier )

Here’s an example mod that uses the Sim Constructor: http://steamcommunity.com/sharedfiles/filedetails/?id=580664017

Feel free to discuss the mod on our Discord: https://discordapp.com/invite/aQrXEse

Download
Revisions:

Old revisions of this mod are available below. Click the link to download.