[MOD 0.14] Filtered Deconstruction Planner 0.4.10

Topics and discussion about specific mods
NearlyDutch
Inserter
Inserter
Posts: 47
Joined: Tue Oct 20, 2015 12:56 pm
Contact:

[MOD 0.14] Filtered Deconstruction Planner 0.4.10

Post by NearlyDutch »

Type: Mod
Name: Filtered Deconstruction Planner
Description: Target specific objects to be deconstructed by bots or cut them from existing blueprints.
License: MIT
Version: v0.4.10
Release: 2016-11-06
Tested-With-Factorio-Version: 0.14.19
Category: Helper
Tags: filtered deconstruction
Download-Url: v0.4.10 at GitHub
Website: https://github.com/dkaisers/filtered-de ... on-planner
License
Long description
Picture
Version history
Last edited by NearlyDutch on Sun Nov 06, 2016 10:52 am, edited 25 times in total.
Supercheese
Filter Inserter
Filter Inserter
Posts: 841
Joined: Mon Sep 14, 2015 7:40 am
Contact:

Re: [MOD 12.22] Filtered Deconstruction Planner 0.1.0

Post by Supercheese »

Niiice, I was just thinking an ability to filter like this would be great to have!
NearlyDutch
Inserter
Inserter
Posts: 47
Joined: Tue Oct 20, 2015 12:56 pm
Contact:

Re: [MOD 12.22] Filtered Deconstruction Planner 0.1.0

Post by NearlyDutch »

Thanks, after I got some sleep I worked a bit more on the mod this morning and now you can choose between three different modes of deconstruction as explained in the updated long description and picture of the mod in the original post.
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: [MOD 0.12.22] Filtered Deconstruction Planner 0.2.0

Post by Choumiko »

That's a nice one :D

We should really request an item like a blueprint/deconstruction planner that does nothing but fire an event with player and entities in the selected area.

Of course i had to peek at the code, and found a potential issue for MP games, will add a comment in github shortly.

Edit: Forget the github comment, doing it here: in the on_marked_for_deconstruction event, you probably should check if exactly one player has the item on its cursor stack and that no other players have a deconstruction planner/module inserter/upgrade planner (if that mod still works) in the cursor stack. Because as far as i know you can't clearly distinguish which player triggered the event.
NearlyDutch
Inserter
Inserter
Posts: 47
Joined: Tue Oct 20, 2015 12:56 pm
Contact:

Re: [MOD 0.12.22] Filtered Deconstruction Planner 0.2.0

Post by NearlyDutch »

I used the module inserter as basis and changed it to the current functionality, I guess that should be quite obvious when looking at the code :D

Concerning the multiplayer, how would that help me, to know if anybody else got a deconstruction planner in his stack? I can't really keep track of who is deconstructing what just to see if there is some overlap, or is there another way?
Koub
Global Moderator
Global Moderator
Posts: 7784
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: [MOD 0.12.22] Filtered Deconstruction Planner 0.2.0

Post by Koub »

You've one ultimate step you could do : search and replace planner, and you'll be praised as a god among men :)
Koub - Please consider English is not my native language.
NearlyDutch
Inserter
Inserter
Posts: 47
Joined: Tue Oct 20, 2015 12:56 pm
Contact:

Re: [MOD 0.12.22] Filtered Deconstruction Planner 0.2.0

Post by NearlyDutch »

You mean like the upgrade planner mod that already exists on this forum? :D
Koub
Global Moderator
Global Moderator
Posts: 7784
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: [MOD 0.12.22] Filtered Deconstruction Planner 0.2.0

Post by Koub »

Doh

Image
Koub - Please consider English is not my native language.
kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

Re: [MOD 0.12.22] Filtered Deconstruction Planner 0.2.0

Post by kds71 »

NearlyDutch wrote:Concerning the multiplayer, how would that help me, to know if anybody else got a deconstruction planner in his stack? I can't really keep track of who is deconstructing what just to see if there is some overlap, or is there another way?
This part of code in your mod rises a problem (three problems actually) in multiplayer

Code: Select all

		for _, p in pairs(game.players) do
			local stack = p.cursor_stack
			if stack.valid_for_read then
				if stack.name == "filtered-deconstruction-planner" then
					player = p
				else
					return
				end
			end
		end
1. If player 1 is holding an item other than filtered deconstruction planner in his hand, player 2 can't use filtered deconstruction planner at all.
2. If situation from point 1 occurs, filtered deconstruction planner used by player 2 will act like a normal deconstruction planner, which may lead to terrible results (like deconstructing half of the factory while player just wanted to remove some inserters): you can't just exit the function, you need to cancel deconstruction before returning.
3. If player 1 is holding a filtered deconstruction planner in his hand, player 2 will be using filtered deconstruction planner with configuration that was set by player 1.

I have the same problem in my upgrade planner mod, and all I do is discard deconstruction alltogether if more than one player holds planner tool in the hand. It has to be done, otherwise it may lead to situation when player uses a planner tool with wrong configuration.

The code is rather simple, this is how it looks like in my mod:

Code: Select all

    -- Determine which player used upgrade planner.
    -- If more than one player has upgrade planner in their hand or one
    -- player has a upgrade planner and other has deconstruction planner,
    -- we can't determine it, so we have to discard deconstruction order.

    for i = 1, #game.players do

        if game.players[i].cursor_stack.valid_for_read then
            if game.players[i].cursor_stack.name == "upgrade-planner" then
                if upgrade or deconstruction then
                    entity.cancel_deconstruction(entity.force)
                    return
                end
                player = game.players[i]
                upgrade = true
            elseif game.players[i].cursor_stack.name == "deconstruction-planner" then
                if upgrade then
                    entity.cancel_deconstruction(entity.force)
                    return
                end
                deconstruction = true
            end
        end

    end

    if not player then return end
Koub wrote:You've one ultimate step you could do : search and replace planner, and you'll be praised as a god among men :)
Oh :(
NearlyDutch
Inserter
Inserter
Posts: 47
Joined: Tue Oct 20, 2015 12:56 pm
Contact:

Re: [MOD 0.12.22] Filtered Deconstruction Planner 0.2.0

Post by NearlyDutch »

Ah okay, I see. I tried to come up with code that would work with all possible "planner-mods" like this one, upgrade planner and module inserter:

Code: Select all

for _, p in pairs(game.players) do
	local stack = p.cursor_stack
	if stack.valid_for_read then
		if stack.type == "deconstruction-item" then
			if stack.name == "filtered-deconstruction-planner" and not found_deconstruction_item then
				player = p
			elseif found_deconstruction_item then
				entity.cancel_deconstruction(entity.force)
				return
			end

			found_deconstruction_item = true
		end
	end
end

if not player then
	return
end
So, this should only allow the rest of the function to work, if there is exactly one item in a player's hand that is a filtered deconstruction planner. In any case the loop finds more than one item of type "deconstruction-item", which all those different planners are, it will cancel the deconstruction and return the function. If the loop finished without the player being set, there was no filtered deconstruction planner used and the function is also returned, as this case will be handled by another mod or the base game in case of the default deconstruction planner.
While this way should be safe to use with any combination of "planner-mods", the downside to this general approach is, that two default deconstruction planners can't be used simultaneously anymore, too... :/

Does this make sense? If so, I'll release the patch for the mod asap.
Last edited by NearlyDutch on Fri Jan 29, 2016 12:53 pm, edited 1 time in total.
kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

Re: [MOD 0.12.22] Filtered Deconstruction Planner 0.2.0

Post by kds71 »

Yeah, it does make a sense - and now I will have to fix my mod, because it is assuming that there are no other deconstruction planners than the one that comes with the base game :)
NearlyDutch wrote:the downside to this general approach is, that two default deconstruction planners can't be used simultaneously anymore, too... :/
Unfortunatelly, nothing can be done about that unless the on_marked_for_deconstruction event would pass not only deconstruction entity, but also a player that caused deconstruction.
NearlyDutch
Inserter
Inserter
Posts: 47
Joined: Tue Oct 20, 2015 12:56 pm
Contact:

Re: [MOD 0.12.22] Filtered Deconstruction Planner 0.2.1

Post by NearlyDutch »

Yeah, sorry about that :D

Just published the 0.2.1 release, link in original post of this thread. This should fix the possible multiplayer issue as described by Choumiko and kds71.
mbritb
Inserter
Inserter
Posts: 22
Joined: Thu Oct 01, 2015 4:19 pm
Contact:

Re: [MOD 0.12.22] Filtered Deconstruction Planner 0.2.1

Post by mbritb »

NearlyDutch - Fix it, Fix it, Fix it!

Sooooo, I downloaded your mod! Soooo excited. So I was playing around with it and thought about giving it the ultimate test.

Removing concrete under structures. Yea, it won't remove concrete...period.

FISSSS IT!!! :D

On another note: I love this...I love you!!!! Best mod ever! haha!
mbritb
Inserter
Inserter
Posts: 22
Joined: Thu Oct 01, 2015 4:19 pm
Contact:

Re: [MOD 0.12.22] Filtered Deconstruction Planner 0.2.1

Post by mbritb »

mophydeen wrote:It is not possible to target:
  • alien artifact
    wood (for trees)
    stone (for rocks) // using minable rock mod
You can use a deconstruction planner to pick up alien artifact and trees. But not stone. (in base game)
NearlyDutch
Inserter
Inserter
Posts: 47
Joined: Tue Oct 20, 2015 12:56 pm
Contact:

Re: [MOD 0.12.22] Filtered Deconstruction Planner 0.2.1

Post by NearlyDutch »

Wasn't very productive today due to a hangover, but I figured out how I will approach the raised issues. :D

I just realized, that items lying on the ground work differently than items placed/built. That's why you can't target alien artifacts in the way mophydeen probably means. Since there can be stone and wood also lying around and I want to keep the possibility open for items on the ground to be targeted, I won't make it so that wood and stone will be used to configure trees and rocks for targeting, but those will be able to be chosen with a selection tool that works like the eyedropper in your favorite graphics software to choose a color from an image.

Danielv123 posted the idea on reddit and after figuring out how to go about it, I think that would be the best solution. You'll click the eyedropper tool button, and while that tool is active, entities that you click on will be added to your filter configuration, as long as there is an empty slot available and the selected item is not already in there.

@brit, thanks for the kind words, but sadly I have to say that concrete below structures won't probably be possible. Since the filtered deconstruction planner is basically just a standard one with functionality and a GUI on top, it still prioritizes structures over flooring, when "drawing" that selection rectangle. And that is not game logic you can tinker with using mods, so at the moment I can't offer a solution for that problem, sorry. :/
User avatar
StanFear
Fast Inserter
Fast Inserter
Posts: 236
Joined: Sun Dec 15, 2013 2:49 pm
Contact:

Re: [MOD 0.12.22] Filtered Deconstruction Planner 0.2.1

Post by StanFear »

NearlyDutch wrote:@brit, thanks for the kind words, but sadly I have to say that concrete below structures won't probably be possible. Since the filtered deconstruction planner is basically just a standard one with functionality and a GUI on top, it still prioritizes structures over flooring, when "drawing" that selection rectangle. And that is not game logic you can tinker with using mods, so at the moment I can't offer a solution for that problem, sorry. :/

for my subsurface mod, I am developping an alternative to the deconstruction planner for selecting areas, maybe, it could be used to manage removing only concrete (my custom event sends out the area selected and not the entities inside of it !) if you are interested, I can (once I finished it) release it as a small utility mod !

oh, and well done on this mod ! how many times have I wanted to remove only a type of items, and ended up removing items one by one ^^
NearlyDutch
Inserter
Inserter
Posts: 47
Joined: Tue Oct 20, 2015 12:56 pm
Contact:

Re: [MOD 0.12.22] Filtered Deconstruction Planner 0.2.1

Post by NearlyDutch »

Sounds like exactly the solution needed, Stan. Looking forward to that release. Do you make heavy use of the on_tick event? Because those UPS are rare and sacred :D
NearlyDutch
Inserter
Inserter
Posts: 47
Joined: Tue Oct 20, 2015 12:56 pm
Contact:

Re: [MOD 0.12.22] Filtered Deconstruction Planner 0.3.0

Post by NearlyDutch »

Release v0.3.0 adds a different way to select items to filter: the eyedropper tool. (Which you need to target trees, those need to be configured using the eyedropper now)

Image

Changelog:
- Added eyedropper tool to select entities
- Removed configuration slot limit
- Removed need to save before filter is applied
- Fixed item-on-ground issues
- Changed GUI look and feel
Koub
Global Moderator
Global Moderator
Posts: 7784
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: [MOD 0.12.22] Filtered Deconstruction Planner 0.3.0

Post by Koub »

Hi,

I haven't had the time to try your mod yet (having no time to play at all), but was wondering : have you considered using the "let go" shortcut key to "drop" your eyedropper tool ?
Koub - Please consider English is not my native language.
Post Reply

Return to “Mods”