Adding New Techs

Starrynite120

Prince
Joined
Jul 15, 2015
Messages
472
How do you add new technologies to the game? I'm getting a repeated lua error with this below code and the game won't load. I do want it to be a leaf tech.

Code:
	<Technologies>
		<Row>
			<Type>TECH_ENGINEERING_2</Type>
			<Cost>75</Cost>
			<LeafTech>true</LeafTech>
			<Description>TXT_KEY_TECH_ENGINEERING_2</Description>
			<Civilopedia>TXT_KEY_TECH_ENGINEERING_2_DESC</Civilopedia>
			<Help>TXT_KEY_TECH_ENGINEERING_2_HELP</Help>
			<Quote>TXT_KEY_TECH_ENGINEERING_2_QUOTE</Quote>
			<IconAtlas>TECH_ATLAS_1</IconAtlas>
			<PortraitIndex>12</PortraitIndex>
			<AudioIntroHeader>AS2D_HEADING_TECH_ENGINEERING_2</AudioIntroHeader>
		</Row>
	</Technologies>

	<Technology_Connections>
		<Row>
			<FirstTech>TECH_ENGINEERING</FirstTech>
			<SecondTech>TECH_ENGINEERING_2</SecondTech>
		</Row>
	</Technology_Connections>
 
Leaftech-Connections require the LeafTech to be indexed in the "FirstTech"-row.
 
Yeah, not quite intuitive. Took me a while to figure out as well, it's just the way they coded the tech web.
 
So I tried what you said and I still got the error. I should mention that I have redesigned the entire tech web. Perhaps that's causing the problem?
 
I notice you've set the AudioIntroHeader as AS2D_HEADING_TECH_ENGINEERING_2, which, unless you've created it yourself in the <Script2DSounds> table, doesn't exist.

You can safely leave AudioIntroHeader blank (if you don't want any voiceover to be played), or use the same value as an existing tech (if you want to re-use an existing voiceover), but referencing a voiceover that doesn't exist may cause errors.
 
Go into the Lua.Log and see at which line the tech web errors out.
 
This is the error message I'm getting:

Code:
 Runtime Error: Assets\DLC\Expansion1\UI\InGame\TechTree\TechTree.lua:459: attempt to index a nil value
stack traceback:
	Assets\DLC\Expansion1\UI\InGame\TechTree\TechTree.lua:459: in function 'AddTechNode'
	Assets\DLC\Expansion1\UI\InGame\TechTree\TechTree.lua:1357: in function 'OnGivenTimeSliceRemotely'
	[C]: in function 'func'
	[C]: in function 'lMetaCall'
	Assets\DLC\Expansion1\UI\FrontEnd\LoadScreen.lua:390: in function 'OnUpdate_TechTree'
 
Which would be this part:
Code:
function AddTechNode( tech )

	-- Build node type based on if this is a "full" node or a leaf node.
	local thisTechButtonInstance;
	[B]if (tech.LeafTech) then[/B]
[...]

Given that that function is being called directly after looping through the Tech-Table my assumption would be that you've deleted technologies without fixing the technology IDs. If that's correct see this thread for a solution: http://forums.civfanatics.com/showthread.php?t=463429
 
I don't think I've deleted any technologies. I've given these delete commands

Code:
DELETE FROM Technology_Affinities;
DELETE FROM Technology_Flavors;
DELETE FROM Technology_FreePromotions;
DELETE FROM Technology_FreePlayerPerks;
DELETE FROM Technology_Connections;
DELETE FROM Improvement_TechYieldChanges;

but then I reset them. I have rearranged the entire tech web, and I do have some technologies that I moved to gridradius 10 and set no connections to them, idk if that would be causing any problem.
 
That should only cause problems if you forgot to set LeafTech=false
 
I have set the leaftech = false on those. I have no problems regarding technologies until I try and add new ones.
 
So I changed my new tech to a branch tech and now it works. I can just switch it out for other techs for a solution. Thanks for your advice everyone!
 
In your original XML did you add in "GridRadius and GridDegrees"?

When creating a new custom Base Tech you have to tell it where to place it on your Tech Web, The GridRadius and GridDegrees tells the game where to put your new Base Tech, here is one I Created: The one thing to watch for is overcrowding :) you may have to modify where an original Tech is positioned you can do that by using the Update function in your XML, look below for my implementations.

Code:
<Technologies>
    <Row>
        <Type>TECH_ARMAMENTS</Type>
        <Cost>280</Cost>
        <GridRadius>1.05</GridRadius>
        <GridDegrees>183</GridDegrees>
        <Description>TXT_KEY_TECH_ARMAMENTS_DESC</Description>
        <Civilopedia>TXT_KEY_TECH_ARMAMENTS_PEDIA</Civilopedia>
        <Help>TXT_KEY_TECH_ARMAMENTS_HELP</Help>
        <Quote>TXT_KEY_TECH_ARMAMENTS_QUOTE</Quote>
        <IconAtlas>AF_TECHNOLOGY_ICON</IconAtlas><!-- TECH_ATLAS_1-->
        <PortraitIndex>0</PortraitIndex>
        <AudioIntro>AS2D_TECH_HABITATION</AudioIntro>
        <AudioIntroHeader>AS2D_HEADING_TECH_HABITATION</AudioIntroHeader>
        <UnitBaseMiasmaHeal>3</UnitBaseMiasmaHeal>
    </Row>
</Technologies>

Then Also in the Technologies section add a first Leaf to it you do it like this:

Code:
<Row>
    <Type>TECH_MOBILE_ARMAMENTS</Type>
    <Cost>360</Cost>
    <LeafTech>true</LeafTech>
    <Description>TXT_KEY_TECH_MOBILE_ARMAMENTS_DESC</Description>
    <Civilopedia>TXT_KEY_TECH_MOBILE_ARMAMENTS_PEDIA</Civilopedia>
    <Help>TXT_KEY_TECH_MOBILE_ARMAMENTS_HELP</Help>
    <Quote>TXT_KEY_TECH_MOBILE_ARMAMENTS_QUOTE</Quote>
    <IconAtlas>AF_TECHNOLOGY_ICON</IconAtlas>
    <!-- TECH_ATLAS_1-->
    <PortraitIndex>0</PortraitIndex>
    <AudioIntro>AS2D_TECH_HABITATION</AudioIntro>
    <AudioIntroHeader>AS2D_HEADING_TECH_HABITATION</AudioIntroHeader>
</Row>

Then you have to Connect your base Tech to an existing Tech near where your placing your custom one, My TECH_ARMAMENTS connects to the original TECH_ENGINEERING Tech, my TECH_MOBILE_ARMAMENTS then connects to my Base TECH_ARMAMENTS. I actually have a second leaf but I left it out of this explanation.

Code:
<Technology_Connections>
    <Row>
        <FirstTech>TECH_ENGINEERING</FirstTech>
        <SecondTech>TECH_ARMAMENTS</SecondTech>
    </Row>
    <Row>
        <FirstTech>TECH_MOBILE_ARMAMENTS</FirstTech>
        <SecondTech>TECH_ARMAMENTS</SecondTech>
    </Row>
</Technology_Connections>

Code:
    <Technologies>
        <!-- Moves the below Tech Branches to make room for my custom Tech Branch Armaments-->
        <Update>
            <Where Type="TECH_PHYSICS"></Where>
            <Set GridDegrees="220" GridRadius="1.10"/>
        </Update>
        <Update>
            <Where Type="TECH_ENGINEERING"/>
            <Set GridDegrees="135" GridRadius="1.20"/>
        </Update>
    </Technologies>

Hope this helps.

Edit: If you want to add a building to your Tech Leaf you only have to add one line to your Building Xml.

Code:
<Buildings>
    <!-- Special Buildings -->
    <Row>
        <Type>BUILDING_FRANKSPIZZA</Type>
        <BuildingClass>BUILDINGCLASS_FRANKSPIZZA</BuildingClass>
        <Description>TXT_KEY_BUILDING_FRANKSPIZZA_DESC</Description>
        <Civilopedia>TXT_KEY_BUILDING_FRANKSPIZZA_PEDIA</Civilopedia>
        <Help>TXT_KEY_BUILDING_FRANKSPIZZA_HELP</Help>
        <!-- [COLOR="Red"]PrereqTech is what adds it to your Custom Tech[/COLOR] -->
        <PrereqTech>TECH_ARMAMENTS</PrereqTech>
        <Cost>240</Cost>
        <ConquestProbability>67</ConquestProbability>
        <HurryCostModifier>-1</HurryCostModifier>
        <!-- This should be a float value. 1000 is actually 10.00 -->
        <Defense>500</Defense>
        <IconAtlas>AF_BUILDINGS_ATLAS</IconAtlas>
        <PortraitIndex>3</PortraitIndex>
        <Health>1</Health>
    </Row>
</Buildings>
 
Top Bottom