Page 1 of 1

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

Posted: Wed Jul 20, 2016 1:53 pm
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!

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

Posted: Thu Jul 21, 2016 12:50 am
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.

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

Posted: Thu Jul 21, 2016 7:45 pm
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.

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

Posted: Thu Jul 21, 2016 8:08 pm
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?