You've already forked rdsspy-lua-host
mirror of
https://github.com/KubaPro010/rdsspy-lua-host.git
synced 2026-02-27 10:55:04 +01:00
console as one way interface, and custom command along other things
This commit is contained in:
@@ -1,18 +1,23 @@
|
||||
ert_group = -1
|
||||
ert_string = string.rep(" ", 128)
|
||||
local ert_group = -1
|
||||
local ert_string = string.rep("_", 128)
|
||||
local ert_last_carriage = -1
|
||||
local ert_console_log = false
|
||||
|
||||
function command(cmd, param)
|
||||
if cmd:lower() == "request" then
|
||||
if cmd:lower() == "request" and param:lower() == "decoderdata" then
|
||||
local cr_pos = ert_string:find("\r", 1, true) -- true means "plain search" (faster)
|
||||
local display_text
|
||||
|
||||
if cr_pos then
|
||||
display_text = ert_string:sub(1, cr_pos - 1)
|
||||
else
|
||||
-- No CR found yet, show the whole 128 bytes (trimmed of trailing spaces)
|
||||
display_text = ert_string:gsub("%s+$", "")
|
||||
if cr_pos then display_text = ert_string:sub(1, cr_pos - 1)
|
||||
else display_text = ert_string:gsub("%s+$", "")
|
||||
end
|
||||
db.add_value("ERT", display_text)
|
||||
elseif cmd:lower() == "resetdata" then
|
||||
ert_group = -1
|
||||
ert_string = string.rep("_", 128)
|
||||
ert_last_carriage = -1
|
||||
if ert_console_log then log("ERT data reset.")
|
||||
else set_console_mode(true) end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,7 +25,7 @@ function group(stream, b_corr, a, b, c, d)
|
||||
if stream ~= 0 and a ~= 0 then return
|
||||
elseif stream ~= 0 and not db.load_boolean("rdsspy.ini", "General", "Tunnelling", false) then return end
|
||||
|
||||
if b_corr then return end
|
||||
if b_corr or b < 0 or c < 0 or d < 0 then return end
|
||||
|
||||
local group = (b & 0xf000) >> 12
|
||||
local group_version = (b & 0x800) >> 11
|
||||
@@ -41,5 +46,18 @@ function group(stream, b_corr, a, b, c, d)
|
||||
local new_chars = char1..char2..char3..char4
|
||||
local start_pos = (ert_state * 4) + 1
|
||||
ert_string = ert_string:sub(1, start_pos - 1) .. new_chars .. ert_string:sub(start_pos + 4)
|
||||
|
||||
local ert_carriage = ert_string:find("\r", 1, true)
|
||||
if ert_carriage ~= ert_last_carriage and ert_carriage ~= nil and ert_console_log then
|
||||
log("New ERT string received.")
|
||||
ert_last_carriage = ert_carriage
|
||||
elseif not ert_console_log then
|
||||
local display_text
|
||||
|
||||
if ert_carriage then display_text = ert_string:sub(1, ert_carriage - 1)
|
||||
else display_text = ert_string:gsub("%s+$", "") end
|
||||
|
||||
set_console(string.format("ERT: %s", display_text))
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user