From eca9963653ed7b403cb72da2f7c7f145c7f6c184 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Fri, 21 Mar 2025 18:49:49 +0100 Subject: [PATCH 1/3] Add example hotkey script --- BauSystem/hotkeys.lua | 89 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 BauSystem/hotkeys.lua diff --git a/BauSystem/hotkeys.lua b/BauSystem/hotkeys.lua new file mode 100644 index 00000000..91f8b7de --- /dev/null +++ b/BauSystem/hotkeys.lua @@ -0,0 +1,89 @@ +-- This file is a part of the SteamWar software. +-- +-- Copyright (C) 2021 SteamWar.de-Serverteam +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU Affero General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Affero General Public License for more details. +-- +-- You should have received a copy of the GNU Affero General Public License +-- along with this program. If not, see . + +--- +--- This serves both as an example and a quick start to the Stewamwar Script Api +--- + +hotkey("ctrl+g", hotkeys_freeze) +hotkey("ctrl+c", hotkeys_rgc) +hotkey("ctrl+v", hotkeys_rgp) +hotkey("ctrl+x", hotkeys_tick_step) +hotkey("shift+x", hotkeys_cycle_trace_view) +hotkey("ctrl+y", hotkeys_tb) +hotkey("ctrl+alt", hotkeys_trace_delete) +hotkey("ctrl+h", hotkeys_trace_delete) + + +function hotkeys_freeze(pressed) + if pressed then + exec("/freeze") + end +end + +function hotkeys_rgc(pressed) + if pressed then + exec("/rgc") + end +end + +function hotkeys_rgp(pressed) + if pressed then + exec("/rgp") + end +end + +trace_cycle_counter = 0; +function hotkeys_cycle_trace_view(pressed) + if not pressed then + return + end + trace_cycle = (trace_cycle + 1) % 3 + trace_commands = {"trace hide", "trace show", "trace show -e -c"} + exec(trace_commands[trace_cycle + 1]) +end + +function hotkeys_tick_step(pressed) + if pressed then + exec("tick step") + end +end + +function hotkeys_tpslimit(pressed) + if not pressed then + return + end + if tps.limit() == 20 then + exec("tpslimit 200") + else + exec("tpslimit 20") + end +end + +function hotkeys_tb(pressed) + if pressed then + exec("tb -e") + end +end + +function hotkeys_trace_delete(pressed) + if pressed then + exec("trace delete") + end +end + + From d22b01f5e6dbe84a6bee3fcca27ad5cfd79bf7e8 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Tue, 25 Mar 2025 21:54:03 +0100 Subject: [PATCH 2/3] Updated copyright --- BauSystem/hotkeys.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem/hotkeys.lua b/BauSystem/hotkeys.lua index 91f8b7de..7d9df865 100644 --- a/BauSystem/hotkeys.lua +++ b/BauSystem/hotkeys.lua @@ -1,6 +1,6 @@ -- This file is a part of the SteamWar software. -- --- Copyright (C) 2021 SteamWar.de-Serverteam +-- Copyright (C) 2025 SteamWar.de-Serverteam -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by From 16f2eaad529cd26e0bea60c06a02401c1dab1760 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Tue, 25 Mar 2025 22:03:52 +0100 Subject: [PATCH 3/3] fixed Script ordering --- BauSystem/hotkeys.lua | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/BauSystem/hotkeys.lua b/BauSystem/hotkeys.lua index 7d9df865..f1182e7a 100644 --- a/BauSystem/hotkeys.lua +++ b/BauSystem/hotkeys.lua @@ -19,16 +19,6 @@ --- This serves both as an example and a quick start to the Stewamwar Script Api --- -hotkey("ctrl+g", hotkeys_freeze) -hotkey("ctrl+c", hotkeys_rgc) -hotkey("ctrl+v", hotkeys_rgp) -hotkey("ctrl+x", hotkeys_tick_step) -hotkey("shift+x", hotkeys_cycle_trace_view) -hotkey("ctrl+y", hotkeys_tb) -hotkey("ctrl+alt", hotkeys_trace_delete) -hotkey("ctrl+h", hotkeys_trace_delete) - - function hotkeys_freeze(pressed) if pressed then exec("/freeze") @@ -86,4 +76,12 @@ function hotkeys_trace_delete(pressed) end end +hotkey("ctrl+g", hotkeys_freeze) +hotkey("ctrl+c", hotkeys_rgc) +hotkey("ctrl+v", hotkeys_rgp) +hotkey("ctrl+x", hotkeys_tick_step) +hotkey("shift+x", hotkeys_cycle_trace_view) +hotkey("ctrl+y", hotkeys_tb) +hotkey("ctrl+alt", hotkeys_trace_delete) +hotkey("ctrl+h", hotkeys_trace_delete)