From 9e1d7b572a8a76ae61bdb85515f2c9d228d874d4 Mon Sep 17 00:00:00 2001 From: Someone Date: Mon, 17 Aug 2020 03:37:30 +0200 Subject: [PATCH] Now remembers input-script and it can be executed via CTRL+Enter. RELEASE 1.0.1 --- changelog.txt | 12 ++++++++++++ control.lua | 14 ++++++++++++-- data.lua | 7 ++++++- info.json | 4 ++-- locale/en/en.cfg | 2 +- 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/changelog.txt b/changelog.txt index 68a0d21..7df567f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,15 @@ +--------------------------------------------------------------------------------------------------- +Version: 1.0.1 +Date: 2020-08-17 + + Features: + - Now remembers the input-script. + - Last input can be executed without opening by using keybindings only. + - Default keybinding to execute last input-script: CONTROL + ENTER. + + Changed: + - Default keybinding to open: from SHIFT + RIGHTBRACKET to CONTROL + RIGHTBRACKET. + --------------------------------------------------------------------------------------------------- Version: 1.0.0 Date: 2020-08-14 diff --git a/control.lua b/control.lua index a9bb04f..b5ee73f 100644 --- a/control.lua +++ b/control.lua @@ -5,7 +5,13 @@ function exec_command(player) end local f, err, cmd - cmd = player.gui.left.some_luaconsole.input.text:gsub('game%.player%.', 'game.players['..player.index..'].') + + if player.gui.left.some_luaconsole then + global.cmd = player.gui.left.some_luaconsole.input.text + end + + cmd = global.cmd or "" + cmd = cmd:gsub('game%.player%.', 'game.players['..player.index..'].') f, err = loadstring(cmd) if not f then @@ -23,6 +29,7 @@ end function toggleGui (player) if player.gui.left.some_luaconsole then + global.cmd = player.gui.left.some_luaconsole.input.text player.gui.left.some_luaconsole.destroy() else frame = player.gui.left.add{type = 'frame', @@ -37,7 +44,7 @@ function toggleGui (player) style='some_luaconsole_input_textbox' } input.word_wrap = true - input.focus() + input.text = global.cmd or "" horizontal_flow = frame.add{type='flow', direction='horizontal'} horizontal_flow.add{type = 'button', @@ -74,3 +81,6 @@ end) script.on_event('some_luaconsole_toggle', function(event) toggleGui(game.players[event.player_index]) end) +script.on_event('some_luaconsole_exec', function(event) + exec_command(game.players[event.player_index]) +end) diff --git a/data.lua b/data.lua index fbeeb84..abcbe1e 100644 --- a/data.lua +++ b/data.lua @@ -11,6 +11,11 @@ data:extend({ { type = "custom-input", name = "some_luaconsole_toggle", - key_sequence = "SHIFT + RIGHTBRACKET" + key_sequence = "CONTROL + RIGHTBRACKET" + }, + { + type = "custom-input", + name = "some_luaconsole_exec", + key_sequence = "CONTROL + ENTER" }, }) diff --git a/info.json b/info.json index ca60e72..cc940f0 100644 --- a/info.json +++ b/info.json @@ -1,10 +1,10 @@ { "name": "some-luaconsole", - "version": "1.0.0", + "version": "1.0.1", "title": "Someone's LUA-Console", "author": "someone1337", "homepage": "https://git.somenet.org/factorio/some-luaconsole.git", - "description": "Run lua commands without losing achievements. By default opens with SHIFT + RIGHTBRACKET.", + "description": "Run lua commands without losing achievements. Now remembers input-script. 'game.player' works. By default opens with CONTROL + RIGHTBRACKET. Execute last input-script with CONTROL + ENTER.", "dependencies": ["base>=1.0.0"], "factorio_version": "1.0" } diff --git a/locale/en/en.cfg b/locale/en/en.cfg index 6bbf547..989c08c 100644 --- a/locale/en/en.cfg +++ b/locale/en/en.cfg @@ -1,6 +1,6 @@ [some_luaconsole] title=Someone's LUA-Console -inputlabel=Input to be executed +inputlabel=To be executed (Control + Enter to execute, un-focus textarea!) close=Close close_tooltip=Close without executing input exec=Execute input -- 2.43.0