Tech crash

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

Tech crash

Post by Kossatx »

Hi pals, any idea about this crash?

Code: Select all

[18:38:57][8472]game/game_research.lua:861(global HasUnitTech) game/game_research.lua:861: attempt to index field 'luaData' (a nil value)
[18:38:57][8472]Resume: false, std::exception: 'Lua Error:game/game_research.lua:861(global HasUnitTech) game/game_research.lua:861: attempt to index field 'luaData' (a nil value)'
[18:38:57][8472][C]:-1(global error) ai/ai.lua:0: std::exception: 'Lua Error:game/game_research.lua:861(global HasUnitTech) game/game_research.lua:861: attempt to index field 'luaData' (a nil value)'
This is the script:

Code: Select all

function HasUnitTech(unit, techName)

  -- Check if unit has it
  i = 1
  while unit.luaData.unitTechs[i] ~= nil do -- line 861
    -- Check if unit already has tech
    if unit.luaData.unitTechs[i] == techName then
      return true
    end
    i = i + 1
  end

  return false
end
Robotron
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

Re: Tech crash

Post by Robotron »

Difficult to say.

I assume this crash is from your personal modification of Potzblitz?

Please give me more info about the situation in the game:
1. when did that crash happen?
2. what turn is it
3. what is happening in the match

I'll need at least the whole logfile.
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: Tech crash

Post by Kossatx »

EDITED:

All the answers are YES, the crash happened in turn 42, while IA (Entente) attacking near Udine. An Italian Cavalry Corps attacking an Austrian Army Corps at hex 100, 34. I have tried to fix the crash, but I have no idea :idea:
Attachments
ctgw.rar
(1.57 KiB) Downloaded 57 times
Robotron
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

Re: Tech crash

Post by Robotron »

Where did that Italian cavalry come from?

Italy does not start with cavalry and AI never builds cavalry. Also there is no Spawnunit for italian cavalry in my mod.

That leaves YOU :mrgreen: as the source of the crash!

Where did you mod the script to have a cavalry spawn for Italy?

Show me that part in your script.
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
Robotron
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

Re: Tech crash

Post by Robotron »

I've had another idea: replace

function HasUnitTech

with this:

Code: Select all

function HasUnitTech(unit, techName)

	if unit.alive then
	  -- Check if unit has it
	  i = 1
	  while unit.luaData.unitTechs[i] ~= nil do
		-- Check if unit already has tech
		if unit.luaData.unitTechs[i] == techName then
		  return true
		end
		i = i + 1
	  end
	 
	end 

  return false
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: Tech crash

Post by Kossatx »

It works! :D How have you learned to mod lua files so fine? In my variant of Potzblitz MOD Italy neither begins with Cavalry Corps, but IA build them sometimes. I think IA takes in account many variables of units.lua file to decide which units to build.
Robotron
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

Re: Tech crash

Post by Robotron »

I've never ever seen the AI build a cavalry corps but great the solution worked for you.
That's all that matters.
:D
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
Post Reply

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