so i've been pissing about working on a planet-features mod, and was trying to figure out how to add [GetTechnicianPlural] to work in the tooltips (custom_tooltips in static modifiers do NOT take [] commands)
BUT then i remembered, scripted modifiers are a thing. So i made one - 3 infact, for my planet modifier.
And this worked great [the modifiers themselves dont immediately do anything - though thats fine i've got workarounds**, its the UI text that i'm concerned with].
But then I realised, the localize_with_value_key = y/n function lets you convert the classic "String: value" syntax in to " str$value$str.". This lets you write in prose!.
I did a quick and dirty test with my static_modifier's scripted_modifier loc string:
I may be getting ahead of myself here, but if i'm understanding this right, it should mean it is now possible to create modifiers, plug them in to leader traits and use those to reference values elsewhere. For example a leader "loyalty" variable could be fed in to 'mod_custom_loyalty_modifier = xxx', which is placed within trait_mod_admiral_loyalty. And have that trait read "This admiral has $value$% loyalty to our empire.". Now either that can dynamically reference a variable in the admiral (separately updated in script) or a script is needed to switch between traits (e.g. 20, in 5% stages) - but that's just one example.
Additionally, as this is a scripted_modifier and not a custom_tooltip it should be possible to feed [scope.scope.whatever] text in to the "mod_custom_loyalty_modifier" loc string to have it say whatever you like, too.
Has anyone used the scripted_modifiers / "localize_with_value_key" much? I'm wondering if there are any other examples I can look at from other mods, to see what the limitations are, as there are literally no examples in vanilla right now.
** workarounds using script_values
Edit: it looks like it works, but at face value looks like it will only consider country scope of the current empire (i.e. your one, or someone elses if playing as them), not the leader itself (or even their fleet) which makes things a little more annoying... but not unworkable.
BUT then i remembered, scripted modifiers are a thing. So i made one - 3 infact, for my planet modifier.

And this worked great [the modifiers themselves dont immediately do anything - though thats fine i've got workarounds**, its the UI text that i'm concerned with].

But then I realised, the localize_with_value_key = y/n function lets you convert the classic "String: value" syntax in to " str$value$str.". This lets you write in prose!.


I did a quick and dirty test with my static_modifier's scripted_modifier loc string:

I may be getting ahead of myself here, but if i'm understanding this right, it should mean it is now possible to create modifiers, plug them in to leader traits and use those to reference values elsewhere. For example a leader "loyalty" variable could be fed in to 'mod_custom_loyalty_modifier = xxx', which is placed within trait_mod_admiral_loyalty. And have that trait read "This admiral has $value$% loyalty to our empire.". Now either that can dynamically reference a variable in the admiral (separately updated in script) or a script is needed to switch between traits (e.g. 20, in 5% stages) - but that's just one example.
Additionally, as this is a scripted_modifier and not a custom_tooltip it should be possible to feed [scope.scope.whatever] text in to the "mod_custom_loyalty_modifier" loc string to have it say whatever you like, too.
Has anyone used the scripted_modifiers / "localize_with_value_key" much? I'm wondering if there are any other examples I can look at from other mods, to see what the limitations are, as there are literally no examples in vanilla right now.
** workarounds using script_values
I wanted to avoid manipulating job files, and as it is impossible to feed a script_modifier in to a job directly, I have to place a deposit and run the maths there, instead:
The maths:
The outcome:
+N TV and amenities, where N = ( modifier [1 by default] * employed technicians ) - if you hire/suppress technician jobs, it updates in real-time.
Provides reduced deviance if a hive mind.

The maths:

The outcome:
+N TV and amenities, where N = ( modifier [1 by default] * employed technicians ) - if you hire/suppress technician jobs, it updates in real-time.
Provides reduced deviance if a hive mind.

Edit: it looks like it works, but at face value looks like it will only consider country scope of the current empire (i.e. your one, or someone elses if playing as them), not the leader itself (or even their fleet) which makes things a little more annoying... but not unworkable.


Last edited:
- 2