Skip to content

Instantly share code, notes, and snippets.

@TheTurkeyDev
Created February 19, 2020 06:06
Show Gist options
  • Save TheTurkeyDev/5ae139ee6e59f41c86840a692110ddb6 to your computer and use it in GitHub Desktop.
Save TheTurkeyDev/5ae139ee6e59f41c86840a692110ddb6 to your computer and use it in GitHub Desktop.
Lua script to connect to Blargerist's 7DaysToStream App NamedPipe
local function splitOnSpace(s)
chunks = {}
for substring in string.gmatch(s, "%S+") do
table.insert(chunks, substring)
end
return chunks
end
local function parseInput(line)
local match = string.match(line, '[a-zA-Z]+')
if match == 'PING' then
--TODO:--
elseif match == 'Action' then
local args = splitOnSpace(string.sub(line, string.len(match) + 3))
print('Action: ' .. args[1] .. " [" .. table.concat(args, ", ", 2) .. "]")
--Add game logic here for this action--
elseif match == 'Message' then
local message = string.sub(line, string.len(match) + 3)
print(message)
--Add game logic here for this message--
else
print('Unknown packet type!: ' .. match)
end
end
while true do
--Replace "Raft" with the name of the connection/ pipe you want to connect to--
for line in io.lines('\\\\.\\pipe\\Raft') do
parseInput(line)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment