I tried making a morse-code module. Wasn't too hard. Just a neat side project. Only works with letters; I didn't bother adding in punctuation or anything.
Here's an example of using the script:
local morse= require(MorseCodeModule)
local code = morse:TranslateTo("Well hello there sean.")
morse:PlayMorse(code)
Here's the module, but you'll need to download the model to get the sounds I used.
--// Morse Code Key:
local morse = {
["a"] = ".-";
["b"] = "-...";
["c"] = "-.-.";
["d"] = "-..";
["e"] = ".";
["f"] = "..-.";
["g"] = "--.";
["h"] = "....";
["i"] = "..";
["j"] = ".---";
["k"] = "-.-";
["l"] = ".-..";
["m"] = "--";
["n"] = "-.";
["o"] = "---";
["p"] = ".--.";
["q"] = "--.-";
["r"] = ".-.";
["s"] = "...";
["t"] = "-";
["u"] = "..-";
["v"] = "...-";
["w"] = ".--";
["x"] = "-..-";
["y"] = "-.--";
["z"] = "--.."
}
--// Services
local debris = game:GetService("Debris")
--// Modules
local m = {}
--// Sounds
local beep = script:WaitForChild("Beep")
local dash = script:WaitForChild("Dash")
-----------------------------------------------------------------------------------------------------
function m:PlayMorse(code)
for c in code:gmatch(".")do
if(c==".")then
local b = beep:Clone()
b.Parent = workspace
b:Play()
wait()
debris:AddItem(b, 2)
elseif(c=="-")then
local d = dash:Clone()
d.Parent = workspace
d:Play()
wait(0.1)
debris:AddItem(d, 2)
elseif(c==" ")then
wait(0.5)
end
wait(0.15)
end
end
-----------------------------------------------------------------------------------------------
function m:TranslateTo(msg)
local fullCode = ""
for letter in msg:gmatch(".")do
local code = morse[letter:lower()]
if(code)then
fullCode = fullCode..code.." "
end
end
return fullCode
end
-----------------------------------------------------------------------------------------------
return m
I tried running the end audio through a morse code decipher-er, but I couldn't get it to work properly.
Thanks