Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Binary Chat (JimmyChance)
- local module = {}
- module.toByte = function(v)
- if type(v) == "number" then return tostring(v) end
- return v:gsub(".", function(t) return " " .. t:byte() end):gsub("^%s*", "")
- end
- module.toChar = function(v)
- if type(v) == "number" then return v end
- return (" " .. v):gsub("(%s*)(%d+)", function(_, char)
- return char:char()
- end)
- end
- module.toDecimal = function(v)
- return tostring(v):gsub("%d+", function(bin)
- local returned = 0
- for i = 1, #bin do
- local place = 2^(i - 1)
- returned = returned + place * tonumber(bin:sub(-i, -i))
- end
- return returned
- end)
- end
- module.toBinary = function(v)
- return module.toByte(v):gsub("%d+", function(char)
- local number = tonumber(char)
- local returned = ""
- while math.floor(number/2) > 0 do
- local remainder = number % 2
- returned = returned .. remainder
- number = math.floor(number/2)
- end returned = returned .. number
- return ("%08d"):format(tonumber(returned:reverse()))
- end)
- end
- _G.module = module
- onChatted = function(speaker, message)
- local head = speaker.Character and speaker.Character:FindFirstChild("Head")
- if head then
- game:GetService("Chat"):Chat(head, module.toBinary(message), "Red")
- end
- end
- for _, player in next, game.Players:GetPlayers() do
- player.Chatted:connect(function(message)
- onChatted(player, message)
- end)
- end
- game.Players.PlayerAdded:connect(function(player)
- player.Chatted:connect(function(message)
- onChatted(player, message)
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement