Page 2 of 2

Re: Robo's Lua Coding masterclass

Posted: Sun Nov 05, 2023 7:09 pm
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

Re: Robo's Lua Coding masterclass

Posted: Sun Nov 05, 2023 7:37 pm
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

Re: Robo's Lua Coding masterclass

Posted: Sun Nov 05, 2023 8:25 pm
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

Re: Robo's Lua Coding masterclass

Posted: Mon Jan 15, 2024 4:55 pm
by Wolf001
Here you are Umeu.

Re: Robo's Lua Coding masterclass

Posted: Tue Jan 16, 2024 4:34 am
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.