[Fixed] "Iron Hand" scenario Lua error

Post bug reports and ask for game support here.

Moderator: MOD_Command

Post Reply
User avatar
Zahar00
Posts: 22
Joined: Mon Aug 29, 2016 4:12 pm

[Fixed] "Iron Hand" scenario Lua error

Post by Zahar00 »

Hey,

I'm just starting to play it, and it generally works, but I got this error:



Lua script execution error: [string "Game_HourlyActions"]:2: attempt to call a nil value (global 'WeatherReportIsDue')

When I finish it, I will let you know if there are any other bugs...
WSBot
Posts: 181
Joined: Sun Jan 17, 2021 9:31 pm

RE: "Iron Hand" scenario Lua error

Post by WSBot »

0014443
Rory Noonan
Posts: 2418
Joined: Thu Dec 18, 2014 1:53 am
Location: Brooklyn, NY

RE: "Iron Hand" scenario Lua error

Post by Rory Noonan »

I've tried to reproduce this a few times without any success. Do you have a save file showing the issue?
Image
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: "Iron Hand" scenario Lua error

Post by KnightHawk75 »

Rory, is it possible you have a version of Iron Hand that hasn't actually shipped with the game or an update yet?

I can repo it with my local copy last modified 9/18/2020 (attached).
If you let it run for an hour, at 17:00Z you should get the issue and the reported errors in the exception log and the message log.

Function WeatherReportIsDue does not exist as function in the scene setup code (nor in the \lua\iron hand\ files for the scene, not that they're used), so the hourly event (Game_HourlyActions) that runs that calls it fails, that error then causes WeatherReportRUS to not run as well, and there is also a line to call CleanUpIdleCivilianShips() that never runs cause of it - but it too would fail as there is no such function. Additionally in LuaInit there is a pointless call to ScenEdit_RunScript('DeveloperMode.lua'), a file which does not exist, it doesn't matter other then the error getting logged.

The follow appears to be missing from LuaInit Action (based on other scenes):

Code: Select all

 function WeatherReportIsDue()
 	local result = false
 	local hourZulu = TimeIs().hour
 	local hourLocal = hourZulu + scenarioZuluOffset
 	if hourLocal %6 == 0 then
 			result = true
 	end
 	return result
 end

Code: Select all

function CleanUpIdleCivilianShips()
 	local unitList = VP_GetSide({side='Civilian'}).units
 	local numberOfCivilianUnits = #unitList
 	local numberOfUnitsDeleted = 0
 	for k,v in ipairs (unitList) do
 		local unit = ScenEdit_GetUnit({guid=v.guid})
 		if (unit.course[1] == nil or unit.speed == 0) and 
 			unit.type == 'Ship' then
 			ScenEdit_DeleteUnit({guid=v.guid})
 			numberOfUnitsDeleted = numberOfUnitsDeleted + 1
 		end
 	end
 
 	if DebugModeIsOn() and numberOfUnitsDeleted > 0 then
 		ScenEdit_SpecialMessage('playerside','Civ_Cleanup fired. <BR>Initial civilian Units: 
 '..numberOfCivilianUnits..' <BR>;Civilian units cleaned up: '..numberOfUnitsDeleted)
 	end
 end
 

I've tried adding the above and removing the developermode.lua call, and scene then runs without issue and you get the weather reports as intended.
Attachments
Iron Hand, 2014.zip
(164.71 KiB) Downloaded 13 times
Rory Noonan
Posts: 2418
Joined: Thu Dec 18, 2014 1:53 am
Location: Brooklyn, NY

RE: "Iron Hand" scenario Lua error

Post by Rory Noonan »

Very possible! Save files save the back and forth, but there's no use hassling you about it [:)]

I've updated this file with the missing functions but have left the developer mode call in (it's there for a reason); when running outside of the console at scenario start this doesn't cause any practical issues but it does leave a trace in the error log.

The improvements to the Lua API mean I can actually do away with that DeveloperMode.lua file and just pass global variables before I open up the .scen files to work on them. The next major update will have this applied across all standalone scenarios.

Thanks for following up on this for Zahar00
Attachments
IronHand2014.zip
(164.33 KiB) Downloaded 16 times
Image
Post Reply

Return to “Tech Support”