aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
authorY. Wang <yw05@forksworld.de>2022-04-11 16:55:50 +0200
committerY. Wang <yw05@forksworld.de>2023-03-23 20:06:02 +0100
commit5c8962b39bd4f6871ec87a988ac43d7bfad04d2b (patch)
treeb30a30fdfa905ef5eabce1528829fa41a8c127a3 /advtrains
parent0b4cdbb455b5ba43b3c8d3fd7af5112021144eaa (diff)
downloadadvtrains-5c8962b39bd4f6871ec87a988ac43d7bfad04d2b.tar.gz
advtrains-5c8962b39bd4f6871ec87a988ac43d7bfad04d2b.tar.bz2
advtrains-5c8962b39bd4f6871ec87a988ac43d7bfad04d2b.zip
Implement basic route signaling with Japanese signals for demo
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/formspec.lua37
-rw-r--r--advtrains/init.lua4
2 files changed, 41 insertions, 0 deletions
diff --git a/advtrains/formspec.lua b/advtrains/formspec.lua
new file mode 100644
index 0000000..91e300d
--- /dev/null
+++ b/advtrains/formspec.lua
@@ -0,0 +1,37 @@
+local sformat = string.format
+local fsescape = minetest.formspec_escape
+
+local function f_button_exit(x, y, w, h, id, text)
+ return sformat("button_exit[%f,%f;%f,%f;%s;%s]", x, y, w, h, id, text)
+end
+
+local function S_button_exit(x, y, w, h, id, ...)
+ return f_button_exit(x, y, w, h, id, attrans(...))
+end
+
+local function f_dropdown(x, y, w, id, entries, sel, indexed)
+ local t = {}
+ for k, v in pairs(entries) do
+ t[k] = fsescape(v)
+ end
+ return sformat("dropdown[%f,%f;%f;%s;%s;%d%s]",
+ x, y, w, id, table.concat(t, ","),
+ sel or 1,
+ indexed and ";true" or "")
+end
+
+local function f_label(x, y, text)
+ return sformat("label[%f,%f;%s]", x, y, fsescape(text))
+end
+
+local function S_label(x, y, ...)
+ return f_label(x, y, attrans(...))
+end
+
+return {
+ button_exit = f_button_exit,
+ S_button_exit = S_button_exit,
+ dropdown = f_dropdown,
+ label = f_label,
+ S_label = S_label,
+}
diff --git a/advtrains/init.lua b/advtrains/init.lua
index a7e5764..1cba255 100644
--- a/advtrains/init.lua
+++ b/advtrains/init.lua
@@ -24,6 +24,9 @@ minetest.log("action", "[advtrains] Loading...")
-- There is no need to support 0.4.x anymore given that the compatitability with it is already broken by 1bb1d825f46af3562554c12fba35a31b9f7973ff
attrans = minetest.get_translator ("advtrains")
+function attrans_formspec(...)
+ return minetest.formspec_escape(attrans(...))
+end
--advtrains
advtrains = {trains={}, player_to_train_mapping={}}
@@ -199,6 +202,7 @@ advtrains.meseconrules =
advtrains.fpath=minetest.get_worldpath().."/advtrains"
advtrains.speed = dofile(advtrains.modpath.."/speed.lua")
+advtrains.formspec = dofile(advtrains.modpath.."/formspec.lua")
dofile(advtrains.modpath.."/path.lua")
dofile(advtrains.modpath.."/trainlogic.lua")