Skip to content

Commit 0001011

Browse files
authored
Improved export/import variable function (#58)
2 parents 5080359 + 1856883 commit 0001011

1 file changed

Lines changed: 23 additions & 31 deletions

File tree

common/scripted_effects/th_scripted_effects_for_generic.txt

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -719,46 +719,38 @@ th_enable_transfer_mp_to_sailors_decision = {
719719
th_export_root_variable_into_foreign = {
720720
#This function counts your own variable, which is made for counting, down while increasing the counter variable of $who$
721721
#Useful if you need to convert variables from a province scope into a country's variable
722-
while = {
723-
limit = {
724-
check_variable = {
725-
which = $root_variable$
726-
value = 1
727-
}
722+
set_variable = {
723+
which = $foreign_variable$_transfer
724+
which = $root_variable$
725+
}
726+
$who$ = {
727+
set_variable = {
728+
which = $foreign_variable$_transfer
729+
which = PREV
728730
}
729-
$who$ = {
730-
change_variable = {
731-
which = $foreign_variable$
732-
value = 1
733-
}
734-
}
735-
subtract_variable = {
736-
which = $root_variable$
737-
value = 1
731+
set_variable = {
732+
which = $foreign_variable$
733+
which = $foreign_variable$_transfer
738734
}
739735
}
740736
}
741737

742738
th_import_foreign_variable_into_root = {
743-
while = {
744-
limit = {
745-
$who$ = {
746-
check_variable = {
747-
which = $foreign_variable$
748-
value = 1
749-
}
750-
}
739+
$who$ = {
740+
set_variable = {
741+
which = $root_variable$_transfer
742+
which = $foreign_variable$
751743
}
752-
$who$ = {
753-
subtract_variable = {
754-
which = $foreign_variable$
755-
value = 1
744+
PREV = {
745+
set_variable = {
746+
which = $root_variable$_transfer
747+
which = PREV
756748
}
757749
}
758-
change_variable = {
759-
which = $root_variable$
760-
value = 1
761-
}
750+
}
751+
set_variable = {
752+
which = $root_variable$
753+
which = $root_variable$_transfer
762754
}
763755
}
764756

0 commit comments

Comments
 (0)