Advertisement
Civilization Fanatics' Center  

Welcome to Civilization Fanatics' Center.

You are currently viewing our site as a guest which gives you limited access to our site features. By joining our free community, you will be able to participate in the discussions, search the forum, send private messages, vote in polls, upload your own screenshots to the gallery, and access many other special features. Registration is fast, simple and absolutely free, so sign up today! If you have any problems with the registration process or your account login, please contact support.

Go Back   Civilization Fanatics' Forums > CIVILIZATION V > Civ5 - Creation & Customization > Civ5 - SDK / LUA

Notices

Reply
 
Thread Tools
Old Oct 05, 2010, 05:06 AM   #1
JANorton
Chieftain
 
Join Date: Oct 2010
Location: Albury, Australia
Posts: 11
[BUG & SOLUTION] Technology tree pipes not linking correctly when expanding the tree

Came across this bug when trying to add a new Tech to the game, basically the tech tree wouldn't connect some pipes correctly when they spanned more than 1 space along the x axis (see first screenshot).

I searched through the TechTree.lua file for the tech tree and found it was due to a typo by the original author, basically he forgot to add the xOffset to downward turning pipes when they were in conjuntion with upward or straight pipes.

To fix the pipe connection issue the following changes need to be made to the TechTree.lua file found in the Assets/InGame/UI/TechTree folder, first, find the section of the code in the below quote, its a fair way down (the file is too long to quote the entire thing) and add the changes highlighted in blue. The result of this Fix can be seen in the second screenshot.

Quote:
for pipeIndex, thisPipe in pairs(techPipes) do

local tech = GameInfo.Technologies[thisPipe.techType];

local yOffset = (tech.GridY-5)*blockSpacingY + 12 + extraYOffset;

if thisPipe.rightConnectionType >= 1 then

local startPipe = g_PipeManager:GetInstance();
startPipe.TechPipeIcon:SetOffsetVal( tech.GridX*blockSpacingX + blockSizeX + 64, yOffset );
startPipe.TechPipeIcon:SetTexture(right1Texture);
startPipe.TechPipeIcon:SetSize(connectorSize);

local pipe = g_PipeManager:GetInstance();
if thisPipe.rightConnectionType == 1 then
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX)*blockSpacingX + blockSizeX + 96, yOffset ); --original
pipe.TechPipeIcon:SetTexture(right1Texture);
elseif thisPipe.rightConnectionType == 2 then
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 12, yOffset - 15 );
pipe.TechPipeIcon:SetTexture(bottomRightTexture);
pipe.TechPipeIcon:SetTextureOffset(Vector2(72,72)) ;
elseif thisPipe.rightConnectionType == 3 then
--pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 6, yOffset - 15 );
--pipe.TechPipeIcon:SetTexture(right2BTexture);
--pipe.TechPipeIcon:SetTextureOffset(Vector2(36,72)) ;
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX)*blockSpacingX + blockSizeX + 96, yOffset );
pipe.TechPipeIcon:SetTexture(right1Texture);
pipe = g_PipeManager:GetInstance();
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 12, yOffset - 15 );
pipe.TechPipeIcon:SetTexture(bottomRightTexture);
pipe.TechPipeIcon:SetTextureOffset(Vector2(72,72)) ;
elseif thisPipe.rightConnectionType == 4 then
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 12, yOffset );
pipe.TechPipeIcon:SetTexture(topRightTexture);
pipe.TechPipeIcon:SetTextureOffset(Vector2(72,0));
elseif thisPipe.rightConnectionType == 5 then
--pipe.TechPipeIcon:SetOffsetVal( (tech.GridX)*blockSpacingX + blockSizeX + 96 - 6, yOffset );
--pipe.TechPipeIcon:SetTexture(right2TTexture);
--pipe.TechPipeIcon:SetTextureOffset(Vector2(36,0));
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX)*blockSpacingX + blockSizeX + 96, yOffset );
pipe.TechPipeIcon:SetTexture(right1Texture);
pipe = g_PipeManager:GetInstance();

-- Modified by Jeremy Norton 05/10/10
--pipe.TechPipeIcon:SetOffsetVal( (tech.GridX)*blockSpacingX + blockSizeX + 96 - 12, yOffset );
--pipe.TechPipeIcon:SetTexture(topRightTexture);
--pipe.TechPipeIcon:SetTextureOffset(Vector2(72,0));
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 12, yOffset );
pipe.TechPipeIcon:SetTexture(topRightTexture);
pipe.TechPipeIcon:SetTextureOffset(Vector2(72,0));
-- End of Changes


elseif thisPipe.rightConnectionType == 6 then
--pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 12, yOffset - 6 );
--pipe.TechPipeIcon:SetTexture(right2Texture);
--pipe.TechPipeIcon:SetTextureOffset(Vector2(72,36)) ;

-- Modified by Jeremy Norton 05/10/10
--pipe.TechPipeIcon:SetOffsetVal( (tech.GridX)*blockSpacingX + blockSizeX + 96 - 12, yOffset );
--pipe.TechPipeIcon:SetTexture(topRightTexture);
--pipe.TechPipeIcon:SetTextureOffset(Vector2(72,0));
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 12, yOffset );
pipe.TechPipeIcon:SetTexture(topRightTexture);
pipe.TechPipeIcon:SetTextureOffset(Vector2(72,0));
-- End of Changes


pipe = g_PipeManager:GetInstance();
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 12, yOffset - 15 );
pipe.TechPipeIcon:SetTexture(bottomRightTexture);
pipe.TechPipeIcon:SetTextureOffset(Vector2(72,72)) ;
else-- thisPipe.rightConnectionType == 7 then
--pipe.TechPipeIcon:SetOffsetVal( (tech.GridX)*blockSpacingX + blockSizeX + 96 - 6, yOffset - 6 );
--pipe.TechPipeIcon:SetTexture(right3Texture);
--pipe.TechPipeIcon:SetTextureOffset(Vector2(36,36)) ;
--pipe.TechPipeIcon:SetOffsetVal( (tech.GridX)*blockSpacingX + blockSizeX + 96, yOffset );
--pipe.TechPipeIcon:SetTexture(right1Texture);
--pipe = g_PipeManager:GetInstance();

-- Modified by Jeremy Norton 05/10/10
--pipe.TechPipeIcon:SetOffsetVal( (tech.GridX)*blockSpacingX + blockSizeX + 96 - 12, yOffset );
--pipe.TechPipeIcon:SetTexture(topRightTexture);
--pipe.TechPipeIcon:SetTextureOffset(Vector2(72,0));
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 12, yOffset );
pipe.TechPipeIcon:SetTexture(topRightTexture);
pipe.TechPipeIcon:SetTextureOffset(Vector2(72,0));
-- End of Changes


pipe = g_PipeManager:GetInstance();
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 12, yOffset - 15 );
pipe.TechPipeIcon:SetTexture(bottomRightTexture);
pipe.TechPipeIcon:SetTextureOffset(Vector2(72,72)) ;
end
end
Attached Thumbnails
Click image for larger version

Name:	techtree_bug.jpg
Views:	327
Size:	218.4 KB
ID:	267103   Click image for larger version

Name:	TechTree_Fixed.jpg
Views:	270
Size:	235.3 KB
ID:	267104  
JANorton is offline   Reply With Quote
Old Oct 05, 2010, 10:51 AM   #2
Kruelgor
Emperor
 
Kruelgor's Avatar
 
Join Date: May 2010
Location: The United States
Posts: 1,165
You're a genius.
Kruelgor is offline   Reply With Quote
Old Oct 05, 2010, 06:34 PM   #3
EmperorFool
Deity
 
EmperorFool's Avatar
 
Join Date: Mar 2007
Location: Mountain View, California
Posts: 9,624
First entry for the Unofficial Patch! Now, who's gonna run it?
__________________
Monkeys killing monkeys killing monkeys over pieces of the ground.
Silly monkeys, give them thumbs they make a club and beat their brother down.


BUG Mod - BTS Unaltered Gameplay
[ Forum | Download | FAQ | Known Issues | Troubleshooting | Modding Tutorial ]

BAT 3.0.1 QuickFix™ released Oct 24th
EmperorFool is offline   Reply With Quote
Old Oct 07, 2010, 01:38 AM   #4
Morlark
Warlord
 
Join Date: Aug 2009
Posts: 138
Nice catch. I've encountered a similar bug. In my case, the pipes are going too far, instead of not far enough. Unfortunately, I don't think the solution for this one is going to be quite so pretty. I'm completely new to this Lua malarkey, so I may be wrong (in fact I hope I am), but it seems to me that each tech can only have one xOffset value. This in turn means that a given tech can only lead to other techs that have the same GridX values as each other.

Curiously enough, there is one tech in the default techtree, Combustion, that does not conform to this rule. And, less curiously, the pipe that leads from said tech is one of the downward-hooked ones, of exactly the kind that your fix applies to. So it seems the bug is no mere typo by a forgetful author, it is in fact a dirty hack to stop the default techtree from breaking. (In fact I have just taken a look at the default techtree with this fix enabled, and Combustion does indeed break.) I have no idea why they didn't just shuffle a few of the techs along one column.

Anyway, I'm slightly digressing from my point. As you can see from my screenshot, my techtree has techs that lead to multiple different columns. Quite a few, in fact, and it'd be a right pain to try to reshuffle all of them all over the place. As I said, I'm new to Lua, so I've been scratching my head for a while, and I can't see any kind of elegant solution that would allow for techs to be arranged in this manner. I thought I'd ask to see if you, or anyone else, had any ideas.
Attached Thumbnails
Click image for larger version

Name:	Civ5Screen0000.jpg
Views:	141
Size:	217.5 KB
ID:	267427  
Morlark is offline   Reply With Quote
Old Oct 08, 2010, 02:01 AM   #5
JANorton
Chieftain
 
Join Date: Oct 2010
Location: Albury, Australia
Posts: 11
Quote:
Originally Posted by Morlark View Post
Nice catch. I've encountered a similar bug. In my case, the pipes are going too far, instead of not far enough. Unfortunately, I don't think the solution for this one is going to be quite so pretty. I'm completely new to this Lua malarkey, so I may be wrong (in fact I hope I am), but it seems to me that each tech can only have one xOffset value. This in turn means that a given tech can only lead to other techs that have the same GridX values as each other.

Curiously enough, there is one tech in the default techtree, Combustion, that does not conform to this rule. And, less curiously, the pipe that leads from said tech is one of the downward-hooked ones, of exactly the kind that your fix applies to. So it seems the bug is no mere typo by a forgetful author, it is in fact a dirty hack to stop the default techtree from breaking. (In fact I have just taken a look at the default techtree with this fix enabled, and Combustion does indeed break.) I have no idea why they didn't just shuffle a few of the techs along one column.

Anyway, I'm slightly digressing from my point. As you can see from my screenshot, my techtree has techs that lead to multiple different columns. Quite a few, in fact, and it'd be a right pain to try to reshuffle all of them all over the place. As I said, I'm new to Lua, so I've been scratching my head for a while, and I can't see any kind of elegant solution that would allow for techs to be arranged in this manner. I thought I'd ask to see if you, or anyone else, had any ideas.
You are absolutely right, there is only 1 xOffset attribute per pipe connection to and from each tech, which means a fair amount of re-coding would be required to solve your problem. Something along the lines of individualising and displaying each prereq -> tech connection rather than trying to do all the outbound pipes from just each tech in one go. Like you, i'm also new to lua and am only able to make small changes by looking at the code, figuring out what it does and then limited to just adjusting or copying code. So if anyone with sufficient lua experience would like to have a go at solving this it would be greatly appreciated.

For the mean time you could move all the techs above and above and to the right of the red square in your thumbnail to the right one tech spacing, this should at least make all the pipes connect correctly.

Hopefully firaxis addresses these tech tree pipe connection issues in a soon to come patch, if not I can see them becoming a stumbling block for modders trying to do more advanced things with the tech tree.
JANorton is offline   Reply With Quote
Old Oct 08, 2010, 04:55 AM   #6
blazekid87
Warlord
 
Join Date: Oct 2010
Location: NYC
Posts: 179
Thanks....needed that, kept having the same problems but I was too lazy to break down the code.
You're the man!!!
blazekid87 is offline   Reply With Quote
Old Oct 08, 2010, 08:57 AM   #7
Horem
Emperor
 
Join Date: Apr 2010
Posts: 1,002
Hi JANorton,

Anychance you can upload a copy of the TechTree.Lua with your changes already in it? I have tried to add in your changes, but I do not get any changed results.

or do I have to add an action for it to fire the new TechTree.Lua?
Horem is offline   Reply With Quote
Old Oct 08, 2010, 11:32 PM   #8
JANorton
Chieftain
 
Join Date: Oct 2010
Location: Albury, Australia
Posts: 11
Quote:
Originally Posted by Horem View Post
Hi JANorton,

Anychance you can upload a copy of the TechTree.Lua with your changes already in it? I have tried to add in your changes, but I do not get any changed results.

or do I have to add an action for it to fire the new TechTree.Lua?
No action required just simply have it included in your mods folder structure, see attached for the modified file.
Attached Files
File Type: zip TechTree.zip (5.3 KB, 46 views)
JANorton is offline   Reply With Quote
Old Oct 09, 2010, 05:09 AM   #9
Horem
Emperor
 
Join Date: Apr 2010
Posts: 1,002
TYVM! Much appreciated!
Horem is offline   Reply With Quote
Reply

Bookmarks

Go Back Civilization Fanatics' Forums > CIVILIZATION V > Civ5 - Creation & Customization > Civ5 - SDK / LUA > [BUG & SOLUTION] Technology tree pipes not linking correctly when expanding the tree

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Advertisement

All times are GMT -6. The time now is 03:06 AM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
This site is copyright © Civilization Fanatics' Center.
Support CFC: Amazon.com | Amazon UK | Amazon DE | Amazon CA | Amazon FR