• 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.
Sorry, it probably works, I just mean I cant figure out how to scope it correctly lol. Thank you for taking time to answer these questions.
Code:
textbox = {
                    name = "new_stat_test"
                    position = { 72 3 }
                    using = MarbleButtonFont
                    autoresize = yes
                    text = "var_testing"
                    tooltip = "tooltip_test"
                    widgetanchor = top|hcenter
                }
I tried both this method with localization, but also directly using [PREV.Var('test_var_1').GetValue] inside text = "". - with the scopes Phlopsi suggested (SCOPE,THIS,PREV,ROOT) and tried InGameTopbar.GetPlayer as well.
My localization:
Code:
 var_testing:0 "[PREV.Var('test_var_1').GetValue]"
So there are two issues here, one is a misunderstanding of the data system and another is something that is not in the released version of the game yet.

The misunderstanding is that you have no PREV or SCOPE etc. there. All you have is whatever InGameTopbar gives you and what is globally accessible. There is no PREV or SCOPE to give you anything so you've got to work with what you have there.

What you would need to type for the localisation is [InGameTopbar.GetPlayer.MakeScope.Var( 'test_var_1' ).GetValue], which brings us to the second issues. In the release version you cannot chain to anything after MakeScope, it can only be the last link in a chain. This is something I have changed for an upcoming patch, probably 1.1 but no guarantees.
 
If I wanted to display the portrait of someone (saved as "cool_person" (scope)) instead of the ruler in the government view tab, this syntax wouldn't work? Or is it something not doable:

Code:
                portrait_button = {
                    using = portrait_100_no_pop
                    name = "player_portrait"
                    position = { 0 33 }
                    datacontext = "[GovernmentView.GetPlayer.SCOPE.sChar('cool_person')]"
                }
 
If I wanted to display the portrait of someone (saved as "cool_person" (scope)) instead of the ruler in the government view tab, this syntax wouldn't work? Or is it something not doable:

Code:
                portrait_button = {
                    using = portrait_100_no_pop
                    name = "player_portrait"
                    position = { 0 33 }
                    datacontext = "[GovernmentView.GetPlayer.SCOPE.sChar('cool_person')]"
                }
No, you can't just stick SCOPE wherever you want, its got to actually be something available in the context of where you are.
Currently MakeScope does not work as a promote so you cannot do what you want, but in an upcoming patch you would be able to type [GovernmentView.GetPlayer.MakeScope.Var( 'cool_person' ).Char] and it would work.
 
No, you can't just stick SCOPE wherever you want, its got to actually be something available in the context of where you are.
Currently MakeScope does not work as a promote so you cannot do what you want, but in an upcoming patch you would be able to type [GovernmentView.GetPlayer.MakeScope.Var( 'cool_person' ).Char] and it would work.

I think that update will make a lot of things possible :)

But for the time being, is there any efficient way to display a country or province variable in a GUI or even a tooltip (say for example I created a new mana type (custom variable) for a country, where would it be possible to display its value?)

Or is it better to wait for that update before modding such things?
 
Hello @blackninja9939
Thanks a lot for your post and work.

I have a little question:
Do you know if it is possible, via modding, to enable Windows to stay open? For example: If I open 'diplomacy_overview.gui' and then open 'trade_overview.gui' the Diplomacy Window will close. But the Outliner is a Window that always stays open. That's why I already have taken a look at the 'outliner.gui' but sadly can't find anything indicating that the Window should stay open. I already asked in a dedicated Discord Modding Server but no one is answering me there or doesn't seem to know an answer...

Would be really nice if that would be possible!

Thanks and have a nice day!
 
I think that update will make a lot of things possible :)

But for the time being, is there any efficient way to display a country or province variable in a GUI or even a tooltip (say for example I created a new mana type (custom variable) for a country, where would it be possible to display its value?)

Or is it better to wait for that update before modding such things?
You can use a scripted gui like shown in the first post and use a custom_tooltip in the effect section, e.g.
Code:
custom_tooltip = "THIS.Var('my_var').GetValue"
 
You can use a scripted gui like shown in the first post and use a custom_tooltip in the effect section, e.g.
Code:
custom_tooltip = "THIS.Var('my_var').GetValue"

That worked thanks though I had to set up the tooltip in localization not directly in the scripted gui file. We can use that until it becomes possible to display such values on the GUI.
 
You can use a scripted gui like shown in the first post and use a custom_tooltip in the effect section, e.g.
Code:
custom_tooltip = "THIS.Var('my_var').GetValue"
Can you give some more tips on how to use the custom_tooltip? I find this in the triggers.log:
Code:
custom_tooltip - Replaces the tooltips for the enclosed triggers with a custom text
custom_tooltip = {
    text = <text>
    <trigger>
}
Supported Scopes: none
So i tried with the below withouth much luck:
Code:
custom_tooltip = {
text = "Is Rome"                           
tag = ROM
 }
I want to make some button with tooltip that checks if i have done certain conditions (for example own proviince XYZ) but not sure how to get it working
 
Can you give some more tips on how to use the custom_tooltip? I find this in the triggers.log:
Code:
custom_tooltip - Replaces the tooltips for the enclosed triggers with a custom text
custom_tooltip = {
    text = <text>
    <trigger>
}
Supported Scopes: none
So i tried with the below withouth much luck:
Code:
custom_tooltip = {
text = "Is Rome"                          
tag = ROM
 }
I want to make some button with tooltip that checks if i have done certain conditions (for example own proviince XYZ) but not sure how to get it working
You want the custom_tooltip in the effects.log, dunno if that supports triggers directly. You can always use regular conditional logic in effect sections.
Code:
if = { limit = { <triggers go here> } custom_tooltip = "…" }
 
Is it possible to set a variable for a pop? Although I managed to create a button in the pop view window, it doesn't seem that pops support variables, is it so?

Here's the code:
Code:
subsidize_pop_button = {
    scope = pop
    saved_scopes = {
        province
    }
    is_shown = {
    }
    is_valid = {
    }
    effect = {
    
    set_variable = {
    name = wealth
    value = 10}
    
    custom_tooltip = SUBSIDIZE_POP
}
}
 
Last edited:
A scope object can be saved with an arbitrary name to reference later on in the top scope, in our older games these were called event targets. The name was changed as internally both were called event targets and one is shorter to type for script. Eg:
Code:
father = { save_scope_as = cool_person }
scope:cool_person = { kill_painfully = yes }

I have a question about this.

As far as I understand save_scope_as it should store the current scope so it's accessible for the entire event, so I can use it anywhere I want.

However, when I try the following:

Code:
immediate = {
        if = {
            limit = {
                any_state_province = {
                    OR = {
                        trade_goods = grain
                        trade_goods = fish
                        trade_goods = cattle
                    }
                }
            }
            every_state_province = {
                limit = {
                    OR = {
                        trade_goods = grain
                        trade_goods = fish
                        trade_goods = cattle
                    }
                }
                save_scope_as = _target
            }
        }
        if = {
            limit = {
                any_state_province = {
                    num_of_slaves > 0
                }
            }
            every_state_province = {
                limit = {
                    num_of_slaves > 0
                }
                random_pops_in_province = {
                    limit = {
                        pop_type = slaves
                    }
                    move_pop = scope:_target
                }
            }
        }
    }

The error log shows that the scope _target is undefined. The exact error is:
Code:
Undefined event target '_target' at location file: ...
Event target link 'scope' returned an unset scope at location file:

Now my question is, how do I make this work so that the game nows which scope I'm talking about?
 
Is it possible to limit who can use certain diplomatic functions or wargoals? For example, if I wanted to prevent certain cultures from being able to claim provinces, or disallow tribal states from conquering territory. I want to slow down the AI's expansion outside of the diadochi, Rome, and Carthage, essentially.
 
I have a question about this.

As far as I understand save_scope_as it should store the current scope so it's accessible for the entire event, so I can use it anywhere I want.

However, when I try the following:

Code:
immediate = {
        if = {
            limit = {
                any_state_province = {
                    OR = {
                        trade_goods = grain
                        trade_goods = fish
                        trade_goods = cattle
                    }
                }
            }
            every_state_province = {
                limit = {
                    OR = {
                        trade_goods = grain
                        trade_goods = fish
                        trade_goods = cattle
                    }
                }
                save_scope_as = _target
            }
        }
        if = {
            limit = {
                any_state_province = {
                    num_of_slaves > 0
                }
            }
            every_state_province = {
                limit = {
                    num_of_slaves > 0
                }
                random_pops_in_province = {
                    limit = {
                        pop_type = slaves
                    }
                    move_pop = scope:_target
                }
            }
        }
    }

The error log shows that the scope _target is undefined. The exact error is:
Code:
Undefined event target '_target' at location file: ...
Event target link 'scope' returned an unset scope at location file:

Now my question is, how do I make this work so that the game nows which scope I'm talking about?


I am getting the same error for an event chain. Event 1 uses the scope just fine, but when I try to use the scope in event 2 which comes after it, I get this same error.
 
I had the same issue with scopes. It's almost like they're not saved after the script is executed?

I tried using them with scripted guis, button 1 saves scope, button 2 executes something for that scope. Didn't work. I think the scope expires when the script is executed?

I don't know if it's possible to use variables instead, didn't work for me either (something along the lines of move_pop = var:name, i guess it only accepts saved scopes?)
 
Last edited:
Looking through the game files, for example pyrrhus' events, it seems like that file saves Pyrrhus as the scope for each individual event, but this uses the character ID, in Pyrrhus' case 70. If you create a character in event 1, and save him as a scope, the character ID will be entirely dependent upon when the event fires, does this mean it is impossible to save a character as a scope over the course of several related events? This is extremely frustrating if true.
 
Looking through the game files, for example pyrrhus' events, it seems like that file saves Pyrrhus as the scope for each individual event, but this uses the character ID, in Pyrrhus' case 70. If you create a character in event 1, and save him as a scope, the character ID will be entirely dependent upon when the event fires, does this mean it is impossible to save a character as a scope over the course of several related events? This is extremely frustrating if true.

I think saved scopes expire as soon as that event expires. A workaround would be to save the character in a variable, I see it being used in olympics.txt

Code:
 scope:olympic_champion = {
                set_variable = {
                    name = olympic_attendee
                    value = root
                }}

Later on, they accessed the variable in another event and saved it as scope in that event

I guess they saved them as a variable to be able to use them in other events?

Hopefully someone will give us a clarification on how saved scopes work.
 
So trying to make this work, but not having much success:

scope:tiberius_gracchus = {
give_office = office_plebeian_aedile
set_variable = {
name = gracchus_1
value = root
}
}

and then next event:

immediate = {
any_character = {
has_variable = gracchus_1
save_scope_as = tiberius_gracchus

}

}

option = { #Reform
name = "gracchus_reforms.2.a"
set_as_ruler = scope:tiberius_gracchus
change_law = lex_sempronia_agraria
}

No luck, still says the scope is undefined. How were you thinking it would work, @Nc-Rm ?
 
So trying to make this work, but not having much success:

scope:tiberius_gracchus = {
give_office = office_plebeian_aedile
set_variable = {
name = gracchus_1
value = root
}
}

and then next event:

immediate = {
any_character = {
has_variable = gracchus_1
save_scope_as = tiberius_gracchus

}

}

option = { #Reform
name = "gracchus_reforms.2.a"
set_as_ruler = scope:tiberius_gracchus
change_law = lex_sempronia_agraria
}

No luck, still says the scope is undefined. How were you thinking it would work, @Nc-Rm ?


If I'm not mistaken, any_character does not support effects. Try random_character or every_character (but make sure only 1 character has such variable).

Or try:
immediate = {
var:gracchus_1 = { save_scope_as = tiberius_gracchus}
}
 
already tried var:gracchus_1, that didn't work, but I also noted that removing root helped set the variable (I think in the olympics event root was the country they were from not the character itself, since it was a country event).

so, I ended up with this:

Code:
    immediate = {
        if = {
            limit = {
                any_character = {
                    count >= 1
                    has_variable = gracchus_1
                }
            }
            every_character = {
                limit = {
                    has_variable = gracchus_1
                }
                save_scope_as = tiberius_gracchus
            }
        }
    }

I am guessing I could remove the "if" and "limit" and "any character", and go straight to "every character", if I understood you correctly?
It'd be nice to have something more intuitive to be able to refer to the same character over and over again, but it'll do for now.

And yes, there will only be one "gracchus_1". Gaius Gracchus wil obviously be "gracchus_2" ;)
 
Last edited:
already tried var:gracchus_1, that didn't work, but I also noted that removing root helped set the variable (I think in the olympics event root was the country they were from not the character itself, since it was a country event).

so, I ended up with this:

Code:
    immediate = {
        if = {
            limit = {
                any_character = {
                    count >= 1
                    has_variable = gracchus_1
                }
            }
            every_character = {
                limit = {
                    has_variable = gracchus_1
                }
                save_scope_as = tiberius_gracchus
            }
        }
    }

I am guessing I could remove the "if" and "limit" and "any character", and go straight to "every character", if I understood you correctly?
It'd be nice to have something more intuitive to be able to refer to the same character over and over again, but it'll do for now.

And yes, there will only be one "gracchus_1". Gaius Gracchus wil obviously be "gracchus_2" ;)
That is a lot of redundant stuff, you don't need the count in the if, by default it will look for at least one hence the name any_x. You don't need the if because the every checks that itself anyway.

As far as I've gathered you are just looking at saving some specific unique character to be referenced from anywhere else, why not just use a global variable?