SGM Library Stellaris




SGM Library Stellaris

Overview
This is not a mod, but a resource for modders. Its purpose is to centralize scripts that are used by multiple addons.

Features
Most of the library functions allow you to determine (or estimate) the numerical value of an ingame property (which is not possible via normal scripting). The other “innovation” is that it shows a way to apply dynamic modifiers (by implementing a range of static modifiers and using binary search to determine which one is actually applied).

List of Functions
The naming scheme is more or less SGM___

SGM_country_add_energy/food/influence/minerals/unity
SGM_country_sub_energy/food/influence/minerals/unity
SGM_country_get_energy_balance
SGM_country_get_max_naval_capacity
SGM_country_get_mineral_balance
SGM_fleet_acc_fleet_size
SGM_fleet_get_fleet_power
SGM_fleet_get_fleet_size
SGM_planet_get_planet_size
SGM_planet_get_sp_level (sp=spaceport)
SGM_planet_num_sp_modules
SGM_planet_num_sp_slots_free
SGM_ship_modifier_upkeep_add
SGM_ship_modifier_weapon_damage_add
Some of these scripts consist of several thousands lines of code. When Stellaris is launched the code is interpreted, which causes the loading time to increase. Most mods use exclusively their own scripts, but I found that several of the SGM mods need the same functionality and thus I created this library to avoid loading the same script multiple times.

Using SGM Library In Your Own Mods
Modders are welcome to take a peak and copy as they like. Please leave a comment or thumbs up if you find something useful. You can also use the provided functions in your own mods by including this library as a “Required Item”. If you do so, please make sure that you read and understand the disclaimer at the very end.

Automatic Code Generation
Some of the provided scripts are created “automatically” using a simple code creator written in Matlab. The source of the coder is included in the upload as well. You might find it useful for creating static, loop unrolled binary searches to determine the exact numerical value of Stellaris ingame variables, using only the minimally required number of “if” statements.

Return Value Concept
To specify the scope for the return value of a function use

“save_event_target_as=SGM_result_scope” in your desired result scope
the script will make the return value available in the marked scope using “event_target:SGM_result_scope”
the result variable is named “SGM_”
Disclaimer
At last a fair word of warning: Stellaris scripting is primitive. There is no abstraction, there are no interfaces. You are directly depending on the implementation itself. If you use this library, every change that I make will directly affect your mod. I’ll try to keep the library stable and up-to-date, but understand that I am doing this in my free time, as a hobby. In no way am I to be held responsible for any inconvenience or error that results from using this library.

Credits:
Soulbinder
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)


What is Stellaris mods?

It looks like you’ve chosen the Stellaris mods! Well don’t wait, press “Download”. Don’t worry! All the mods on this website are completely free. No hidden charges or limitations will bother you. Simply spend couple minutes of your free time to install these mods and improve your game so you could experience the new excitement. We can ensure that only highest quality mods Stellaris are being published on our website. We care about our community and we want you to feel happy. Do you want to feel happy too? Well, don’t wait. Hundreds of different mods are waiting for you. They aren’t going to install by themselves. Take a look at all our offers and find the best mods you truly need. Download mods for Stellaris and install. A couple of minutes – that’s all that it takes to improve the game. Don’t miss this chance because you deserve the best of the best!





You may also like...

Leave a Reply

Your email address will not be published.