What's the difference between game_events.lua and game_diplomacy.lua?

A forum to discuss custom scenarios, campaigns and modding in general.

Moderators: Slitherine Core, The Lordz

Post Reply
Kossatx
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 132
Joined: Wed Nov 27, 2013 3:27 pm

What's the difference between game_events.lua and game_diplomacy.lua?

Post by Kossatx » Mon May 20, 2019 8:58 am

Hi! Anyone can explain what's the difference between game_events.lua and game_diplomacy.lua? Many events are scripted in these two files, aznd I have no idea why :? Moreover, I think many times the same event is defined in different ways in these two files... why? :|

Robotron
Lieutenant Colonel - Panther D
Lieutenant Colonel - Panther D
Posts: 1230
Joined: Tue Nov 23, 2010 3:35 pm

Re: What's the difference between game_events.lua and game_diplomacy.lua?

Post by Robotron » Mon May 20, 2019 12:45 pm

Don't call me anyone. ;)

game_events.lua handles all events that can trigger at the start of a turn or are triggered by moving or attacking units, declarations of war and surrender events.
Many of these are disabled but were not deleted for reference purposes.

game_diplomacy.lua handles the choice events, intel, influence, alignment calculations and other stuff.
Slitherine's Commander the Great War on steroids: POTZBLITZ mod!
http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610

Kossatx
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 132
Joined: Wed Nov 27, 2013 3:27 pm

Re: What's the difference between game_events.lua and game_diplomacy.lua?

Post by Kossatx » Mon May 20, 2019 3:24 pm

You are right Robotron :lol:

Ok, but why there are some events in both files? For example, spawning units in Kerenski and the irish revolt events are defined in both files.... why? :?

Robotron
Lieutenant Colonel - Panther D
Lieutenant Colonel - Panther D
Posts: 1230
Joined: Tue Nov 23, 2010 3:35 pm

Re: What's the difference between game_events.lua and game_diplomacy.lua?

Post by Robotron » Mon May 20, 2019 7:03 pm

Many events for spawning units have two versions:

one for singleplayer (in game_diplomacy.lua) which can be triggered at any time during a turn.

and one for multiplayer (in game_events.lua) which MUST be triggered at the START of a turn or else the game will crash during the other player's replay phase.


You can see whether a function or statement is viable for single or multiplayer by looking for occurrences of:

if game.type == Game.TYPE_SINGLE then
(...)
end

or

if game.type == Game.TYPE_PBEM then
(...)
end
Slitherine's Commander the Great War on steroids: POTZBLITZ mod!
http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610

Kossatx
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 132
Joined: Wed Nov 27, 2013 3:27 pm

Re: What's the difference between game_events.lua and game_diplomacy.lua?

Post by Kossatx » Tue May 21, 2019 8:20 am

So, if an event is repeated in both files is because the version in game_diplomacy.lua is only for single player games and the version in game_events.lua is only for PBEM games?

Robotron
Lieutenant Colonel - Panther D
Lieutenant Colonel - Panther D
Posts: 1230
Joined: Tue Nov 23, 2010 3:35 pm

Re: What's the difference between game_events.lua and game_diplomacy.lua?

Post by Robotron » Tue May 21, 2019 12:45 pm

For events about spawning units, yes.

There are however many functions in game_events.lua that are obsolete and are no longer called from TriggerTurnEvents.

To see whether a function is obsolete just perform an automated search of the whole scripts folder using notepad++ (takes only 1 second)

Seach for the name of the function followed by ()

For example: Kerenski()

If there are no hits, then that function is no longer getting called from anywhere and no longer needed and therefore obsolete.

function Kerenski() is obsolete like most other unit spawning events for multiplayer since V9, it has been integrated into function Offensives() in game_events.lua
Slitherine's Commander the Great War on steroids: POTZBLITZ mod!
http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610

Kossatx
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 132
Joined: Wed Nov 27, 2013 3:27 pm

Re: What's the difference between game_events.lua and game_diplomacy.lua?

Post by Kossatx » Tue May 21, 2019 3:40 pm

Ok Robotron, thanks again.

Post Reply

Return to “Commander the Great War : Mods & Scenario Design”