From f9c7e46a347576c9327aaa0d9b6a5b4cd07c26e2 Mon Sep 17 00:00:00 2001 From: HybridDog <3192173+HybridDog@users.noreply.github.com> Date: Sat, 4 Jan 2020 15:44:48 +0100 Subject: Add table.key_value_swap (#9248) --- builtin/common/misc_helpers.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'builtin') diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index 88a498927..199f13cd1 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -575,6 +575,15 @@ function table.insert_all(t, other) end +function table.key_value_swap(t) + local ti = {} + for k,v in pairs(t) do + ti[v] = k + end + return ti +end + + -------------------------------------------------------------------------------- -- mainmenu only functions -------------------------------------------------------------------------------- -- cgit v1.2.3