Robo's Lua Coding masterclass

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

Moderators: Slitherine Core, The Lordz

Umeu
Sergeant First Class - Elite Panzer IIIL
Sergeant First Class - Elite Panzer IIIL
Posts: 437
Joined: Sat Nov 17, 2012 7:00 pm

Re: Robo's Lua Coding masterclass

Post by Umeu »

Robotron wrote: Sun Nov 05, 2023 5:28 pm Only choice-events can be displayed as ???-events.

If you want to prevent your Hindenburg-Line event from showing upon triggering, trigger it with -1 instead of game.turn

Code: Select all

if GetEvent("HindenburgLine") == 0 then
	if game.turn == 45 then --- just an example for whatever condition you fancy
		SetEvent("HindenburgLine", -1)
	end
end
The disadvantage of doing it this way is that you won't be able to refer to the proper game.turn on which the HindenburgLine was triggered in the future, because this is now set to -1

So for example this would no longer be possible

Code: Select all

if game.turn ==  GetEvent("HindenburgLine") +12 then
	(...)
end
ok that's perfect. Since it will be a choice event.

still working on the code. Getting close
Check out Project: IMBA, the balance mod for the multiplayer section of Commander: the Great War. Your input is appreciated! viewtopic.php?f=218&t=39677
Robotron
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2173
Joined: Tue Nov 23, 2010 3:35 pm

Re: Robo's Lua Coding masterclass

Post by Robotron »

*sigh*

Code: Select all

if IsTechCompleted("concrete_dugout", serbia) ~= true then

	for unit in serbia.units do		
		if 	unit.hex ~= nil
			and unit.hex.terrain.type == Terrain.LAND  then	
				local check = 0
				local hexes = game.map:GetHexesInRange(unit.hex, 1)
				for _, hex in pairs(hexes) do
					if 	hex.unit ~= nil
						and hex.unit.alliance.id == 2 then
						  check = 1
						  break
					end
				end	
				if unit.hex.x <= 109 
						and unit.hex.originalFaction.id == 7
						and check == 0	then  
						  unit.hex.entrench = 5
				end
		end
	end
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
Umeu
Sergeant First Class - Elite Panzer IIIL
Sergeant First Class - Elite Panzer IIIL
Posts: 437
Joined: Sat Nov 17, 2012 7:00 pm

Re: Robo's Lua Coding masterclass

Post by Umeu »

awesome! I was close but I think it would've taken me a few more years to get there :D checks are too advanced for me yet
Check out Project: IMBA, the balance mod for the multiplayer section of Commander: the Great War. Your input is appreciated! viewtopic.php?f=218&t=39677
Wolf001
Administrative Corporal - SdKfz 232 8Rad
Administrative Corporal - SdKfz 232 8Rad
Posts: 173
Joined: Wed Jan 16, 2019 4:11 pm

Re: Robo's Lua Coding masterclass

Post by Wolf001 »

Here you are Umeu.
Attachments
EndGameSave.zip
(180.19 KiB) Downloaded 41 times
Last edited by Wolf001 on Thu Jan 25, 2024 8:05 pm, edited 2 times in total.
Umeu
Sergeant First Class - Elite Panzer IIIL
Sergeant First Class - Elite Panzer IIIL
Posts: 437
Joined: Sat Nov 17, 2012 7:00 pm

Re: Robo's Lua Coding masterclass

Post by Umeu »

Wolf001 wrote: Mon Jan 15, 2024 4:55 pm Here you are Umeu.
I can't replicate the crash, and the log wasn't specific enough for me to locate the crash. I've uploaded the end of turn and next turn, which at least hopefully will allow you to continue the game. If it happens again, let me know.
Attachments
game_events.rar
(122.13 KiB) Downloaded 51 times
SaveGameWolf.rar
(257.54 KiB) Downloaded 47 times
Check out Project: IMBA, the balance mod for the multiplayer section of Commander: the Great War. Your input is appreciated! viewtopic.php?f=218&t=39677
Post Reply

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