[MOD 0.16.x] Whistle Stop Factories

Topics and discussion about specific mods
Avacado
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Fri Jul 22, 2016 3:17 pm
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by Avacado »

I was wondering if you had any plans to allow players to build their own large factories, much like DellAquila's The Big Furnace or Circuit Factory? I think it would make for a very interesting alternative path for mass production, particularly if big factories are tiered around the complexity of the output product - a Big Factory 1, for example, researched with a lot of red science, could create only basic items in bulk (iron gear wheels, iron sticks, copper cable, landfill, pipe, etc), whereas a Big Factory 3 might need a lot of blue science and can assemble electric engines, refined concrete, more blue science, electric furnaces... you see where I'm going here. It would shift the focus from designing a factory to actually supplying the factory (with resources and power), providing a different sort of challenge.
@deemacgee, my plan is to create a completely separate mod, because my mod is suppose to be all about trains, and that would ruin the theme a bit, though it is a common enough request that I'll work on making it, so yes, I do have plans to make a second mod that would allow the same buildings to be built including the refinery and chemical plant.
Do you support deadlocks compact loaders?
@mrvn, When I load my mod with some mods (like 5 dim) it changes the looks of the default loaders, so the looks of my loaders change. It would be a bit of rework to get 1x1 loaders to place in the right positions, so I have no plans for my buildings to start using those. But in my current development branch, the loaders will support faster belt speeds by taking whatever the fastest belt or loader in the game is and using that (though it will still visually appear like a default express-loader, or different when mods change the look of the default loader). I'm worried about trying to take visuals from other loaders, which would have the advantage of making it be the same color as the fastest belt, but I don't want to deal with the issues created by potentially accidentally taking visuals from other kinds of loaders such as the 1x1 loader.
Avacado
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Fri Jul 22, 2016 3:17 pm
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by Avacado »

Just released a big patch I've been working on for version 0.1.0:

Version: 0.1.0
Changes:
- Added Oil Refinery (rare)
- Setting recipes now automatically creates map tags with the item's icon (can be disabled)
- Big factories now spawn on the 2x2 grid to match blueprints that have rails
- Balanced power consumption to be about 4 times higher to be more in line with other entities
- Loaders now rotate with big factories (added always-on pipes to make this work)
- Loader's speed now matches the fastest loaders or belts possible in your current game
- Limited spawning to the main surface
- Change ratio of spawning to change over time. First two spawns are furnances, but then the game focuses on assemblers
until eventually finding a balance similar to whats required for an equal amount of all of the science packs
- Big recipes unlocks are now hidden from the technology screen to avoid clutter
- Improved algorithm for minimum distance checking to be much more efficient, also changing setting affects current buildings
Bugfixes:
- Fixed issue where factories could spawn on the edge of a chunk
- Added more edge-case testing to avoid crashes from bad data from other mods
- Added additional logic to further avoid spawning over ores, rso is optional dependency now
- Created cleanup logic for indestructable loaders that can sometimes be created by errors or conflicts with other mods
- Loaders under factories no longer copied into blueprints,a,
- Better localization for mods so "Unknown Key" doesn't show up for item-groups or recipes
Gear1989
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sat Jul 21, 2018 3:49 am
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by Gear1989 »

Version 0.1.0 has an issue with the spawning of the oil refinery.

I went exploring in my heavily modded save to find this.

https://imgur.com/HaQytde

Tested in Factorio v0.16.51 (Steam)
Avacado
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Fri Jul 22, 2016 3:17 pm
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by Avacado »

Could you provide a list of your mods? You can paste in your mods.json if that is easier.
Gear1989
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sat Jul 21, 2018 3:49 am
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by Gear1989 »

I have mods in my game that aren't in that save.

Here's the list for that save:

Afraid of the Dark (v 1.0.20)
Angel's Addons - Petrochem Train (v 0.3.2)
Angel's Addons - Smelting Train (v 0.1.1)
Angel's Addons - Warehouses (v 0.3.0)
Auto Deconstruct (v 0.1.11)
Bob's Adjustable Inserters (v 0.16.8)
Bob's Assembling Machines (v 0.16.1)
Bob's Functions Library (v 0.16.6)
Bob's Logistics Mod (v 0.16.23)
Bob's Mining (v 0.16.0)
Bob's Modules (v 0.16.0)
Bob's Revamp Mod (v 0.16.2)
Bob's Tech (v 0.16.6)
Bottleneck (v 0.9.1)
Bulk Rail Loader (v 0.4.3)
Bullet Trails (v 0.3.1)
Crafting Speed Research (v 0.2.0)
Explosive Excavation (v 1.1.4)
FNEI (v 0.1.8)
Factorio Reach (v 2.3.1)
Helicopters (v 0.2.16)
Helmod (v 0.7.11)
LTN (v 1.7.12)
Laser Beam Trails (v 0.2.0)
Loader Redux (v 1.2.7)
Miniloader (v 1.5.22)
More Armor (Better Power Armor Grids) (v 2.2.2)
Nixie Tubes (v 0.16.4)
Personal Roboport MK3 (v 2.2.1)
Power Armor MK3 (v 0.1.3)
RSO (v 3.7.8)
ShinyBobGFX (v 0.16.20)
Texuga TA Miners (v 0.0.3)
Train Ore Color (v 1.2.0)
Vehicle Wagon (v 1.2.5)
Whistle Stop Factories (v 0.1.0)
Wing Turbine V16 (v 4.0.5)

Since this post and that screenshot, the only mod that was updated since was RSO. Confirming that the issue is NOT with RSO.
Hyratel
Inserter
Inserter
Posts: 34
Joined: Sun May 15, 2016 10:35 pm
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by Hyratel »

will refineries retroactively spawn where they otherwise would in already-explored land? and is there a command to re-trigger spawning?
Avacado
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Fri Jul 22, 2016 3:17 pm
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by Avacado »

@gear1989

The issue is I didn't use a proper graphics shift for high resolution. It is a graphical glitch that doesn't affect gameplay. I'll be able to fix that in the next patch in the next couple of days, since I need to wait to get access to a better computer and the process for getting the right shift is pretty much guess and check.

@Hyratel

They won't spawn in explored territory, but the game tries to spawn the buildings in a way to get a goal ratio, so you'll be more likely to spawn refineries if you already have a lot of spawns, but note that refineries are meant to be pretty rare, so even with that you may still have to hunt a bit. The algorithm's goal is that in the next 100 spawns you'll hit the goal ratio for total spawned, which for refineries is going to try to spawn enough refineries so that 1 out of 36 buildings are refineries.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by eradicator »

Avacado wrote: the process for getting the right shift is pretty much guess and check.
The process is to open it in a graphics program. Determine the distance of the desired center-point to the edges. And divide that by 32 (one tiles pixel width), or use util.by_pixel(x.y) do do it for you. There's also supposedly a mod for it, but i've never used that so i don't know how well it works.

Anecdotally...if you're reusing a scaled version of the base game provided graphics, why do you do hr_version at all? I'd use the base.hr_version for both sd/hd for a factory scaled up like that.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Avacado
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Fri Jul 22, 2016 3:17 pm
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by Avacado »

I don't have much experience with graphics and graphics programs, but would I just zoom in all the way and then take a screenshot? I might try that mod though.

I tried using the hr version for both versions, but hit some resolution limit for the normal version where it wouldn't let me.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by eradicator »

Ah yes...them sprite sheet max sizes for sd, always forgetting about that. So yea, can't do that.
As you're reusing a vanilla texture it's probably easiest to measure by going to default zoom (F9) and making a screenshot with the tile grid showing (after setting shift=(0,0)). I'm sorry but i can't give you a general tutorial on dealing with graphics here, you'll have to find one on google. We all started knowing nothing ;). Although, as you're using a vanilla graphic that already has shift, you should be able to simply apply half the scale to shift. So if shift was (5,5) before, and you set scale = scale * 3 then shift should be (5*3/2 , 5*3/2) if i'm theorizing this correctly.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Avacado
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Fri Jul 22, 2016 3:17 pm
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by Avacado »

Thanks for the info, didn't know about default zoom either.

Why half the factor? By my reasoning it should be the full factor, which didn't end up working, so I made manual adjustments, but I'm now realizing that at least one of the reasons it didn't work might be because of reused table references in the base game data.raw causing some fields to potentially get adjusted multiple times.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by eradicator »

Avacado wrote:Why half the factor?
Because you're moving the center, but scaling all edges. So the graphic expands in two dimensions, but the center only moves in one? Difficult to explain in words. And that's just my theory, haven't tested.

Also yea...always be wary of table references. When in doubt just use util.table.deepcopy on everything :D. (Haha, found a table-by-ref bug in my library while writing you some example code, thanks! ;)

So, i can do this quite simply:

Code: Select all

local this = data.raw['assembling-machine']['oil-refinery']
sprite .scale(this.animation,6)
this.collision_box = area .scale(this.collision_box,6)
this.fluid_boxes = nil --didn't want to bother...
Here's the functions used:

Code: Select all

function sprite .scale (layers,factor)
  --scales all subnotes of an entities sprite tree
  --works recursively so input can be any level above what you want to change
  --i.e. can also be the entity prototype itself, or just entity.animations etc
  local this = layers
  local should_scale = false
  for name,layer in pairs(layers) do
    if (type(layer) == 'table') then
      if layer.filename then
        layers[name].scale = (layers[name].scale or 1) * factor
        local shift_factor =
          (layer.draw_as_shadow ~= true) and factor/2 or factor
        layers[name].shift = layers[name].shift or {0,0}
        layers[name].shift = erlib.epos.multiply(layers[name].shift,shift_factor)
      end
      scale(layer,factor)
      end
    end
  end
  
function position .multiply(pos1,factor)
  local x1,y1 = pos1.x or pos1[1], pos1.y or pos1[2]
  return {x = x1 * factor, y = y1 * factor}
  end
  
function area.scale(box,scale)
  local x1,y1,x2,y2
  if box.left_top and box.right_bottom then    
    x1 = box.left_top    .x or box.left_top    [1]
    y1 = box.left_top    .y or box.left_top    [2]
    x2 = box.right_bottom.x or box.right_bottom[1]
    y2 = box.right_bottom.y or box.right_bottom[2]
  elseif box[1] and box[2] then
    x1 = box[1].x or box[1][1]
    y1 = box[1].y or box[1][2]
    x2 = box[1].x or box[2][1]
    y2 = box[1].y or box[2][2]
  else
    erlib .stop('Invalid area specification.')
    end
  return {left_top={x=x1*scale,y=y1*scale},right_bottom={x=x2*scale,y=y2*scale}}
  end
Result:
bigfinery.jpg
bigfinery.jpg (133.73 KiB) Viewed 5769 times
Edit: Also not that this is more of an orientation/proof of concept. You still need to adjust working visualizations etc.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
wolfram74
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat May 20, 2017 5:05 pm
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by wolfram74 »

I've found 2 oil refineries on separate maps upgrade from earlier versions of the mod and when I click on them to assign a recipe like with other objects, I get a message about no recipes being available.
Rylant
Long Handed Inserter
Long Handed Inserter
Posts: 52
Joined: Mon Sep 25, 2017 6:07 pm
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by Rylant »

It is definitely a brilliant idea. I love the idea of building your entire world around these small factories and smelters and refineries. However, when I tried it, I found that the amount of throughput just wasn't worth it. I ended up getting out about a yellow belt of iron plates when feeding iron ore into it. At first, I was thinking I could feed in 8 belts of ore and get out 8 belts of plates. With just 1 belt of plate output, it isn't worth building your world around these structures. It isn't worth setting up a bunch of train stations to gather the resources, for the odd 1 yellow belt of plates. You are better off just building your factory as normal.

Is there any way to increase the production that these units can make? Or am I missing something here?

Rylant
Avacado
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Fri Jul 22, 2016 3:17 pm
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by Avacado »

I've found 2 oil refineries on separate maps upgrade from earlier versions of the mod and when I click on them to assign a recipe like with other objects, I get a message about no recipes being available.
@wolfram74, I fixed an issue related to this in 0.1.1. Please try upgrading to 0.1.1 and then double check you have basic-oil-processing researched and report back if you're still having issues.
Is there any way to increase the production that these units can make? Or am I missing something here?
@Rylant, the assemblers are as powerful as 80 assembling-machine-1's or 32 assembling-machine-3's (and by the time you're making assembling-machine-3's you'll have speed modules, which can let you get even more power out of them due to their extra module slots). The furnace is the power of 50 electric furnaces. Those are huge numbers. Yes, it doesn't look visually impressive to fill a belt and a half, but just think about how much infrastructure is normally needed for a belt and a half. Just having 80 assembling machines sitting there for free (well, not for free, for the cost of building out to it) for the player to just walk over to is pretty huge. And each one is that powerful.

And they take a bunch of modules so you can get a higher productivity bonus than would normally be possible. Also, being large they can take a lot of beacons, which can be used to bring them up to a speed that allows a full 8 blue-belts (at least for quick recipes like iron-plates). My goal however is for players not to have to mess with beacons and simply have tech research to increase the speed. This would not only serve as a way for players to speed up the machines, but also would help players better realize why they aren't fast to the point of being broken at the start of the game. Visually they absolutely look like they'd be a lot faster given the 8 output blue-belts, I agree it's a bit visually deceptive and hopefully the presence of techs will remedy that.

A big part of the problem is that in order to have a tech that increases the power consumption in line with the increased speed, I actually need to have a different prototype for each power consumption level. So not only do I need my mod to build a bunch of different prototypes, but I need logic that cleanly swaps the machines for other machines that look the same but have the different power consumption levels.

So I'm working on it. I've been adding features almost daily to the development branch of my mod (the version I released a few days ago had about 10 new features, some of them minor), and the tech speed improvement is towards the top of my current list, but it'll be a challenge to implement and also difficult to ensure that I get it to all work correctly and seamlessly swap between the prototypes (not only getting it to the right position and facing the right direction, but also making sure it keeps the same recipe, etc, so the player hopefully doesn't even realized all their buildings have been replaced with completely new buildings).
wolfram74
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat May 20, 2017 5:05 pm
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by wolfram74 »

Update fixed it, now just gotta build out to the bloody thing.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by eradicator »

Avacado wrote: A big part of the problem is that in order to have a tech that increases the power consumption in line with the increased speed, I actually need to have a different prototype for each power consumption level.
Modules can increase power+speed, they can also be limited to be only usable for certain recipes. So a module that's only usable in the assemblers should theoretically be possible. Ofc that does mean players can just spam any amount of modules into the machines, so yea. Replacing them would be cleaner to the player, but a lot messier in code :). Hm...if you spawn an invisible beacon below the machine, you can place invisible modules into that. Getting you the benefit of modules, without the spammability.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Avacado
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Fri Jul 22, 2016 3:17 pm
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by Avacado »

@eradicator

I could gain control by limiting the machines to just one module and the have special modules like you suggest. One problem is the player would still need to run around to each machine across their giant railworld to place the modules, which seems like a pain. I could also have the tech automatically fill the module in all the machines.

Yeah, I agree it'd be cleaner to code that, it'd be messier for the player. I wonder if the devs would be open to a read/write power consumption or power consumption bonus. There would be a few avenues in which they could add that ability into the API, but I wonder if there are limitations around the electrical buffer not being able to change size on the fly out something like that. Couldn't hurt to ask.

Do you know if I can make then immune to beacons? So that they aren't getting both my speed tech and the benefit of beacons?

Also, while I have you, do you know when the game calls tech effects reset? Is that safe to manually call during every mod upgrade (or is it automatically called)? Or an I risking messing something up?

I switched from unlock-recipe tech effects to unlock on recipe research event to hide my recipe clutter from the tech menu and also added an on tech effects reset event to also unlock all recipes for current techs, so I thought I was covered, but still found I needed to manually call tech effects reset.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by eradicator »

Yea, the biggest problem with modules is that the player can manipulate them, that's why i suggested hidden beacons. Btw, math says that in most cases speed bonus (beacons) massively reduces the energy cost per item, because they're made just that much faster. You might want to keep that in mind when balancing.

In 0.16 the abiltiy to change min/max flow rate of electric energy interfaces during runtime was removed due to "energy network optimizations" (i liked that feature...). So i doubt they'd want to reintroduce it to a much more widely used class like assemblers. On the other hand i have no clue how that makes sense given the fact that modules can already change effective consumption/demand. So, try your luck if you want (if i had to guess i'd say 80% of my requests are never implemented, so i just write lots of them :p).

You can make recipes "immune" to effects. Remeber "productivity can only be used on intermediates" from vanilla;)? Half of it is specified on the module, and half on the recipe if i remember correctly (just do some text searching through base files).

You mean LuaForce.reset_technology_effects? The base game never calls that. Only mods do it as far as i know. You're supposed to write a proper migrations file instead of a brute force "oh, just try all of them!". Though there's no lack of mods that just call it on every on_configuration_changed. So what you risk to mess up is other peoples mods that don't guard themselfs against it :D. (But as you're not the only one they have to do the guarding anyway.) The problem being that calling it raises on_research_finished for everything again, so if you have a handler for that make sure it doesn't do something twice that it shouldn't.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Avacado
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Fri Jul 22, 2016 3:17 pm
Contact:

Re: [MOD 0.16.x] Whistle Stop Factories

Post by Avacado »

Oh, I missed your suggestion about invisible beacons, that is a great idea and I believe has a huge added benefit for me, which is the bonus isn't multiplicative with other speed modules.

So if I give you a +2000% bonus, and you add speed beacons to give you another +100% bonus, you'll be only at a +2100% bonus instead of a (1+20)*(1+1)-1=4100% bonus. I was worried about people getting a huge bonus on top of my tech bonus to get really absurd speeds (20x from techs and 20x from beacons so 400x... that's absurd), but an invisible beacon will stack in the perfect way such that adding your own beacons isn't that much more powerful, exactly what I was hoping for. I'm not sure if other types of bonuses would stack, but invisible beacons would certainly stack with other beacons in the way I want and be way easier than multiple prototypes and prototype swapping.
massively reduces the energy cost per item,
I don't follow this. Don't they give +50% speed and +70% energy? Even taking advantage of the multiplicative effect with productivity modules and the additive effect of the energy costs from those productivity modules you're still never going to get a more energy efficient cost per item with just speed/productivity modules except in some edge-cases. If you have 4 productivity-3 modules, you'll never get better energy/item no matter how many speed-module-3s you add. If you have 5 productivity-3's you can get a better energy/item by having 92 speed-3 modules (but you can't fit that many around even my big buildings, which can only fit 32 beacons). With 6 proctivity-3's you can get more energy efficient than default with 57 speed-3 modules, but even with infinite speed-3 modules, you only ever get to a 12.5% energy savings over the base.
The problem being that calling it raises on_research_finished for everything again, so if you have a handler for that make sure it doesn't do something twice that it shouldn't.
Woops! I'm doing it twice then, though the thing I'm doing twice is unlocking a recipe, so no real problems there. I guess I don't need to have the on_tech_effects_reset event then if it calls each tech on_research_finished. I maybe could have figured out just which techs it was needed for and reset only those tech effects, or even more straight forward, just figured out which recipes needed to be unlocked and unlock them directly instead of doing any resets.

I'm still a little confused, because it wasn't until I tried to change unlock-recipes to the on event recipe unlocks that I had a problem with the game not unlocking my newest batch of recipes meant for refineries. I assume then even if reset_technology_effects isn't ever called, that anytime a technology prototype is changed by a mod that at least that tech is reset?

My plan then is to add a beacon at the exact center of my factories (since factorio has no problem with entity collisions). Is there a logic to what's "on top"? I recently realized that my underground belts, which sometimes caused issues because if my mod didn't delete them when it was suppose to (if another mode .destroy() my entity without calling an event), they'd be left with unminable/undestroyable loaders. But I recently realized that I could simply make them minable and because the factory is "on top" they can't be picked up until the factory is gone anyway. So they are minable now and just give no results so that the player can easily clean them up if my mod messes up (though I still have nth_tick logic that iterates through every one of my factories and checks .valid and cleans up loaders automatically if the factory stopped being .valid). Ideally I'd like to get rid of the nth_tick logic entirely, but that, at minimum, won't happen unless they give me the requested on_recipe event that I use for creating map tags, so I'm already iterating through all my entities every nth_tick, so the .valid check and cleanup doesn't add much.
Post Reply

Return to “Mods”