tech tree (modding/adding techs)

General Stars in Shadow Discussion Forum
User avatar
siyoa
Posts: 182
Joined: Fri Apr 21, 2017 3:19 pm

tech tree (modding/adding techs)

Post by siyoa »

adding new techs is quite easy, and they show in regular view no problem

tech tree view is quite a different matter, I have a few end game techs added and tech tree not showing them didn't bother me much ... but now I am thinking to add some more techs in the middle of tech pool and I was looking into the code for tech tree to see how difficult it is to add them there ... it seems that tech tree is quite hardcoded at the moment and not modding friendly

are you guys planning to rewamp tech tree for easier modding ? and meanwhile, can you, please, provide a quick crash course on tech tree modding (in its current form) ? I may try to figure out the code if I have enough time, but any help that speeds it up is much appreciated ;)
How did YOU get a key? All right, go in.
User avatar
sven
Site Admin
Posts: 1621
Joined: Sat Jan 31, 2015 10:24 pm
Location: British Columbia, Canada
Contact:

Re: tech tree (modding/adding techs)

Post by sven »

siyoa wrote:adding new techs is quite easy, and they show in regular view no problem

tech tree view is quite a different matter,

are you guys planning to rewamp tech tree for easier modding ? and meanwhile, can you, please, provide a quick crash course on tech tree modding (in its current form) ?
It should actually be pretty easy to mod as is. The core thing you need to know is that the big "master_columns" list in tech_tree_settings.lua determines where in the columns of the tree any tech shows up. Techs that don't appear in that list are just not shown in the tree. But, if you add the name of your newly created techs to master_columns -- they should show up.

(There's a lot of other fanciness involved with the way the tech tree is laid out, and tricky things that one can do to try an make the lines going in and out of a particular tech look better -- I'd recommend ignoring that stuff as a modder. But, skimming the code at the top of tech_tree_settings.lua will give you a glimpse into that rabbit hole.)
User avatar
siyoa
Posts: 182
Joined: Fri Apr 21, 2017 3:19 pm

Re: tech tree (modding/adding techs)

Post by siyoa »

hmm, apparently I was doing something wrong then, as I added new tech to "master_columns" and it didn't want to show up ... I was able to remove existing tech from there though ... will try tonight again :)

it seems that tech tree doesn't change on the fly as you edit tech_tree_settings.lua, new game is needed everytime, maybe I just didn't save files properly ... at the end I had to validate my steam files as I couldn't remember anymore what I changed :mrgreen:
How did YOU get a key? All right, go in.
User avatar
sven
Site Admin
Posts: 1621
Joined: Sat Jan 31, 2015 10:24 pm
Location: British Columbia, Canada
Contact:

Re: tech tree (modding/adding techs)

Post by sven »

siyoa wrote:it seems that tech tree doesn't change on the fly as you edit tech_tree_settings.lua, new game is needed everytime, maybe I just didn't save files properly ... at the end I had to validate my steam files as I couldn't remember anymore what I changed :mrgreen:
Yeah -- tech_tree_settings.lua doesn't support live-coding as well as it could. That's something that's actually been bothering me as well. I've just taken a few minutes to see about improving things here -- as of r22104 (currently on the in_development steam branch), edits made to tech_tree_settings.lua should be reflected immediately in the tech tree screen.
User avatar
siyoa
Posts: 182
Joined: Fri Apr 21, 2017 3:19 pm

Re: tech tree (modding/adding techs)

Post by siyoa »

sven wrote:I've just taken a few minutes to see about improving things here -- as of r22104 (currently on the in_development steam branch), edits made to tech_tree_settings.lua should be reflected immediately in the tech tree screen.
fantastic, thanks :D
How did YOU get a key? All right, go in.
User avatar
siyoa
Posts: 182
Joined: Fri Apr 21, 2017 3:19 pm

Re: tech tree (modding/adding techs)

Post by siyoa »

so, indeed it works (Beam Mods and Force Beams 2 in the picture), not sure what I was doing before :oops: definitely something incorrect

now, there seems to be some memory leak in latest dev version, anytime I edit tech_tree_settings.lua when live-coding
Attachments
tech_tree.jpg
tech_tree.jpg (377.21 KiB) Viewed 15158 times
How did YOU get a key? All right, go in.
User avatar
sven
Site Admin
Posts: 1621
Joined: Sat Jan 31, 2015 10:24 pm
Location: British Columbia, Canada
Contact:

Re: tech tree (modding/adding techs)

Post by sven »

siyoa wrote:now, there seems to be some memory leak in latest dev version, anytime I edit tech_tree_settings.lua when live-coding
hrm. have you been experimenting with any of the other stuff in tech_tree_settings.lua (besides the master_columns entries)?

under the hood -- the tech tree layout involves an optimization step -- and if that optimization is in some way impossible, it may lead to strange behaviors (including, i think, out of memory errors). creating impossible optimization problems can be pretty easy to do accidentally, if you're playing with, say, the iq_constraints table.
User avatar
siyoa
Posts: 182
Joined: Fri Apr 21, 2017 3:19 pm

Re: tech tree (modding/adding techs)

Post by siyoa »

sven wrote:hrm. have you been experimenting with any of the other stuff in tech_tree_settings.lua (besides the master_columns entries)?
nope, master_columns only ... for now ;)

is it GPU or system memory ? I only have 2GB of GPU memory

EDIT: interesting, I tried to repeat it, but I don't get error anymore, it still takes a second or 2 to switch to SiS application from text editor anytime I add/remove entry in master_columns (it still tries to process a lot of data) ... normally it switches between applications immediately
How did YOU get a key? All right, go in.
User avatar
siyoa
Posts: 182
Joined: Fri Apr 21, 2017 3:19 pm

Re: tech tree (modding/adding techs)

Post by siyoa »

hmmm, this is what I meant by tech tree being hardcoded 2 days ago ... I run into similar thing then

I get an error as per the picture if I put my new tech to this section of master_columns (Beam Mods after Primary Beams)

Code: Select all

  {

    "Antimatter Torpedoes",


		"Warp Node Dynamics",
    "Hadron Cohesion",
    "Warp Lane Stabilizers",


    "Plasma Projectiles",




    "Primary Beams",
     "Beam Mods",

    "Zero-Point Energy",


    "Adaptive Energy Grid",	
   "Adamantium Construction",	


    "Dreadnoughts",	

    "Quantum Decryption",	

    "Starfighters",
    "Civil Fortifications",

    "Hidden Bases",

    "Weather Control",
    "Atmospheric Condensation",	
  },
Attachments
tech_tree_3.jpg
tech_tree_3.jpg (92.2 KiB) Viewed 15147 times
Last edited by siyoa on Fri Mar 30, 2018 6:35 am, edited 3 times in total.
How did YOU get a key? All right, go in.
User avatar
siyoa
Posts: 182
Joined: Fri Apr 21, 2017 3:19 pm

Re: tech tree (modding/adding techs)

Post by siyoa »

if I put it here, all is fine

Beam Mods after Advanced Turbolasers

Code: Select all

{

        "Antimatter Warheads",

    "Railguns",
		"Pulse Generators",
		"Warp Node Attunement",
    "Graviton Physics",

    "Neutron Beams",
    "Stupendous Energy Physics",
    "Plasma Focusing",
  "Disruptors",
  

    "Advanced Turbolasers",
	"Beam Mods",

	    "Subspace Networking",
	    "Improved Solar Panels",
			"Arda Fabrication Techniques",

    "Battlecruiser",
    "Carriers",		
	
	
    "Multirole Fighters",		
	
    "Battle Mechs",
    "Hardened Bunkers",
    "Interspecies Law",

    "Cloning",
    "Synthetic Foodstuffs",
    "Habitat Domes",
	
	
  },
Attachments
tech_tree_2.jpg
tech_tree_2.jpg (132.87 KiB) Viewed 15147 times
How did YOU get a key? All right, go in.
User avatar
sven
Site Admin
Posts: 1621
Joined: Sat Jan 31, 2015 10:24 pm
Location: British Columbia, Canada
Contact:

Re: tech tree (modding/adding techs)

Post by sven »

siyoa wrote:hmmm, this is what I meant by tech tree being hardcoded 2 days ago ... I run into similar thing then

I get an error as per the picture if I put my new tech to this section of master_columns (Beam Mods after Primary Beams)
Hmm... Yes, the OR node rendering logic is a bit brittle. I don't recall exactly /why/ that particular error would show up, but, I do vaguely remember deciding that some cases in the tech tree layout code were rare enough that I figured I could get away with just not handling them properly. (Meanwhile, the handful of cases in the tech tree that do involve visualizing relatively complex <OR> joins do have custom, special case handling code in tech_tree_edges.lua.)

My own experience with adding new techs has been that as long as I pick a column position that sortof looks like the tech ought to fit there -- it usually does fit without issues. Clearly though, your mileage hasn't been quite as good.

How many new techs are you trying to add to the tree?
User avatar
sven
Site Admin
Posts: 1621
Joined: Sat Jan 31, 2015 10:24 pm
Location: British Columbia, Canada
Contact:

Re: tech tree (modding/adding techs)

Post by sven »

siyoa wrote:if I put it here, all is fine
Hrm, it looks like, in this rendering, there are no visible edges between Beam Mods and anything else. If the edges going into Beam Mods are, for some reason, triggering a case I haven't handled in the rendering code, you could try adding custom code to info.hide_edge to just hide all lines going into Beam Mods, i.e.:

Code: Select all

	if tech=='Beam Mods' return true end
Then, in theory, you ought to be able to put the tech in any column without issues. (Though no lines would show up.)
User avatar
sven
Site Admin
Posts: 1621
Joined: Sat Jan 31, 2015 10:24 pm
Location: British Columbia, Canada
Contact:

Re: tech tree (modding/adding techs)

Post by sven »

siyoa wrote:is it GPU or system memory ? I only have 2GB of GPU memory
Should be system. So, it should take a *serious* memory leak to trigger that warning. (Probably some kind of infinite loop in my edge-placement code.)
siyoa wrote: EDIT: interesting, I tried to repeat it, but I don't get error anymore, it still takes a second or 2 to switch to SiS application from text editor anytime I add/remove entry in master_columns (it still tries to process a lot of data) ... normally it switches between applications immediately
This doesn't surprise me. The optimization and edge layout steps that go into tech tree rendering are slow -- 2 seconds doesn't sound that far off what I'd expect.
User avatar
siyoa
Posts: 182
Joined: Fri Apr 21, 2017 3:19 pm

Re: tech tree (modding/adding techs)

Post by siyoa »

sven wrote:Should be system. So, it should take a *serious* memory leak to trigger that warning. (Probably some kind of infinite loop in my edge-placement code.)
must be, that laptop has 12GB of RAM :shock:
sven wrote:How many new techs are you trying to add to the tree?
not that many at the moment, but eventually I can end up with 20+
sven wrote:Then, in theory, you ought to be able to put the tech in any column without issues. (Though no lines would show up.)
will try this one for sure ... now, I understand that tech tree should really be visual representation of dependencies between technology advancements ... I personally don't care about the lines as much, but than why to have tech tree, right ?

I just think that the current model is hampering modding to a bigger extend than, maybe, it should ? you assign techs into fields, so main dependencies should be within this field and only very occasionally other field affects it ... so maybe, what if you show only dependencies within the field by lines and anything coming from other field would be represented by that little icon in top left corner ? all that fancy OR stuff would be lost, but this may enable you to code tech tree really flexible, so much less would be hardcoded and much more would be automatically generated, so adding a tech would be really just a simple entry ?

EDIT: please, don't take this as a criticism, more like positive feedback (although I am not sure how much it is worth it, from someone who is not fluent in lua code that much :?: ), for a small team of two, you guys are doing amazing work already :idea:
How did YOU get a key? All right, go in.
User avatar
sven
Site Admin
Posts: 1621
Joined: Sat Jan 31, 2015 10:24 pm
Location: British Columbia, Canada
Contact:

Re: tech tree (modding/adding techs)

Post by sven »

siyoa wrote: I just think that the current model is hampering modding to a bigger extend than, maybe, it should ? you assign techs into fields, so main dependencies should be within this field and only very occasionally other field affects it ... so maybe, what if you show only dependencies within the field by lines and anything coming from other field would be represented by that little icon in top left corner?
This is actually already being done -- by default, only lines between techs in the same field will be rendered.
siyoa wrote: all that fancy OR stuff would be lost, but this may enable you to code tech tree really flexible, so much less would be hardcoded and much more would be automatically generated, so adding a tech would be really just a simple entry ?
The core problem, I think, is that if a modder creates a tech with an OR prereq, as you did, adding it to the tree is currently hard -- because OR prereqs are buggy without special purpose edge-handling code. Tweaking the tech_tree_edges.lua code a bit so that new OR prereqs just aren't rendered at all (rather than trying, and often failing, to render them in some fancy way) is probably the solution here that would be most useful for modders. But... I make no promises on when I might get around to writing that up. For now, I'd suggest you just try hiding OR preq lines by adding special cases to info.hide_edge, and then let me know if you run into any other problems.
Post Reply