refactor(gate): streamline gate installers and support multi-station codes via splitCsv
This commit is contained in:
+6
-5
@@ -97,7 +97,7 @@ term.setCursorPos(1, 1)
|
||||
print("Bidirectional Ticket Gate Installer")
|
||||
print("")
|
||||
|
||||
local stationCode = trim(prompt("Station code: "))
|
||||
local stationCode = trim(prompt("Station code(s) [comma or / separated]: "))
|
||||
if #stationCode == 0 then
|
||||
print("No station code provided.")
|
||||
return
|
||||
@@ -110,16 +110,17 @@ local backRaw = prompt("Back mode (entry/exit): ")
|
||||
local frontMode = normalizeMode(frontRaw)
|
||||
local backMode = normalizeMode(backRaw)
|
||||
|
||||
local parsedCodes = splitCsv(stationCode)
|
||||
local cfg = {
|
||||
station_codes = { stationCode },
|
||||
station_code = stationCode,
|
||||
station_codes = parsedCodes,
|
||||
station_code = parsedCodes[1] or stationCode,
|
||||
side_modes = {
|
||||
front = frontMode,
|
||||
back = backMode,
|
||||
},
|
||||
side_station_codes = {
|
||||
front = stationCode,
|
||||
back = stationCode,
|
||||
front = parsedCodes[1] or stationCode,
|
||||
back = parsedCodes[1] or stationCode,
|
||||
}
|
||||
}
|
||||
local okCfg, cfgJson = pcall(textutils.serializeJSON, cfg)
|
||||
|
||||
Reference in New Issue
Block a user