• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

Das Blah

Sergeant
37 Badges
May 12, 2016
79
12
  • Cities: Skylines - Parklife Pre-Order
  • Stellaris: Leviathans Story Pack
  • Crusader Kings II: Monks and Mystics
  • Surviving Mars
  • Hearts of Iron IV: Death or Dishonor
  • Age of Wonders III
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Hearts of Iron IV: Together for Victory
  • Cities: Skylines - Parklife
  • Stellaris: Distant Stars
  • Crusader Kings II: Holy Fury
  • Prison Architect
  • Stellaris: Ancient Relics
  • Stellaris: Lithoids
  • Stellaris: Federations
  • Stellaris: Digital Anniversary Edition
  • Crusader Kings II: Reapers Due
  • Hearts of Iron IV: Cadet
  • Stellaris
  • Crusader Kings II: Conclave
  • Cities: Skylines - After Dark
  • Crusader Kings II: Horse Lords
  • Crusader Kings II: Way of Life
  • Cities: Skylines
  • Victoria 2
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sword of Islam
  • Stellaris: Megacorp
  • Europa Universalis IV
  • Stellaris: Synthetic Dawn
  • Stellaris - Path to Destruction bundle
  • Crusader Kings II
Is it at all possible to define our own variables and classes? Like, rather than having to be limited to piggy-backing off of pre-existing variables/classes, are we able to create our own? If so, then how?
 
I only know of set_variable check_variable change_variable, but even there get_variable seems to be missing.

There is also save_event_target_as and something with parameter, but I didn't use that yet.

So if I were to apply a planet a completely new variable that hasn't existed in the game before, it'd look something like below?

Code:
pc_desert = {
   
    set_variable:testVar = {
        3
    }
}

That's entirely just a guess.

Oh and the closest thing to custom functions, is scripted_triggers where you can outsource often used code blocks and call it by a single line.

Oooooo. So you could get code from a different language and use it using the scripted_triggers? If so, then how exactly would one go about doing this, because that'd become quite useful.

On a side note, what about classes? Rather than the variables and functions, classes are the thing I'm most interested in, as they're generally a base foundation for every language. If you're not sure what a class is, I've got a few references that tend to come in handy. :p

https://en.wikipedia.org/wiki/Class_(computer_programming)
https://msdn.microsoft.com/en-AU/library/x9afc042.aspx
http://www.cprogramming.com/tutorial/lesson12.html
 
scripted_triggers Is still the same language, just outsourcing from one file to another. And it can only be 'functions' that return true/false used for conditions/triggers.

Yeah, I looked into it a bit more and discovered that. Still could be useful though, especially if one wishes to streamline their mod programming.

You probably can not define custom glasses.

Well then I guess that's another modability suggestion I need to make. ;)
 
I found this entry in the CK2 modding wiki but I don't see it used anywhere in Stellaris files. Does anyone know if this works?
A reference to another variable in same scope: (set|change|subtract|multiply|divide)_variable = { which = <variable_name> which = <another_variable_name> }
I mean the substract/multiply/divide functions or for example setting variable X to equal variable Y.
 
I found this entry in the CK2 modding wiki but I don't see it used anywhere in Stellaris files. Does anyone know if this works?

I mean the substract/multiply/divide functions or for example setting variable X to equal variable Y.

I imagined that doing basic maths wouldn't require having to use a specific function. Evidently that thought is wrong, but I'm also unable to find any sort of reference to that particular piece.
 
ATM only variable related commands are set_variable and chech_variable, and in both you can only use values, not variables (so you can't compare two values). @Divine said he might take a look at implementing CK2 variable commands (which would be very useful).

By value would you mean a number? As when it comes to normal variables, the value is simply whatever the variable is referencing, whether it's a number or a class.
 
I found this entry in the CK2 modding wiki but I don't see it used anywhere in Stellaris files. Does anyone know if this works?

I mean the substract/multiply/divide functions or for example setting variable X to equal variable Y.

Is this possible?

Code:
check_variable = {
                which = testVar
                value >= testVarMax
            }

Since it is a normal variable (albeit confined to numbers) I imagine that it'd still work in such a way.
 
I think it has to be 'value > x' where x is an actual number.

If > works, then I imagine that >= works as well. Not only that, but the testVarMax is a number var, so yet again, I imagine that it would work. I haven't actually gotten to test it since I haven't created the means of displaying it, but I'm hoping that using the max var will work. If not, then there needs to be some SERIOUS changes to the modding engine.
 
If > works, then I imagine that >= works as well. Not only that, but the testVarMax is a number var, so yet again, I imagine that it would work. I haven't actually gotten to test it since I haven't created the means of displaying it, but I'm hoping that using the max var will work. If not, then there needs to be some SERIOUS changes to the modding engine.

That would be logical but it's safe to assume that anything that you don't see used in the Stellaris files doesn't work. I've used workarounds to get past some of the limitations but without at least being able to compare one variable to another, I'm not sure I can solve the problem I have.
 
That would be logical but it's safe to assume that anything that you don't see used in the Stellaris files doesn't work. I've used workarounds to get past some of the limitations but without at least being able to compare one variable to another, I'm not sure I can solve the problem I have.

What exactly were these workarounds?
 
What exactly were these workarounds?

It's hard to give any general advice, depends on what you are trying to do and if it's possible to achieve the same thing with some other type of script.

For example, I wanted to make a script that counts the amount of yes/no votes and if there is a 66% majority, the vote succeeds. If the divide function worked in Stellaris, I think it would be very simple to divide yes_votes variable by no_votes variable and see check if the result was 2 or greater.

Instead I made a script that substracts two 'yes votes' and one 'no vote' from each variable every time the event loops around until various conditions are met which determines if the vote goes through.