summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
Diffstat (limited to 'builtin')
-rw-r--r--builtin/common/misc_helpers.lua25
-rw-r--r--builtin/game/auth.lua25
2 files changed, 25 insertions, 25 deletions
diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua
index 68481f7c8..d162bc0a2 100644
--- a/builtin/common/misc_helpers.lua
+++ b/builtin/common/misc_helpers.lua
@@ -723,3 +723,28 @@ function core.pointed_thing_to_face_pos(placer, pointed_thing)
end
return fine_pos
end
+
+function core.string_to_privs(str, delim)
+ assert(type(str) == "string")
+ delim = delim or ','
+ local privs = {}
+ for _, priv in pairs(string.split(str, delim)) do
+ privs[priv:trim()] = true
+ end
+ return privs
+end
+
+function core.privs_to_string(privs, delim)
+ assert(type(privs) == "table")
+ delim = delim or ','
+ local list = {}
+ for priv, bool in pairs(privs) do
+ if bool then
+ list[#list + 1] = priv
+ end
+ end
+ return table.concat(list, delim)
+end
+
+assert(core.string_to_privs("a,b").b == true)
+assert(core.privs_to_string({a=true,b=true}) == "a,b")
diff --git a/builtin/game/auth.lua b/builtin/game/auth.lua
index 8cb4ebf57..7a6be8788 100644
--- a/builtin/game/auth.lua
+++ b/builtin/game/auth.lua
@@ -4,31 +4,6 @@
-- Authentication handler
--
-function core.string_to_privs(str, delim)
- assert(type(str) == "string")
- delim = delim or ','
- local privs = {}
- for _, priv in pairs(string.split(str, delim)) do
- privs[priv:trim()] = true
- end
- return privs
-end
-
-function core.privs_to_string(privs, delim)
- assert(type(privs) == "table")
- delim = delim or ','
- local list = {}
- for priv, bool in pairs(privs) do
- if bool then
- list[#list + 1] = priv
- end
- end
- return table.concat(list, delim)
-end
-
-assert(core.string_to_privs("a,b").b == true)
-assert(core.privs_to_string({a=true,b=true}) == "a,b")
-
core.auth_file_path = core.get_worldpath().."/auth.txt"
core.auth_table = {}