Event Request: on_console_cancelled/closed

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
CREE7EN
Manual Inserter
Manual Inserter
Posts: 3
Joined: Tue Nov 24, 2020 4:04 am
Contact:

Event Request: on_console_cancelled/closed

Post by CREE7EN »

hello,

by registering a custom-input on the ESCAPE key, one can check if the player has closed the console, easy enough:

Code: Select all

-- player closed console
script.on_event(
  event("input", "close-console"),
  function (e)
    if has_console_open(e.player_index) then
      set_console_open(e.player_index, false)

      print("> console closed")
    end
  end
)
(pseudo-code)

however, if a player decides to close the console by pressing ENTER with an empty input field, the console closes but no events are sent.
this includes not being able to check if the ENTER key was pressed (via a custom-input), as this event never fires while the console is open.

this is problematic in my case, as i'm dipping my toes into modding and decided to make a mod that interacts with the chat/console in various ways.
checking if a player has closed the console in any way is a crucial part of this mod.

i've seen this thread, but i don't think the use cases are quite similar.

would this be a feasible addition to the api?

- cree7en

//e: or, instead of a whole new event, pipe it through on_console_chat/on_console_command as an empty message/command value (might be dangerous for existing mods? dunno)

Post Reply

Return to “Modding interface requests”