Can I call the std clear cursor routine (default Q)?

Place to get help with not working mods / modding interface.
Post Reply
Tinyboss
Fast Inserter
Fast Inserter
Posts: 205
Joined: Sun Nov 16, 2014 12:11 pm
Contact:

Can I call the std clear cursor routine (default Q)?

Post by Tinyboss »

One of the users of my Picker mod told me that he bound it to Q, together with the usual "clear cursor" control. Now I'm trying to design it to replace that control, because it works even better if it can take it over completely.

Unfortunately, this kills the nice new red/green wire behavior in .13, where the first Q cancels a connection in progress, and the second Q clears the cursor. Rail laying also gets changed.

I think the ideal behavior for Picker would be to call the vanilla "clear cursor" routine if the held item is red/green wire or a rail, otherwise do its own thing. Is there a way to accomplish this?

I think maybe the right way to do it is for the player to have Q bound both to Picker and to "clear cursor", and make Picker not consume the Q press, so that it passes on to the default clear cursor handler. I wonder if I can do this with the "consuming" parameter in data.lua, which currently looks like this:

Code: Select all

data:extend({
  {
    type = "custom-input",
    name = "picker-select",
    key_sequence = "Q",
    consuming = "all"
  },
})
I haven't been able to find a reference on the other possible values for "consuming" and what they do. Even if I can't accomplish what I'm trying here, I'd like to know where I can find a reference on custom controls.

Thanks for any help!

User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: Can I call the std clear cursor routine (default Q)?

Post by DedlySpyder »

Rseding gave an example on IRC at one point, I thought he was gonna write something up for the wiki, but I guess he got busy.

Here's his pastebin example.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13223
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Can I call the std clear cursor routine (default Q)?

Post by Rseding91 »

I added a method in 0.13.10 that will do the exact actions on a given player from script.

LuaPlayer::clean_cursor() - for 0.13.10.
If you want to get ahold of me I'm almost always on Discord.

Tinyboss
Fast Inserter
Fast Inserter
Posts: 205
Joined: Sun Nov 16, 2014 12:11 pm
Contact:

Re: Can I call the std clear cursor routine (default Q)?

Post by Tinyboss »

Rseding91 wrote:I added a method in 0.13.10 that will do the exact actions on a given player from script.

LuaPlayer::clean_cursor() - for 0.13.10.
Neat! I worked around it for my specific case already, but who knows who else might benefit from it?

You know what would be even cooler and more widely applicable? The ability for a script to decide for itself whether to consume the hotkey input or pass it down the chain. Is that feasible?

Post Reply

Return to “Modding help”