Hi,
I'm trying to build a QoL mod, which I'd like in some aspects to behave like the standard build key. Specifically, I'd like to press my binding (control-mouse-1) and make it possible to drag the mouse over a series of entities and act on them. That's similar to what build-click or fill-click do. I get the initial press with a custom-input and associated on_event easily, but I'm not getting any more events when the selection changes or when the button is released, so I'm a bit at a loss there.
Is there a way to do what I want?
OG.
Tracking a multiple selection
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Tracking a multiple selection
The "drag & draw" style actions you mention are not exposed to the Lua API, you'll have to build something yourself. If you want more specific hints you'll need to describe what you're trying to do in more detail. Here's a few generic hints:
defines.events.on_selected_entity_changed notifies you when the players cursor hovers over a different entity (or none?) than before.
Autofill (Modportal) might have code related to what you want to do.
If a square selection works for you there's also Selection Tool item type with associated event: defines.events.on_player_selected_area
defines.events.on_selected_entity_changed notifies you when the players cursor hovers over a different entity (or none?) than before.
Autofill (Modportal) might have code related to what you want to do.
If a square selection works for you there's also Selection Tool item type with associated event: defines.events.on_player_selected_area
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Tracking a multiple selection
I'm trying to do https://mods.factorio.com/mods/galibert ... dPlacement. Square selection wouldn't work, I'll see what autofill does. Thanks for the hints.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Tracking a multiple selection
I'm not sure how modifier keys like ctrl interact with custom hotkey events. You'll have to look at autofill for that. (report back tho, kinda interested ).
If it doesn't work you could still implement a toggle-build-mode switching between normal and blueprint-fill. Also take care when reving ghosts that are fast-replacable with themselfs (inserters, belts, drills,...). Circuit connections don't properly resurrect on those if done wrong (and was labeled not-a-bug *sigh*). I tried to make something similar myself before (here's some unfinished sample code) and came to the conclusion that it would be easier to have a seperate item using on_put_item that revives ghosts from items in inventory instead of having to build the exact thing on them. Sort of like a "fill-brush".
If it doesn't work you could still implement a toggle-build-mode switching between normal and blueprint-fill. Also take care when reving ghosts that are fast-replacable with themselfs (inserters, belts, drills,...). Circuit connections don't properly resurrect on those if done wrong (and was labeled not-a-bug *sigh*). I tried to make something similar myself before (here's some unfinished sample code) and came to the conclusion that it would be easier to have a seperate item using on_put_item that revives ghosts from items in inventory instead of having to build the exact thing on them. Sort of like a "fill-brush".
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Tracking a multiple selection
Not sure what you mean. At least I can tell you that key_sequence = "CONTROL + mouse-button-1" works as I expected it, and in particular does *not* invoke item placement.eradicator wrote:I'm not sure how modifier keys like ctrl interact with custom hotkey events. You'll have to look at autofill for that. (report back tho, kinda interested ).
Yeah, that would work, nowhere near as nicely though obviously.eradicator wrote:If it doesn't work you could still implement a toggle-build-mode switching between normal and blueprint-fill.
I suspect they resurrected properly then the entity was replaced by an identical one and they went away. In my case C-M1 does not invoke item placement so I think the second step won't happen. In-place upgrade killing wiring is sad though. Wires are iffy anyway w.r.t ghosts, and copper wires are the iffiest (you can't blueprint them, bye bye power control tricks).eradicator wrote:Also take care when reving ghosts that are fast-replacable with themselfs (inserters, belts, drills,...). Circuit connections don't properly resurrect on those if done wrong (and was labeled not-a-bug *sigh*).
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Tracking a multiple selection
I mean that the normal mouseclick is draggable while ctrl+lmb is probably not? And i don't know how autofill does it because i've actually never used it ;P.galibert wrote:Not sure what you mean. At least I can tell you that key_sequence = "CONTROL + mouse-button-1" works as I expected it, and in particular does *not* invoke item placement.eradicator wrote:I'm not sure how modifier keys like ctrl interact with custom hotkey events. You'll have to look at autofill for that. (report back tho, kinda interested ).
Some of the uglyness could be "fixed" by a complicated user-intention-detection algorithm that tries to guess what the user is trying to do. I.e. standing near ghost? Did just place a blueprint? But that's a lot of work. Which is why i concluded that i'd go for a "fill-brush" style item.galibert wrote:Yeah, that would work, nowhere near as nicely though obviously.eradicator wrote:If it doesn't work you could still implement a toggle-build-mode switching between normal and blueprint-fill.
You can read the detailed description if you want: Self-replacable entity revive in on_put_item. If i ever have time and motivation i might make a video that properly demonstrates the behavior. Maybe then they recognize it's a bug. But probably not before 0.16.galibert wrote:I suspect they resurrected properly then the entity was replaced by an identical one and they went away. In my case C-M1 does not invoke item placement so I think the second step won't happen. In-place upgrade killing wiring is sad though. Wires are iffy anyway w.r.t ghosts, and copper wires are the iffiest (you can't blueprint them, bye bye power control tricks).eradicator wrote:Also take care when reving ghosts that are fast-replacable with themselfs (inserters, belts, drills,...). Circuit connections don't properly resurrect on those if done wrong (and was labeled not-a-bug *sigh*).
Hm...yea. If you trigger that by an event that doesn't also trigger normal build the bug wouldn't happen. I only tested without modifier because that was the behavior i wanted.
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Tracking a multiple selection
Ctrl-LMB is also used in vanilla to fill/empty entities (with ammo, coal, modules, etc), which is definitely draggable. Technically, it's not purely dragging too, since you can have the same effect with the mouse standing still but the player moving.eradicator wrote:I mean that the normal mouseclick is draggable while ctrl+lmb is probably not? And i don't know how autofill does it because i've actually never used it ;P.
What's missing is being able to get activate/deactivate events on custom inputs. Which is probably not entirely trivial if you want to allow movement, etc. Sadly, implementing the behaviour I want would take five minutes with source access. To which you add a couple of days to decide whether you want a different input than entity-fill, to name it, to translate it and to create the text and screenshot for the start-of-game hint, and of course testing. But I digress. I hope we get something similar in vanilla at one point, it would make early-game blueprints so much nicer.