[MOD 0.?.x] ZTech - making research harder (or easier) Alpha

Topics and discussion about specific mods
hoho
Filter Inserter
Filter Inserter
Posts: 681
Joined: Sat Jan 18, 2014 11:23 am
Contact:

[MOD 0.?.x] ZTech - making research harder (or easier) Alpha

Post by hoho »

A couple of days ago in another thread there was a short discussion on how the need for lower-end research packs stays relatively static throughout the game meaning that one generally needs to have equal production of different science packs in order to not have too much idling. That also means that the lower-end research manufacturing generally doesn't have to be upgraded or expanded. From that I got the idea of increasing the amount of lower-end science packs depending on how many science packs a research needs. Today in a few hours of googling and coding Lua for the first time in my life this simple thingy was born :)

I'm not going to prepare a easy-to-use package today as it's a about 1:30a.m here but in the mean time you can have a look at the code here: https://github.com/hohounk/ZTech

Currently only one type of making-things-harder is implemented. Basically the amount of science packs is multiplied like this:

Code: Select all

# of types of packs in 
recipe:  1   2   3   4
Pack use multiplied by:
red:     1   2   4   8
green:  N/A  1   2   4
blue:   N/A N/A  1   2
alien:  N/A N/A N/A  1
The mod currently doesn't really handle any recipes that use anything but science packs or that have non-standard usage of thos packs but I do plan on making those work too. I also intend to give other options for changing how research recipes are modified. Obviously it'll be possible to change things like time per unit of research, total number of units, time per unit and offer other types of increases of the science packs.


[edit 20.07.2014]
Finally added the mod .zip to this post. No real changes since I originally made it, just removed some debug stuff from the code.
Attachments
ZTech.zip
ZTech 0.0.1
(1.03 KiB) Downloaded 213 times
Last edited by hoho on Sun Jul 20, 2014 12:23 pm, edited 2 times in total.
hoho
Filter Inserter
Filter Inserter
Posts: 681
Joined: Sat Jan 18, 2014 11:23 am
Contact:

Re: [alpha] ZTech - making research harder (or easier)

Post by hoho »

The name was chosen simply to have it load as late after other mods as possible. I did add DyTech as optional dependency to test a few things with mod loading order. The name isn't really something I like and if anyone has a bright idea for a decent name I wouldn't mind changing it :)

Also, the code itself is rather awful and will be rewritten several times for sure. It's my first ever Lua thing and my main goal was to get things working. Making things actually good will come Soon(tm)
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: [MOD 0.?.x] ZTech - making research harder (or easier) A

Post by FreeER »

Hm, looking at the git code I see one issue (wouldn't be a problem in base but with mods... maybe):
for science pack ones you are using multipliers[total] but you only have 4 multipliers so if the total number of ingredients was greater than 4 you'll get nil!, I'd suggest using local multipler = multipliers[total] or multipliers[#multipliers] or creating a function to return the multiplier based on the level of the science pack aka, function multipler(level) = return 2^(level-1) end where you can get the level via the below code.
A 'cleanup' might be replacing " if ((total-x) < 1) then"s with local level = tonumber(pack:sub(-1)) or 4 level = level-1(note level=level-1 is technically a different statement) and then using a single if statement for checking if total-level < 1.

I spent a few minutes trying to think of a way to 'simply' the code but I can't really think of one when I include possible mod science packs since there's no reliable way to know how expensive those science packs would be compared to the others (and thus what multiplier to use), especially if they were to be obtained through non-crafting methods. Unless the mod [authors] were to create a table within data for you to look at (I don't think 'odd' tables within data would cause issues since I imagine Factorio only loads the types it actually knows about, but i haven't tested), or you simply assigned non-base packs an arbitrary value. Of course if you are only modifying the base science-packs then the above should simplify it fairly well (and gets rid of the, to me, ugly if-elseifs aka switch statements lol)

aka I might have made it something like
this
hm... I probably spent far too much time thinking about this than it was worth since I don't particularly want my research to be harder (and so probably won't use this mod myself) :lol:

edit: apologies for 'green' code if it bothers anyone, I didn't really want to use the code tag because that inserts a line break (before and after) and the code was quite short
cartmen180
Filter Inserter
Filter Inserter
Posts: 358
Joined: Fri Jul 25, 2014 2:53 pm
Contact:

Re: [MOD 0.?.x] ZTech - making research harder (or easier) A

Post by cartmen180 »

does it work with multiple science packs yet? (more of the same type) and science without red packsrequirements like in dytech?
Check out my mods
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: [MOD 0.?.x] ZTech - making research harder (or easier) A

Post by FreeER »

cartmen180 wrote:science without red packsrequirements
Yes, at least if I recall correctly (and the glance I took prior to answering your question didn't mislead me) :)
cartmen180 wrote:does it work with multiple science packs yet? (more of the same type)
That will cause an error in the next version of Factorio (it lead to an underflow error in labs causing 4.3G science packs, so the devs are disallowing multiple science packs of the same type). see the bug report
hoho
Filter Inserter
Filter Inserter
Posts: 681
Joined: Sat Jan 18, 2014 11:23 am
Contact:

Re: [MOD 0.?.x] ZTech - making research harder (or easier) A

Post by hoho »

cartmen180 wrote:does it work with multiple science packs yet? (more of the same type)
As was said, this is a bug and devs decided to disable such recipes so I have no need to "fix" the bug :)
cartmen180 wrote:science without red packsrequirements like in dytech?
Technically it does work but not quite correctly and I believe Dysoch intends to fix those things.
If you have ideas how to increase the amount of science packs needed for researches like that I'd like to hear ideas. Missing red science packs entirely sort of messes up the calculations I use at the moment.

Perhaps I should simply look at the highest-end science pack that is used in recipe and derive multipliers from that?
Post Reply

Return to “Mods”