• 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.
What is the current hack we should use in order to fire an event at (or pretty much at) game start? It seems that simply setting a trigger like
C++:
trigger = {
        game_date = 1836.1.5
}
won't work. I learned there is something called "on_actions" but I don't like the idea of having a condition be checked every time a research is started, because it's an arbitrary condition, or every time a character is created, and then check if it's a ruler, and then if it's the right dynasty, in order to show an event with info on the ruler. It seems pretty uneconomical to me. I don't know what happened to the good old days when we could just set a date for an event to fire and it would just work as you would expect intuitively.


EDIT:
Answered on my own:

you can put a weekly pulse check in a journal entry:
C++:
some_journal_entry {
...

on_weekly_pulse = {
        events = {
            my_mod_event_name.1
        }
        effect = {
        // leave empty if you just want to fire the event and let the event handle effects
        }
    }

...
}
I saw this approach in the Voice of the People DLC file: \game\common\journal_entries\02_french_monarchism.txt

I don't know if it's better optimization to use a variable to check if the event should be fired in this events {} block or in the event's trigger {} block. I have copied the approach from VoP:

C++:
...
trigger = {
        is_player = yes
        ruler = {
            has_ideology = ideology:ideology_orleanist
        }
        NOT = { has_variable = fra_start } // using my own variable to avoid calling this event ever again after the first time
    }
...
immediate = {
        set_variable = fra_start
}
...
For game start, better is to use the history folder. you can fire an event from a country's history or use the "global" history. Otherwise, for triggers like game_date, typically you'll use comparative operators, < or >, rather than =.

Overall though, in Victoria 3, there are no mean time to happen events, all events must be triggered by an on_action or another effect.

As for optimization, unless the event is being call constantly, I think it's about the same to use a conditional check on whether to trigger it or just put it in the event trigger.
 
  • 1Like
  • 1
Reactions:
How can I store the value of an ingame variable in a variable in my script? Currently I want to record the value of the clout of an interest group at the start of the game, and give the player an objective in a journal entry, that he should keep the clout below a value that is based on this initial value.
 
  • 1
Reactions:
I think I've found what code can be used for comparison of the goods production:

C++:
market = {
            mg:steel = {
                market_goods_production >= 200
            }
        }
However, is it possible to replace the static value with a variable? I can't find examples of this in the code.
 
  • 1
Reactions:
You can always just try it out, put var:your_variable in place of the 200 or whatever value. You might need to 'scope' the variable, so something like root.var:your_variable instead.

For IG clout, there is the trigger IG_cout, which also functions as a game variable, so you can use it in a starting effect (in the history files or the immediate of the journal entry added on start for example) to set a variable. For an example, see the French monarchy scripted effects such as fra_weekly_pulse_bonapartist_progress in common/scripted_effects/00_victoria_scripted_effects.txt.

For using it in a journal entry, you can set a goal value explicitly from the IG clout and use that mechanic more directly than just setting a variable.
 
  • 1
Reactions:
Still doesn't work when I check it ingame.:

C++:
...
immediate = {
        set_global_variable = {
            name = current_steel_production
            value = this.market.mg:steel
        }
    }

complete = {
        market = {
            mg:steel = {
                market_goods_production >= root.var:current_steel_production
            }
        }
...
}

I'm not sure what's the way to "get" the value, and if what I'm referencing as "this.market.mg:steel" returns to me the value I need, or it returns an object where one of the properties is the sell orders, or production. I'm also not sure what is the difference between sell orders and production, the values seem to be the same in the game interfaces.
 
  • 1
Reactions:
Still doesn't work when I check it ingame.:

C++:
...
immediate = {
        set_global_variable = {
            name = current_steel_production
            value = this.market.mg:steel
        }
    }

complete = {
        market = {
            mg:steel = {
                market_goods_production >= root.var:current_steel_production
            }
        }
...
}

I'm not sure what's the way to "get" the value, and if what I'm referencing as "this.market.mg:steel" returns to me the value I need, or it returns an object where one of the properties is the sell orders, or production. I'm also not sure what is the difference between sell orders and production, the values seem to be the same in the game interfaces.
Well, one issue is that you set the variable as a global_var but then call it as a "local" var. Either way can work, but if you set it as global, you need to call it with global_var:var_name, and then scoping is irrelevant

One way to check the value is to set a localization to output the value. I'm not sure the exact script for that, but you should be able to find an example in the localization files.

I'm not exactly sure about how to set the value either, though there might be a vanilla example. If I find something, I'll let you know.
 
  • 1Like
  • 1
Reactions:
Hi, please tell me which lines should be changed in the code to allow the AI not only to automatically subsidize buildings like railroads, but also to automatically expand railroads? The thing is that in my game I regularly encounter the fact that private investors do not build anything in industrialized countries because of a small lack of infrastructure, to make the AI build railroads through ai_value or PRODUCTION_BUILDING_DESIRED_INFRASTRUCTURE_SURPLUS.
PRODUCTION_BUILDING_EXCESSIVE_INFRASTRUCTURE_SURPLUS does not work for me.
I would be grateful if you could tell me one way or another how to deal with the infrastructure problem.
P.s Automatic railroad expansion solves this problem, except that the AI doesn't (or can't) keep this option enabled.
 
  • 1
Reactions:
Hi, please tell me which lines should be changed in the code to allow the AI not only to automatically subsidize buildings like railroads, but also to automatically expand railroads? The thing is that in my game I regularly encounter the fact that private investors do not build anything in industrialized countries because of a small lack of infrastructure, to make the AI build railroads through ai_value or PRODUCTION_BUILDING_DESIRED_INFRASTRUCTURE_SURPLUS.
PRODUCTION_BUILDING_EXCESSIVE_INFRASTRUCTURE_SURPLUS does not work for me.
I would be grateful if you could tell me one way or another how to deal with the infrastructure problem.
P.s Automatic railroad expansion solves this problem, except that the AI doesn't (or can't) keep this option enabled.
İ see private Sector build railroads with No problema in my games. Aİ countries are less proactive (Like Building a railroads once infrastrutture surplus Is less than 5) and smaller countries Sometimes Need a few years, but that more lack of consttuction in itself.

When do you Encounter this Problem ? Early, MID or late game ?

Onlus Aİ countries or also your own ?

Will maybe Take a look in evening.

As i am about tò move (and 1.7...) i out on hold trying tò do a mod on buildings buy that seems Like an interesting thing tò Look at.
 
  • 1
Reactions:
İ see private Sector build railroads with No problema in my games. Aİ countries are less proactive (Like Building a railroads once infrastrutture surplus Is less than 5) and smaller countries Sometimes Need a few years, but that more lack of consttuction in itself.

When do you Encounter this Problem ? Early, MID or late game ?

Onlus Aİ countries or also your own ?

Will maybe Take a look in evening.

As i am about tò move (and 1.7...) i out on hold trying tò do a mod on buildings buy that seems Like an interesting thing tò Look at.
In the middle and late game I start to see such problems, first of all in the industrialized countries because they build a lot . In the screenshots first the situation with the level of railroads,then you can see how the private sector does not build anything,then I myself went to the UK and put automatic road expansion,private investors filled the construction queue for 100+ buildings immediately after the start of road expansion. Plus I play with the Railroaded AI mod which makes countries develop better (over 300 million GDP in 1900) + many new mechanics and events. Maybe it somehow changes the desire of the private and public sector to build infrastructure in excess, but I haven't found what lines of code are responsible for this.

P.S I fixed the problem with railroads, the only remaining problem is with ports, which the AI often reduces to 1 because of which it has problems with port connectivity and trade.
 

Attachments

  • const1.png
    const1.png
    3,6 MB · Views: 0
  • const2.png
    const2.png
    3,3 MB · Views: 0
  • const3.png
    const3.png
    2,5 MB · Views: 0
Last edited:
  • 1
Reactions:
I have a weird issue/question. I'm making a mod and many states aren't spawning their buildings despite no issues visible in the building files. For example:
1714393743708.png
1714393826091.png


Does anyone know the cause?
 
  • 1
Reactions:
I have a weird issue/question. I'm making a mod and many states aren't spawning their buildings despite no issues visible in the building files.

Does anyone know the cause?
I've had this issue before and sometimes it was something stupid like adding a space in create_ building which completely wiped the ability for much of a region (not just the offending state!) to spawn buildings.
Install CWTools - Paradox Language Services into Visual Studio Code and check if there really is an error you've missed. Warning though is that there's a lot of false errors you'll have to scroll through because it can't recognise barracks PMs or something. Also remember to close VS Code when you're done because otherwise Victoria 3 will try to access files that are currently held in memory by Visual Studio.
Other common issues are { } brackets not being closed properly which after identifying the existence of such error in VS Code can be easily fixed in Notepad++ by putting your text cursor next to the ending } bracket to highlight it as red and scrolling up until the vertical red line stops (sometimes it's easier to set the language to C or something so it's easier to spot where the highlighted vertical line ends)
for example:
1714472409738-png.1126006
Otherwise if neither of these things are the case we need the full file rather than a screenshot of what can otherwise look to be correct code (which really should use [code ] [/code] tags instead on this forum but doesn't matter now)
 

Attachments

  • 1714472409738.png
    1714472409738.png
    52,9 KB · Views: 0
Last edited:
  • 1
Reactions:
Any pointers on how to fix the issue where urban centres don't spawn in the game (especially when starting) and the urbanisation per level tooltip just shows TEXT,AA== ?
I've seen it posted online a few times but aside from the fact it's to do with mods no actual clues as to the root of the problem
specific mod I'm having trouble with is Lunabups' Cosmopolitan - Modern Day Basemap, wanted to make an addon for it now it's working as of 1.6 but am hitting this problem which is preventing me from really testing production methods for urban centres
If it helps with awareness of this problem here's a screenshot of this phenomenon in Cosmopolitan - Modern Day Basemap (it naturally appears in the derivative mod I'm working on but I didn't want to muddy the waters when the problem exists regardless of what I've added)
1714472800010.png

Obviously we should have at least four levels of urban centre in this state but the mechanic's broken to the point of not being able to display a tooltip.
Can confirm this occurs regardless of system.

Also see the other place this has been reported: https://steamcommunity.com/app/529340/discussions/0/4039229229059129950/, not that any of the mod creators have observed this themselves or understand why this would happen for the user.
 
  • 1
Reactions:
If I understand this correctly, it's saying the end bracket is a syntax error. But I don't understand why it would be?
That's an error somewhere earlier in the file or a false positive. Basically, the CWTools parser ran into an unexpected character or sequence. Unfortunately, CWTools is not super functional for Vic3 yet. (Though this sort of error can pop up in other games sometimes)
 
If I understand this correctly, it's saying the end bracket is a syntax error. But I don't understand why it would be?
As mentioned by CaesarVincens, this is an error from earlier in the file: most likely an open { bracket not having a matching closing } bracket (so the parser carries on until it finds the wrong } to use and then throws a fit when it encounters an 'unmatched' } bracket further down the file)
If you keep your text cursor next to the } bracket the error is talking about you can scroll up until you find the highlighted (outlined boxed-in) { bracket, or when the vertical line tracing the section out is no longer highlighted (compare here the grey lines vs the white lines)
1714496837503.png
EDIT: Okay note to everyone reading afterwards - just had this issue cropping up again for myself to remind me that if it's the parser throwing an error about a closing } bracket then really you need to put the text cursor at the first relevant opening { bracket (i.e. I got it backwards, e.g. if it's an error at the end of the file you need to figure out what the bracket at the start of the file etc. is actually being matched up to)
 
Last edited:
Another possibility is a missing equals sign or an equals sign without any following argument (text or number).
 
when the vertical line tracing the section out is no longer highlighted (compare here the grey lines vs the white lines)
The vertical grey line stops after 2841 lines, even in files without errors.

most likely an open { bracket not having a matching closing } bracket (so the parser carries on until it finds the wrong } to use and then throws a fit when it encounters an 'unmatched' } bracket further down the file)
I already checked that and there's no mismatch between the number of { brackets and } brackets in the file.

EDIT: Found the issue, a missing " from every single rye farm I gave potatoes to. Ended up just using Notepad++ to search for " and looking for the first row to give an odd number of results. Somehow I missed it even though I looked RIGHT AT IT several times over these last few days.

Thank you for introducing me to CWTools though.
 
Last edited:
  • 1Like
Reactions:
If it helps with awareness of this problem here's a screenshot of this phenomenon in Cosmopolitan - Modern Day Basemap (it naturally appears in the derivative mod I'm working on but I didn't want to muddy the waters when the problem exists regardless of what I've added)
Obviously we should have at least four levels of urban centre in this state but the mechanic's broken to the point of not being able to display a tooltip.
Can confirm this occurs regardless of system.

Also see the other place this has been reported: https://steamcommunity.com/app/529340/discussions/0/4039229229059129950/, not that any of the mod creators have observed this themselves or understand why this would happen for the user.
Well after asking on the Victoria 3 Mod Co-Op Discord again we figured out it was due to Cosmopolitan - Modern Day Basemap replacing the 00_static_modifiers.txt file, likely causing problems when the game is expecting a definition for state_urbanization_per_level_add, I guess this means I've yet another file to add to my own mod to remember to keep updating with every update until needing to override the basemap files is no longer a problem.

This was probably the cause of the steam user's problem as well, although in that case I guess setting stuff within base_values = { } in a differently named file also wipes the vanilla values? It would make sense but I didn't bother to check that mod instead.
 
Hello modders.
Is there a way for a mod to directly manipulate pops, more specifically to partially fire a pop from a building?
But otherwise maybe emulate firing by cloning an existing unemployed pop as unemployed and resizing it..
I haven't been able to find any examples, but maybe the community knows.

I've been thinking if I can write a mod to work around the bug that soldiers in barracks (like all government buildings) are not able to move to officer jobs when qualified.