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
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 241
Joined: Wed Nov 27, 2013 3:27 pm

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

Post by Kossatx »

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
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

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

Post by Robotron »

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.
Image
Slitherine's Commander the Great War - Director's Cut: POTZBLITZ mod!
FIND IT HERE: http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610
Kossatx
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 241
Joined: Wed Nov 27, 2013 3:27 pm

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

Post by Kossatx »

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
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

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

Post by Robotron »

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
Image
Slitherine's Commander the Great War - Director's Cut: POTZBLITZ mod!
FIND IT HERE: http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610
Kossatx
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 241
Joined: Wed Nov 27, 2013 3:27 pm

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

Post by Kossatx »

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
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

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

Post by Robotron »

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
Image
Slitherine's Commander the Great War - Director's Cut: POTZBLITZ mod!
FIND IT HERE: http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610
Kossatx
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 241
Joined: Wed Nov 27, 2013 3:27 pm

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

Post by Kossatx »

Ok Robotron, thanks again.
Post Reply

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