diff options
author | HybridDog <3192173+HybridDog@users.noreply.github.com> | 2020-01-04 15:44:48 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2020-01-04 15:44:48 +0100 |
commit | f9c7e46a347576c9327aaa0d9b6a5b4cd07c26e2 (patch) | |
tree | 0a1cffa49e854c2e808981383ce07ff2f8f17f5d /builtin/common | |
parent | 3ad92baa9c1e1b4c7b23306b2be1fc4284dd4872 (diff) | |
download | minetest-f9c7e46a347576c9327aaa0d9b6a5b4cd07c26e2.tar.gz minetest-f9c7e46a347576c9327aaa0d9b6a5b4cd07c26e2.tar.bz2 minetest-f9c7e46a347576c9327aaa0d9b6a5b4cd07c26e2.zip |
Add table.key_value_swap (#9248)
Diffstat (limited to 'builtin/common')
-rw-r--r-- | builtin/common/misc_helpers.lua | 9 |
1 files changed, 9 insertions, 0 deletions
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 -------------------------------------------------------------------------------- |