mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add table.key_value_swap (#9248)
This commit is contained in:
parent
3ad92baa9c
commit
f9c7e46a34
2 changed files with 11 additions and 0 deletions
|
@ -575,6 +575,15 @@ function table.insert_all(t, other)
|
||||||
end
|
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
|
-- mainmenu only functions
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
|
@ -2902,6 +2902,8 @@ Helper functions
|
||||||
* `table.insert_all(table, other_table)`:
|
* `table.insert_all(table, other_table)`:
|
||||||
* Appends all values in `other_table` to `table` - uses `#table + 1` to
|
* Appends all values in `other_table` to `table` - uses `#table + 1` to
|
||||||
find new indices.
|
find new indices.
|
||||||
|
* `table.key_value_swap(t)`: returns a table with keys and values swapped
|
||||||
|
* If multiple keys in `t` map to the same value, the result is undefined.
|
||||||
* `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a
|
* `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a
|
||||||
position.
|
position.
|
||||||
* returns the exact position on the surface of a pointed node
|
* returns the exact position on the surface of a pointed node
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue