aboutsummaryrefslogtreecommitdiff
path: root/ch_core/vgroups.lua
diff options
context:
space:
mode:
authororwell <orwell@bleipb.de>2025-05-27 21:17:10 +0200
committerorwell <orwell@bleipb.de>2025-05-27 21:17:10 +0200
commit3470687be0af7254aca478ead1e9c72757edf070 (patch)
tree41781361c979cfda61a924d7471978037d68005e /ch_core/vgroups.lua
parent8506dd2825b715293138976a5ad1fa11a46206a7 (diff)
downloadadvtrains-cesky-hvozd.tar.gz
advtrains-cesky-hvozd.tar.bz2
advtrains-cesky-hvozd.zip
Add CH dependencies temporarily.cesky-hvozd
Before merge to master should remove them again and split out util functions (e.g. formspec lib)
Diffstat (limited to 'ch_core/vgroups.lua')
-rw-r--r--ch_core/vgroups.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/ch_core/vgroups.lua b/ch_core/vgroups.lua
new file mode 100644
index 0000000..5b43fd8
--- /dev/null
+++ b/ch_core/vgroups.lua
@@ -0,0 +1,32 @@
+ch_core.open_submod("vgroups")
+
+local vgroups = {}
+local private_vgroups = {}
+
+function ch_core.create_private_vgroup(vgroup, tbl)
+ if vgroups[vgroup] then
+ error("Vgroup "..vgroup.." demanded as private already exists!")
+ end
+ local result = tbl or {}
+ vgroups[vgroup] = result
+ private_vgroups[vgroup] = true
+ return result
+end
+
+function ch_core.get_shared_vgroup(vgroup)
+ if private_vgroups[vgroup] then
+ error("Vgroup "..vgroup.." is private!")
+ end
+ local result = vgroups[vgroup]
+ if not result then
+ result = {}
+ vgroups[vgroup] = result
+ end
+ return result
+end
+
+function ch_core.try_read_vgroup(vgroup)
+ return vgroups[vgroup]
+end
+
+ch_core.close_submod("vgroups")