Page 1 of 1

[Request] Placing Electric Miners

Posted: Wed May 28, 2014 10:36 pm
by Omnissiah
Hello, I was wondering if there are any mods out there that removes the restriction on placing Miners only on top of ore or rocks. I want to make a blueprint mining outpost for my expanding rail network so I can just throw down a roboport and make the entire outpost with 1 click. Right now if you try to place miners on any ground other than over ore or rock it is red and doesn't let you.

Thanks for any help.

Re: [Request] Placing Electric Miners

Posted: Thu May 29, 2014 12:01 am
by FreeER
Here you go: Drills Anywhere
There is a 'feature' to it that allows you to place drills at any distance and a couple bugs:
You can place drills on top of other entities (including yourself) if you are not careful but not other drills (that much was easy enough to check for), and at times it may be placed next to where you actually intended (you can pick it up and move your cursor a bit try again to place it properly).

to fix these would require a decent amount of work to check for exactly what is at that position (the little 'doodads' show in game.findentities not just player built entities) and the positioning would require checking exactly which cursor positions are causing the placed position to be off by one (and then doing some math to correct for it) and the feature would require looking at the source code to see the player's building reach and then check that the cursor position is not further away from the player than that building limit, it's just not worth it to spend that amount of time on this sort of mod :lol:

Oh, and it should work for any drill (including mod added drills, as long as they are drill entities and not containers with fancy coding ;))
Hope you find it helpful regardless of those little bugs :P

Re: [Request] Placing Electric Miners

Posted: Thu May 29, 2014 1:14 am
by Omnissiah
Thanks for the help! One quick question. Can I add this to my game, make my blueprint, then remove it without causing any problems to my save file?

Re: [Request] Placing Electric Miners

Posted: Thu May 29, 2014 1:24 am
by FreeER
yeah, shouldn't cause any issues by removing since it doesn't add or (technically) change anything in the base game.
IF replays were working then they would 'break' when you add a mod (or remove one), because Factorio assumes the mod would use random numbers and if it does then it would change the determination for the replay (random numbers may not be used in the exact same order when the replay is ran as when you were playing, at least I'm fairly sure that's the reason replays are disabled when you add/remove mods), but that's the only issue that should be possible and since I don't believe replays even work in 9.8 there's no issue :)

Re: [Request] Placing Electric Miners

Posted: Thu May 29, 2014 1:26 am
by Omnissiah
Awesome, thank you very much!

Re: [Request] Placing Electric Miners

Posted: Fri May 30, 2014 9:13 am
by GotLag
FreeER wrote:Here you go: Drills Anywhere
There is a 'feature' to it that allows you to place drills at any distance and a couple bugs:
You can place drills on top of other entities (including yourself) if you are not careful but not other drills (that much was easy enough to check for), and at times it may be placed next to where you actually intended (you can pick it up and move your cursor a bit try again to place it properly).

to fix these would require a decent amount of work to check for exactly what is at that position (the little 'doodads' show in game.findentities not just player built entities) and the positioning would require checking exactly which cursor positions are causing the placed position to be off by one (and then doing some math to correct for it) and the feature would require looking at the source code to see the player's building reach and then check that the cursor position is not further away from the player than that building limit, it's just not worth it to spend that amount of time on this sort of mod :lol:

Oh, and it should work for any drill (including mod added drills, as long as they are drill entities and not containers with fancy coding ;))
Hope you find it helpful regardless of those little bugs :P
This places drills only where structures can be built (i.e. not on other structures or the player) and puts them in the correct grid square:

Code: Select all

require "defines"

function distance(position1, position2)
  return ((position1.x - position2.x)^2 + (position1.y - position2.y)^2)^0.5
end

game.onevent(defines.events.onputitem, function(event)
  if distance(game.player.position, event.position) < 7 then
    if game.player.cursorstack.name == "basic-mining-drill" then
      if (game.canplaceentity{name="electric-furnace", position=event.position}) then
        game.createentity{name=game.player.cursorstack.name, position=event.position}
        game.player.removeitem{name="basic-mining-drill", count=1}
      end
    elseif game.player.cursorstack.name == "burner-mining-drill" then
      if (game.canplaceentity{name="stone-furnace", position=event.position}) then
        game.createentity{name=game.player.cursorstack.name, position={event.position.x + 0.5, event.position.y + 0.5}}
        game.player.removeitem{name="burner-mining-drill", count=1}
      end
    end
  end
end)
Replace "electric-furnace" and "stone-furnace" with your 3x3 and 2x2 buildings of choice, respectively. Or create your own simple entities with appropriate collision masks.
This should use the distance function from util but for whatever reason I can't get the game to recognise it and I can't be bothered finding out why.

This could probably be made to work with mod-added drills, by finding out the size from the prototype collision box and using an appropriately-sized placeholder entity. But I'm tired and can't be arsed today.

Re: [Request] Placing Electric Miners

Posted: Fri May 30, 2014 10:05 am
by BurnHard
One of the things I really want so see working :)

I hope the devs let us place miners wherever we want. The only thing that happens when placing a miner not on ore is that they just dont work, just like on an depleted ore field.

Re: [Request] Placing Electric Miners

Posted: Fri May 30, 2014 3:44 pm
by SilverWarior
BurnHard wrote:I hope the devs let us place miners wherever we want.
I would rather see that developers change the way how blueprints work so that even if some specific structures like miners can't be built the blueprint itself will still be valid and the building of incorectly placed miners will be just skipped. This way you won't be needlessly spending resources for placing of non working buildings.

Re: [Request] Placing Electric Miners

Posted: Fri May 30, 2014 3:48 pm
by FreeER
SilverWarior wrote:I would rather see that developers change the way how blueprints work so that even if some specific structures like miners can't be built the blueprint itself will still be valid and the building of incorectly placed miners will be just skipped. This way you won't be needlessly spending resources for placing of non working buildings.
The blueprints are being/have been changed to allow this, but you still need the miners setup before you can make the blueprint.