mirror of
https://github.com/sr229/metastruct-experiments.git
synced 2024-09-20 06:30:36 +00:00
Make Moonbase Alpha TTS work for everyone
Signed-off-by: Ayane Satomi <ayane@vignetteapp.org>
This commit is contained in:
parent
ec47aabee5
commit
da2a1a35ba
2 changed files with 46 additions and 21 deletions
|
@ -1,29 +1,53 @@
|
|||
--@name DECTalk
|
||||
--@author Minori
|
||||
--@include https://gist.githubusercontent.com/sr229/5e6f3a5b03181704a871207c14706499/raw/2ee5b6cfb3a875a5ad2024a38d0131cfb5278785/url-encode.lua as henke.txt
|
||||
--@client
|
||||
|
||||
--@shared
|
||||
local soundref
|
||||
require("henke.txt")
|
||||
|
||||
-- Check if client has permission
|
||||
if not hasPermission("bass.loadURL", "https://tts.cyzon.us/tts") then return end
|
||||
if SERVER then
|
||||
-- haaugh
|
||||
chip():setNoDraw(true)
|
||||
|
||||
hook.add("playerchat", "aeiou", function(ply, txt)
|
||||
if ply ~= owner() then return end
|
||||
if string.sub(txt, 1, 1) ~= ";" then return end
|
||||
|
||||
txt = string.sub(txt, 2)
|
||||
if #txt < 1 then return end
|
||||
|
||||
txt = urlencode(txt)
|
||||
|
||||
bass.loadURL("https://tts.cyzon.us/tts?text=" .. txt, "3d", function(a, err, name)
|
||||
-- we dispose the current reference, then we create a new one
|
||||
if soundref then soundref:stop() end
|
||||
soundref = a
|
||||
|
||||
hook.add("think", "soundFollow", function() a:setPos(owner():getPos()) end)
|
||||
soundref:play()
|
||||
hook.add("PlayerSay", "tts_msg", function(ply, txt)
|
||||
-- instead of limiting to owner()
|
||||
-- we do a little trolling and give it to everyone
|
||||
if ply and string.sub(txt, 1, 1) == ";" then
|
||||
-- broadcast who sent it
|
||||
net.start("aeiou")
|
||||
-- send user ID (32-bit)
|
||||
net.writeInt(ply:getUserID(), 32)
|
||||
-- send user msg (string)
|
||||
net.writeString(string.sub(txt, 2))
|
||||
net.send()
|
||||
-- do not broadcast original msg to client
|
||||
-- BUG: only works for owner()
|
||||
--return ""
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
if CLIENT then
|
||||
if not hasPermission("bass.loadURL", "https://tts.cyzon.us/tts") then return end
|
||||
print("DECTalk loaded on client. Type ;<text> to use it.")
|
||||
|
||||
net.receive("aeiou", function()
|
||||
local plyAuthor = player(net.readInt(32))
|
||||
local msg = net.readString()
|
||||
|
||||
bass.loadURL("https://tts.cyzon.us/tts?text=" .. urlencode(msg), "3d", function(a, e, n)
|
||||
if soundref then
|
||||
soundref:destroy()
|
||||
end
|
||||
|
||||
soundref = a
|
||||
|
||||
hook.add("Think", "followSound", function()
|
||||
soundref:setPos(plyAuthor:getPos())
|
||||
end)
|
||||
|
||||
soundref:setVolume(1.3)
|
||||
soundref:play()
|
||||
end)
|
||||
end)
|
||||
end
|
|
@ -91,6 +91,7 @@ if CLIENT then
|
|||
end
|
||||
end)
|
||||
|
||||
sound:setVolume(1.3)
|
||||
sound:play()
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue