How to detect new techs?

Thalassicus

Bytes and Nibblers
Joined
Nov 9, 2005
Messages
11,057
Location
Texas
What's a reliable way to detect new techs?

I tried TechAcquired, but calling functions within that event crashes scenario maps when it reaches citystates. I can't figure out a way to omit citystates without calling a function. :think:

PHP:
function NewTech(playerID, techID)    
    local player = Players[playerID]
    print(tostring(playerID) .. " " .. tostring(techID))
    print(tostring(player.GetName))
    print(tostring(player:GetName()))
end
Events.TechAcquired.Add(NewTech)
Code:
8 1
function: 135F82B0
Napoleon

9 1
function: 135F82B0
(crash)
 
you mean IsAlive, IsMinor, etc are all crashing there ?

what about playerID > GameDefines.MAX_MAJOR_CIVS (or >=, I don't remember with index at 0 :o )
 
The only usage of Events.TechAcquired doesn't pass parameters, so I'd guess that the parameter list is wrong.

Techs are generally known by Teams, not Players, so I'd guess that the parameters should be (teamID, techID), not that it should make a difference

Try using

Code:
function OnTeamTechResearched (eTeam, eTech, iChange) 
end;
GameEvents.TeamTechResearched.Add(OnTeamTechResearched);

See TurnsRemaining.lua in DLC 2 (Spain) and 3 (Polynesia) scenarios
 
What's a reliable way to detect new techs?

I tried TechAcquired, but calling functions within that event crashes scenario maps when it reaches citystates. I can't figure out a way to omit citystates without calling a function. :think:

PHP:
function NewTech(playerID, techID)    
    local player = Players[playerID]
    print(tostring(playerID) .. " " .. tostring(techID))
    print(tostring(player.GetName))
    print(tostring(player:GetName()))
end
Events.TechAcquired.Add(NewTech)
Code:
8 1
function: 135F82B0
Napoleon

9 1
function: 135F82B0
(crash)
Detect a tech may come 1st thanks for the help!
 
Back
Top Bottom