Big Menz's Research Pack


This mod adds general researches that benefit the play. List includes: Player Craft Speed, Player Mine Speed, Extended Reach, Inventory Slots, Health, Running Speed, Number of Quickbars, Research Speed & Research Productivity

Overhaul
6 years ago
0.14 - 0.16
113

b Bonuses no longer applicable

7 years ago

Running this mod on a multiplayer server, with several others. It's been working fine for a few days, but suddenly today, none of the bonuses from research seem to be in effect. Most noticeably, crafting speed and movement speed have gone back to normal. The mod, otherwise, seems to be functioning normally. I can see all the researches we have completed, and have yet to complete, in the research menu.

Any ideas, or additional information I can provide?

6 years ago

I haven't been able to reproduce this one. If you can give me further info on how/when it happened I'll give it a shot to produce a fix.

6 years ago

I have been able to reproduce this one and I know the cause.

I've been trying out this mod today and I've noticed that every time I load the game, none of the effects are in effect...

So I delved into the code, and in the control.lua file it had:

script.on_event(defines.events.on_research_finished, function(event) 
local research = event.research
local force = research.force
local name = research.name

if name == "basiccraftspeed-1" then force.manual_crafting_speed_modifier = force.manual_crafting_speed_modifier+0.1 end
if name == "basiccraftspeed-2" then force.manual_crafting_speed_modifier = force.manual_crafting_speed_modifier+0.1 end
...

This... is entirely wrong, specifically it is modifying the force values directly. You should be using research effects.

First let me explain why this is wrong. By modifying the effects directly then any time any mod configuration is changed (a mod setting changed, a mod updated, a mod added/removed, as I've been doing today to test mods and gameplay for my server) and that mod does anything to research effects (specifically calling reset_technology_effects, as quite a few mods do to resynch research), then any custom changes to the effects are wiped out and resynched back with research effects.

Second, to explain why research effects should be used. As you see right now a research has a description, but it has no little squares saying exactly what it does, where if you look at, say, an inserter stack upgrade you see the little square (with the vanilla plus icon) saying that it performs an effect, specifically it adjusts the inserter stack capacity by +1. Those kind of effects would work for any adjustable effect. Thus by using research effects you will get those little squares saying what happens. Second, and the big reason, any time the research effects are resynched then everything will 'just work' without suddenly vanishing.

I 'think' everything this mod does is usable in that way, if it is not then you can continue your current style, except instead of setting the effect straight, you should also record what your current effect modification is in your global storage, then on every 'configuration change' hook (and I think one other but I cannot recall off hand, you need to be very careful about this part) then apply those effects again but be careful as those callbacks can be called back multiple times (so you'd probably want to set a 'dirty' flag on your global store and apply the modifications again on the next game tick). However this method also breaks if absolutely no mod calls reset_technology_effects on a configuration change (and whatever that other hook is...), so if you need to go this route then I'd say you yourself call reset_technology_effects on configuration change, on game load, on new game, on basically every time where it really makes sense, then set your dirty flag and apply the updates on the next game tick (never change effects in the same tick that reset_technology_effects is run because another mod will likely be doing it in the same tick after you too, thus resetting your work), and even then there are still corner cases where your current method will not work even after all these fixes, such as if it is called out-of-band (like reset_technology_effects being called during normal gameplay, like if an admin calls it or so).

6 years ago

This site is so broken... >.>

Just... copy/paste the above post into a text editor or something to read it, what on earth happened there... >.>

TL;DR though: Calling force.<some_effect> = <whatever> is almost always the wrong thing to do and will inevitably break.

6 years ago

Here are the modifiers you can do in a research modification effect:
http://lua-api.factorio.com/latest/Concepts.html#Modifier

It looks like all the modifiers this mod makes research for is indeed supported in that list.

The research prototype is, mostly, detailed at: https://wiki.factorio.com/Prototype/Technology

Or just look at the vanilla upgrades, say how the toolbelt is upgraded or how inserter stack size's increase in size, those are all done the same way except you'd replace the modifier name with one of the ones in that above modifier list, copied here:
"inserter-stack-size-bonus", "stack-inserter-capacity-bonus", "laboratory-speed", "character-logistic-slots", "character-logistic-trash-slots", "quick-bars-count", "maximum-following-robots-count", "worker-robot-speed", "worker-robot-storage", "ghost-time-to-live", "turret-attack", "ammo-damage", "give-item", "gun-speed", "unlock-recipe", "character-crafting-speed", "character-mining-speed", "character-running-speed", "character-build-distance", "character-item-drop-distance", "character-reach-distance", "character-resource-reach-distance", "character-item-pickup-distance", "character-loot-pickup-distance", "character-inventory-slots-bonus", "deconstruction-time-to-live", "character-health-bonus", "auto-character-logistic-trash-slots", "mining-drill-productivity-bonus", "train-braking-force-bonus", "zoom-to-world-enabled", "zoom-to-world-ghost-building-enabled", "zoom-to-world-blueprint-enabled", "zoom-to-world-deconstruction-planner-enabled", "zoom-to-world-selection-tool-enabled", "worker-robot-battery", "laboratory-productivity", "follower-robot-lifetime", "nothing",

New response