[Fixed] "Iron Hand" scenario Lua error (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Tech Support



Message


Zahar00 -> [Fixed] "Iron Hand" scenario Lua error (3/2/2021 7:33:37 PM)

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 -> RE: "Iron Hand" scenario Lua error (3/9/2021 5:52:14 AM)

0014443




Rory Noonan -> RE: "Iron Hand" scenario Lua error (4/29/2021 8:27:38 PM)

I've tried to reproduce this a few times without any success. Do you have a save file showing the issue?




KnightHawk75 -> RE: "Iron Hand" scenario Lua error (5/1/2021 6:37:07 PM)

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):
function WeatherReportIsDue()
	local result = false
	local hourZulu = TimeIs().hour
	local hourLocal = hourZulu + scenarioZuluOffset
	if hourLocal %6 == 0 then
			result = true
	end
	return result
end
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.




Rory Noonan -> RE: "Iron Hand" scenario Lua error (5/4/2021 6:08:56 PM)

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




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
1.21875