Open Borders using Lua Script

Tiramisu

Warlord
Joined
Aug 16, 2013
Messages
148
Location
Leonberg (BW, Germany)
Hello,
in Firetuner I could successfully run the following code to give open borders to player 0 (i.e. me) in the territory of player 2:
Code:
DiplomacyManager.SendAction(0, 2, DiplomacyActionTypes.SET_OPEN_BORDERS);

However, this does not work as a lua script in my mod. I could successfully run other scripts in my mod like e.g.
Code:
Players[0]:GetDiplomacy():SetHasMet(3);
to make contact between player 0 and player 3. But open borders does simply not work for me as a mod.

I really cannot see any reason for this strange behavior, because in Firetuner my open borders script works perfectly. Please help!
 
DiplomacyMannager shows as being unavailable in a GameplayScripts context. LiveTuner (aka FireTuner) is a hybrid deal that often has its own implementation set, so that which will work in LiveTuner will not always work in the game under a GameplayScript.

Player:GetDiplomacy():SetHasMet() only shows as valid in a GameplayScript on Gedemon's reference, for example, and shows as not available in UI context.
 
Yes, they're not available in the same context.

Side note, is SendAction working in all cases, for example can you force open border on someone that don't want to trade it? Can you use it to force peace somehow?
 
Thanks for your replies!
Indeed the Open border function only works in UI context. FearSunn gave me the advice to overwrite an existing UI file to get access to the UI context. For this purpose I used TutorialGoals.lua and I added my own code there to set open borders with city states, once a major civilization has at least 3 envoys in there.
This really works, but to me it seems kind of ridiculous to use an UI file like TutorialGoals.lua just to get access to the UI context. So I wonder if there is a another way to use the UI context.

Side note, is SendAction working in all cases, for example can you force open border on someone that don't want to trade it? Can you use it to force peace somehow?

Yes, this always works even if you are at war with the target civilization. Its border lines will become dashed even during war. However, this does not enforce peace. So open borders and war can exist at the same time with a civilization.
 
  • Like
Reactions: TC_
Unfortunately declaring war will not cancel open borders once you have set opened borders with this Lua function. I tried to find a way setting closed borders myself, but I could not do that, yet.
 
That's too bad, but thank you for the response! You saved me a lot of time.
 
Top Bottom