Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function delta_encode(str)
- local delta = ''
- local last = 0
- for i = 1,string.len(str) do
- local n = string.byte(string.sub(str,i,i))
- delta = delta .. string.byte(string.sub(str,i,i))-last .. ' '
- last = n
- end
- delta = string.sub(delta,1,string.len(delta)-1)
- return delta
- end
- function delta_decode(delta)
- local sdelta = string.split(delta,' ')
- local last = sdelta[1]
- local str = string.char(last)
- for i = 2,#sdelta do
- local n = tonumber(sdelta[i])
- last = last+n
- str = str .. string.char(last)
- end
- return str
- end
- local char = owner.Character
- local head = char['Head']
- BillboardGui0 = Instance.new("BillboardGui")
- TextBox1 = Instance.new("TextBox")
- BillboardGui0.Parent = head
- BillboardGui0.LightInfluence = 1
- BillboardGui0.Size = UDim2.new(8, 0, 3, 0)
- BillboardGui0.Active = true
- BillboardGui0.ClipsDescendants = true
- BillboardGui0.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
- BillboardGui0.SizeOffset = Vector2.new(0, 2)
- TextBox1.Parent = BillboardGui0
- TextBox1.Size = UDim2.new(1, 0, 1, 0)
- TextBox1.BackgroundColor = BrickColor.new("Institutional white")
- TextBox1.BackgroundColor3 = Color3.new(1, 1, 1)
- TextBox1.BackgroundTransparency = 1
- TextBox1.Font = Enum.Font.SourceSans
- TextBox1.FontSize = Enum.FontSize.Size14
- TextBox1.TextColor = BrickColor.new("Institutional white")
- TextBox1.TextColor3 = Color3.new(1, 1, 1)
- TextBox1.TextScaled = true
- TextBox1.TextSize = 14
- TextBox1.TextStrokeTransparency = 0
- TextBox1.TextWrap = true
- TextBox1.TextWrapped = true
- function test(str)
- local d = delta_encode(str)
- local s = delta_decode(d)
- TextBox1.Text = 'encoded: ' .. d .. '\n decoded: ' .. s
- end
- owner.Chatted:Connect(function(msg)
- if msg:lower():sub(1,4) == 'enc/' then
- local str = msg:sub(5)
- if str then
- test(str)
- end
- elseif msg:lower():sub(1,7) == '/e enc/' then
- local str = msg:sub(8)
- if str then
- test(str)
- end
- end
- end)
Add Comment
Please, Sign In to add comment