File tree 2 files changed +11
-0
lines changed
2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -575,6 +575,15 @@ function table.insert_all(t, other)
575
575
end
576
576
577
577
578
+ function table .key_value_swap (t )
579
+ local ti = {}
580
+ for k ,v in pairs (t ) do
581
+ ti [v ] = k
582
+ end
583
+ return ti
584
+ end
585
+
586
+
578
587
---- ----------------------------------------------------------------------------
579
588
-- mainmenu only functions
580
589
---- ----------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -2902,6 +2902,8 @@ Helper functions
2902
2902
* `table.insert_all(table, other_table)`:
2903
2903
* Appends all values in `other_table` to `table` - uses `#table + 1` to
2904
2904
find new indices.
2905
+ * `table.key_value_swap(t)`: returns a table with keys and values swapped
2906
+ * If multiple keys in `t` map to the same value, the result is undefined.
2905
2907
* `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a
2906
2908
position.
2907
2909
* returns the exact position on the surface of a pointed node
You can’t perform that action at this time.
0 commit comments