Auto mining


You don't need to mine manually. You can use mods.factorio.com/mod/zk-lib instead Anyone can translate the mod on Crowdin. https://crowdin.com/project/factorio-mods-localization

Tweaks
4 years ago
0.17 - 1.1
1.44K
Cheats

i Make it more comfy

4 years ago

I guess that command "/auto-mine" is an awful idea so an embedded gui is a better way than a command.

4 years ago
(updated 4 years ago)

I think that you don't need to have the "/auto-mine" command at all.
Let the player "auto-mine", if the player has mined an ore successfully (just like it is now).
But add the possibilty to let the player abort the auto-mine-action, if the player is trying to move or trying to mine another ore.
Because if the player is trying to mine another ore while auto-mining now (in this version), the player won't mine anything.

4 years ago
(updated 4 years ago)

I think that you don't need to have the "/auto-mine" command at all.

Yes

if the player is trying to move or trying to mine another ore.

There are various problems with it although it's possible and it's good ideas.

I may add a user interface to a player or to the ore when the player mining which cancel his mining.

4 years ago

For canceling the auto-mining, you could instead add a button to the shortcut menu, which is next to the quickbar, and a hotkey.
Also it would be great, if I could move and cancel the auto-mining, when I am suddenly attacked by enemies for example and I need to get out as fast as possible.
It would be easier for the user, because right now the player would be stuck and it would be frustrating to die because of that.

I don't know, if my ideas I mentioned in my previous post will have a heavy preformance impact on the game.
So if implementing an interface is better performance wise, you should do it.

4 years ago

Ah... Apparently I'll make

The possibility to let the player abort the auto-mine-action, if the player is trying to move or trying to mine another ore.

But if it'll cause problems on the performance in the multiplayer mode then the features will work in the singleplayer mode.

4 years ago

Well when the mod is updated, I will test it in multiplayer and report bugs either here or in a new thread, if I encounter any. I hope it will be compatible with the 0.17 version of Factorio.

Thank you for taking your time and for the quick responses.
Have a nice day!

4 years ago

I hope it will be compatible with the 0.17 version of Factorio.

At the moment, it's easy to make compatibility. (same API)

I will test it in multiplayer and report bugs either here or in a new thread, if I encounter any.

Well, I hope it's not necessary :P

4 years ago
(updated 4 years ago)

if the player is trying to move

Failed, I don't have access to the default inputs and such events do not happen.

trying to mine another ore.

It works.

4 years ago

trying to mine another ore.

Wait... why it doesn't work?..

4 years ago

So you want to use an event to abort the auto-mining action ?
Are there more possibilities to abort it ?

About the mine ore situation, did you mean the bug, when you try to mine another field of ore while auto-mining is active, that you don't mine anything ?
Or did you mean, you can abort auto-mining, when trying to mine another field of ore ?

One idea I have right now is, that you use a hotkey (and add a button to the shortcut menu) to toggle auto-mining.

Another idea would be to use 1 of the "on_gui"-events. Like when auto-mining is active, a GUI opens with just a button, and as soon as the button is clicked, it stops the auto-mining, but I think, the first idea is better.

4 years ago

So you want to use an event to abort the auto-mining action?
Are there more possibilities to abort it?

Yes, sorta, and I´ll create a one.

if the player is trying to move

Here we go again, I found a workaround. Maybe it´s dirty because I don´t see standard ways to use the default buttons that we use to run (w, a, s, d).

About the mine ore situation, did you mean the bug, when you try to mine another field of ore while auto-mining is active, that you don't mine anything?

Well... It's a real problem because of it, you can't move in the current version although there are strange ways to stop it.

One idea I have right now is, that you use a hotkey (and add a button to the shortcut menu) to toggle auto-mining.

Hm...

Another idea would be to use 1 of the "on_gui"-events. Like when auto-mining is active, a GUI opens with just a button, and as soon as the button is clicked, it stops the auto-mining, but I think, the first idea is better.

Well, it's the case when I want to use a button that will be attached to a player or an ore and it´s possible for 0.17 and 0.18.

4 years ago
(updated 4 years ago)

An update in ~5 minutes

4 years ago

No new bugs

4 years ago
(updated 4 years ago)

I have no modding experience in factorio, so I am just typing things that come to my mind to give you some ideas.
Whenever you found your way, that you are most satisfied with, to deal with this situation, and release a new version of your mod, I will test it in multiplayer, as it is something, that is convenient to have.

Anyway, I wish you good luck for that!

Edit: I did't expect to be that fast lol ^^!

4 years ago

Uhm, it says it needs a dependency, which is not available on the mod portal.

4 years ago

Fixed, redownload the mod again

4 years ago

Thanks! I will test it today and give you feedback after a couple of hours or tomorrow.

4 years ago

So far, there were only minor problems I could find:
- It seems like only the host is able to see the mining animation from auto-mining-players. Others don't see their mining animation being played when auto-mining (but it still works)
- If you are holding rightclick to mine another field of ore while auto-mining being on, the player cannot mine anything, as the auto-mining and manual mining cancels each other out

I checked the code, to see, what you meant by "dirty workaround". You used hotkeys, which are the same as the default movement keys. That's actually smart. I didn't even thought you could do that lol.

You seem to still have the "/auto-mining"-command implemented. Is it still needed for something ?

Aside from that, nothing major happened and everything worked so far.
Good job!

4 years ago
(updated 4 years ago)

It seems like only the host is able to see the mining animation from auto-mining-players. Others don't see their mining animation being played when auto-mining (but it still works).

Oh

If you are holding rightclick to mine another field of ore while auto-mining being on, the player cannot mine anything, as the auto-mining and manual mining cancels each other out

This is defiantly a bug, this is our curse. (I don't how to fix it without overengineering) OR WE USE THE SAME TRICK AGAIN (edited).

You seem to still have the "/auto-mining"-command implemented. Is it still needed for something?

There are people with another control ways, so yes.

4 years ago
(updated 4 years ago)

This is defiantly a bug, this is our curse. (I don't how to fix it without overengineering) OR WE USE THE SAME TRICK AGAIN (edited).

Hmm. But you can't build anymore while auto-mining, because you have to rightclick, and this would abort the auto-mine action, assuming you use the hotkey function. Also, I don't know, if it will work, as you have to mine an ore successfully before auto-mining activates and at the same time it deactivates, because technically you are still holding rightclick, if I understood it correctly.

4 years ago
(updated 4 years ago)

An update in 4 mins

4 years ago

Hmm. I tried to mine another or while auto-mining was toggled on, but it wasn't working.
Did you fix it ? What did you change ?

4 years ago

Oh, I did a little mistake

4 years ago

I get an error:
Error ModManager.cpp:1332: Failed to load mod "auto-mining": Failed to load locale: Duplicate key "stop-auto-mining-2" in property tree at ROOT.controls.

4 years ago
(updated 4 years ago)


Oh, I see

4 years ago
(updated 4 years ago)

4 years ago

Seems like it is working. There are a few thinks I would like to mention:
- The control to toggle auto-mining isn't translated. It says for me 'Unknown key:"controls.toogle-auto-mining"'
- With "toogle", I think you meant "toggle", right ?
- This is very minor and doesn't need to be fixed: If you hold rightclick to mine an ore and auto-mine gets activated, drag the cursor while still holding rightclick and hover it over another field of ore. You will see the same conflict between auto-mining and manual mining, as mentioned before.

Did you already implement a fix for the multiplayer mining animation bug ? I cannot test it in multiplayer right now, so that's why I am asking.

4 years ago

Did you already implement a fix for the multiplayer mining animation bug?

Nope

4 years ago
(updated 4 years ago)

Aside from the minor things, the mod is working really well so far.
I will report additional bugs here, if I encounter any.

Thanks for the great work!

4 years ago

The control to toggle auto-mining isn't translated. It says for me 'Unknown key:"controls.toogle-auto-mining"'

It's fixed now

4 years ago
(updated 4 years ago)

Oh, okay, so you renamed "toogle" to "toggle". That's good.
But I get this error:

Error while running event auto-mining::on_init()
Unknown custom-input name: toogle-auto-mining
stack traceback:
event-listener/branch-3/v0-9-0/control.lua:51: in function 'newindex'
__event-listener
/branch-3/v0-9-0/control.lua:166: in function 'register_events'
event-listener/branch-3/v0-9-0/control.lua:194: in function <event-listener/branch-3/v0-9-0/control.lua:193>
stack traceback:
[C]: in function 'get_event_handler'
event-listener/branch-3/v0-9-0/control.lua:51: in function 'newindex'
__event-listener
/branch-3/v0-9-0/control.lua:166: in function 'register_events'
event-listener/branch-3/v0-9-0/control.lua:194: in function <event-listener/branch-3/v0-9-0/control.lua:193>

Seems like there are more spelling mistakes in the code. Also, make sure to fix the locals (for english) as well.

4 years ago

4 years ago

Thanks! It's working now
One more thing:
In "\locale\en\auto-mining.cfg", can you change line 14 from:

toggle-auto-mining=Toogle auto mining

into:

toggle-auto-mining=Toggle auto mining

?

4 years ago
(updated 4 years ago)

Auto fixing, my IDE fixes even the minor mistakes

4 years ago

No, I mean in "\locale\en\auto-mining.cfg" at line 14, there is still the spelling mistake "toogle", directly after the "="-symbol.

4 years ago
(updated 4 years ago)
4 years ago

I guess it works

4 years ago

Yes, it works, thanks again!

4 years ago

I think I found an unintended behaviour, but it makes sense, why it is that way.
While auto-mining, when I have my world map opened, if I navigate through the world map with WASD or rightclick, it cancels the auto-mining.
I don't think it should be that way, because I didn't intend to move my character or mine another field of ore.

Is there a easy way to check, whether a player has opened the map or not ?
If not, then it isn't important to fix this behaviour. I can use scrollwheel instead to navigate through the world map.
(Or you could somehow apply the same workaround lol)

4 years ago
(updated 4 years ago)

Is there an easy way to check, whether a player has opened the map or not?

Seems, there's

(Or you could somehow apply the same workaround lol)

Why not? xD

4 years ago
(updated 4 years ago)

Oh, so it is easy then. Cool.
So you can add something like this:
if defines.render_mode.game then
cancel_automining

... to "clear_player_data(event)", right ?
(Yeah, i don't know how it would be in lua)

Edit:
I think this new condition should be hotkey-exclusive.
So a new function for all "stop-auto-mining-*" events.

4 years ago
(updated 4 years ago)

I am not good at naming functions, but I have a working example (at least in single-player).
In "\auto-mining\control.lua", I have added a new function:

local function check_player_opened_map(event)
    local player = game.players[event.player_index]
    if player.render_mode == defines.render_mode.game then
        clear_player_data(event)
    end
end

And changed the event trigger functions for "stop-auto-mining-*":

["stop-auto-mining-1"] = check_player_opened_map,
["stop-auto-mining-2"] = check_player_opened_map,
["stop-auto-mining-3"] = check_player_opened_map,

Oh yeah, before you add that, at line 58 in "\auto-mining\control.lua", you can change this line to:

clear_player_data(event)

I hope I can help you with that.

4 years ago
(updated 4 years ago)

*Hidden confusing because of the one did a thing*

Well, you made me change my future plans and made me smile also :P
So, wait for new info in ~17 hours and the update.

(So, yes, I guess)

4 years ago

You are welcome, but I don't know, why you got confused ^^ (maybe because of my today's first post ?).
So, the only thing I can do to find that out is looking forward for the new info/update.

Until then.

4 years ago

https://mods.factorio.com/mod/auto-mining/changelog

why you got confused

Users don't code... commonly...

(And the info later)

4 years ago
(updated 4 years ago)

I took some code of "FI" for current update ...*

(xP)

4 years ago
(updated 4 years ago)

Users don't code... commonly...

Well, I thought I give it a try.

I took some code of "FI" for current update ...*

Wow. That's nice of you. Thanks! I appreciate it.

4 years ago

So... Auto-mining of trees/rocks + auto-walking may be a useful thing.

As always, my plan is chaotic.

4 years ago
(updated 4 years ago)

Auto-mining resource-filled obstacles, like trees and rocks, would be very nice to have.
That means, the player auto-mines every resource-filled obstacle in the vicinity. The player should be able to move, while this kind of auto-mining is active. This is only my suggestion. I don't know, how the player should be able to abort it though (Maybe only through the already-existing "Toggle auto-mining"-hotkey ?).

As for auto-walking, is it like walking straight forward or like "walk to the next tree/rock in the search vicinity". Should this also be separately toggleable with another hotkey ?

Edit:
I like your idea more. It should be like this:
The player mines a tree/rock, with that it activates auto-mining, and auto-walks to the next tree/rock and mines it.
To abort this action, right-click or use WASD. Simple as that.

4 years ago

Like "walk to the next tree/rock in the search vicinity" and it might be working with a selection of area like a blueprint.

Should this also be separately toggleable with another hotkey?

... Probably, nope. I meant auto-walking will work together with auto-mining always.

4 years ago

I meant auto-walking will work together with auto-mining always.

This is probably the better approach for the user.

it might be working with a selection of area like a blueprint.

Maybe the deconstruction tool, which is originally meant for the robots, can be used for that ?

4 years ago

deconstruction tool

Yeah, I forgot about the one.

can be used for that?

As a new item or a new shortcut, probably.

4 years ago
(updated 4 years ago)

Is it possible to do this:
Mining a tree/rock to activate auto-mining.
Then search for any tree/rock in a configurable distance, choose the closest tree/rock, optionally auto-walk there to reach that tree/rock, auto-mine it, and repeat.
Would that be feasible ?

4 years ago

Yes, it's possible!

4 years ago

If you implement that, then there will be no need for a new item or shortcut.
This would be easier for the user as well, only having to mine a tree/rock to activate this kind of auto-mining

Otherwise, if you don't want to do it that way, you can also make usage of the deconstruction tool to mark trees/rocks, so the auto-mining picks only the marked objects, if that's possible too.

4 years ago

They both are neat.

Mining a tree/rock to activate auto-mining.

It's simpler

4 years ago

I guess I await for the next update then :)

4 years ago

Here is something that I have found by accident, that could be convenient for you:
https://wiki.factorio.com/Prototype/CustomInput#linked_game_control

Take a look at the property "linked_game_control":
If you use that, then the player won't have to reassign your custom inputs to the movement inputs manually, if they are different than WASD. One other neat effect is it disappears in the control-settings GUI. So you won't need a localization for that :). For that property, you have to use these strings:

mine
move-down
move-left
move-right
move-up

But you have to define 5 custom inputs for that though. I am not sure, if you can use the same name for all 5 custom inputs. Have you tried that ?

4 years ago

^^

But you have to define 5 custom inputs for that though. I am not sure, if you can use the same name for all 5 custom inputs. Have you tried that?

I'll try it!

4 years ago

Nice. It's working. The control-settings GUI looks so much better now lol.

Thanks for updating!

4 years ago

This project has been moved to https://mods.factorio.com/mod/zk-lib