Author Topic: Modding  (Read 895 times)

0 Members and 1 Guest are viewing this topic.

Offline Agm-114 (OP)

  • Pulsar 4x Dev
  • Registered
  • Chief Petty Officer
  • ***
  • Posts: 32
  • Thanked: 12 times
  • Discord Username: AGM-114#7218
Modding
« on: April 17, 2020, 02:30:03 PM »
Well I figure it's probably worth having a dedicated modding thread.
I'll append any mods people make to this post.
« Last Edit: April 23, 2020, 10:03:59 AM by Kyle »
 

Offline Agm-114 (OP)

  • Pulsar 4x Dev
  • Registered
  • Chief Petty Officer
  • ***
  • Posts: 32
  • Thanked: 12 times
  • Discord Username: AGM-114#7218
Re: Modding
« Reply #1 on: April 17, 2020, 02:41:10 PM »
So kyle, from past experience modding aurora, one of the main issues is that the game's database structure will make updating mods a bit difficult.

Let's take a hypothetical mod "Agm's trade good adjustment mod"



Which changes the req to produce to civ infrastructure to 25 million to make setting up a colony a bit tougher.
The issue is that installing this mod requires a DB swap so it can't be used with existing saves and can't be updated very easily to new DB versions.   

My suggestion would be to move read only data tables like Installations, materials, name themes, ranks, trade goods, etc to a separate DB.
I'm not sure if that's viable but it'd def be super helpful.
 

Offline MasonMac

  • Warrant Officer, Class 1
  • *****
  • M
  • Posts: 77
  • Thanked: 22 times
Re: Modding
« Reply #2 on: April 17, 2020, 02:58:13 PM »
Why not run a script that transfers the old saves to the new db?
 

Offline Agm-114 (OP)

  • Pulsar 4x Dev
  • Registered
  • Chief Petty Officer
  • ***
  • Posts: 32
  • Thanked: 12 times
  • Discord Username: AGM-114#7218
Re: Modding
« Reply #3 on: April 17, 2020, 03:47:59 PM »
Yeah if it comes, and kyle's ok with it I'll probably release a script. However that's a bit of a hacky solution that I'd like to avoid if  possible.
 

Offline Kyle

  • Moderator
  • Lt. Commander
  • *****
  • K
  • Posts: 297
  • Thanked: 745 times
  • Quasar4x dev
Re: Modding
« Reply #4 on: April 17, 2020, 07:57:06 PM »
Two databases is a good idea but there a few read-only-but-not-really tables that muddy up the waters on the idea of multiple db's.  Pretty relevant tables too, such as TechSystem: (this may also be a reason against it happening on C# by the way)



Any new research project you create gets added here but this also contains vanilla stuff like fuel tanks.

I strongly advise not to write a script that migrates an existing game into a new db.  That's a lot of work and would be incredibly easy to mess up and would cause all kinds of very-very-nasty bugs.  I also don't recommend providing a drop-in db, because the database gets updated fairly regularly as I add more helper columns and tables.  Instead, put a database modification script in your on_program_load file.  It would be pretty simple.  Say you wanted to remove the Trans-Newtonian Tech requirement on Flag Bridge.  You could have the following in your on_program_load function:

update TechSystem set Prerequisite2 = 0 where TechSystemID = 225 and Prerequisite2 = 27434

The "Prerequisite2 = 27434" section nicely skips the update if some other mod has already messed with that field or a future database version has fiddled with it.  Doing it this way ensures that your mod is still active even after future database updates.  If, for arguments sake, the entire Prerequisite2 column got deleted (it wont) making your mod no longer compatible, then the SQL would harmlessly fail.  Bad SQL fails silently, it doesn't crash.

You would just have to give the user a caveat that your mod is permanent and if they want to revert the change they'll have to redownload the database file.  (Which is the same amount of work that would be required for the database-dropin approach anyway.)
 

Offline Agm-114 (OP)

  • Pulsar 4x Dev
  • Registered
  • Chief Petty Officer
  • ***
  • Posts: 32
  • Thanked: 12 times
  • Discord Username: AGM-114#7218
Re: Modding
« Reply #5 on: April 17, 2020, 08:12:19 PM »
Thanks kyle!

On the front of tech systems would it be possible to split it into two separate tables?
« Last Edit: April 17, 2020, 08:15:52 PM by Agm-114 »
 

Offline Kyle

  • Moderator
  • Lt. Commander
  • *****
  • K
  • Posts: 297
  • Thanked: 745 times
  • Quasar4x dev
Re: Modding
« Reply #6 on: April 17, 2020, 08:27:03 PM »
*You* can if you want.  It's pretty trivial, just rename the existing TechSystem table, then create a view with the name TechSystem that pulls from two tables unioned together.  *I'm* not going to do that though :)  My philosophy has been to touch the schema as little as possible and it's served me well.
 

Offline Agm-114 (OP)

  • Pulsar 4x Dev
  • Registered
  • Chief Petty Officer
  • ***
  • Posts: 32
  • Thanked: 12 times
  • Discord Username: AGM-114#7218
Re: Modding
« Reply #7 on: April 17, 2020, 08:28:03 PM »
Gotcha

Edit: Forms are weird I send gotcha and it takes up like half my screen lmao.
« Last Edit: April 17, 2020, 08:35:59 PM by Agm-114 »
 

Offline Warer

  • Chief Petty Officer
  • ***
  • W
  • Posts: 41
  • Thanked: 16 times
Re: Modding
« Reply #8 on: November 19, 2020, 11:31:20 AM »
How do i mod Q4x? What tools are needed if any and things like that?
 

 

Sitemap 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74