remie92

Untitled

Jul 11th, 2026
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.15 KB | None | 0 0
  1. local HEAD_PART = models.model.root
  2.     .Head                                                                    --model part of the head (this gets scaled)
  3. local DIALOG_NOISE_NAME =
  4. "dialog"                                                                     --audio name for the undertale-y/animal crossing-y sounds
  5. local SPEAK_BIND = keybinds:newKeybind("SpeakText", "key.keyboard.h", false) --Keybind for manually removing/starting the text
  6. local SPEAKING_SPEED = 1.5                                                   --ticks per character
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13. local is_showing_text = false
  14. local dialog_noise = sounds[DIALOG_NOISE_NAME]
  15. local text_to_speak = "{test text, this gets replaced when actual text gets typed}"
  16.  
  17. if (models.model.BILLBOARD) then
  18.     --There is a billboard
  19. else
  20.     print(
  21.         "NO BILLBOARD IN MODEL. ADD A 'BILLBOARD' FOLDER TO YOUR MAIN MODEL.BBMODEL FILE. IT MUST BE EMPTY (OR NOT, but the code does change the pivot of the billboard)")
  22. end
  23. models.model.BILLBOARD:setPivot(0,50,0)
  24. local SpeakTextTask = models.model.BILLBOARD:newText("SpeakTextTask")
  25.  
  26. SpeakTextTask:setAlignment("CENTER"):setScale(0.5)
  27. -- SpeakTextTask:setBackground(true)
  28. -- SpeakTextTask:setBackgroundColor(255 / 255, 20 / 255, 255 / 255, 50 / 255)
  29. SpeakTextTask:setOutline(true)
  30. --SpeakTextTask:setOutlineColor(140 / 255, 20 / 255, 200 / 255)
  31. SpeakTextTask:setOutlineColor(0.4,0,0.6)
  32. SpeakTextTask:setWidth(250)
  33. SpeakTextTask:setSeeThrough(true)
  34.  
  35.  
  36.  
  37. local starting_speaking_tick = 0
  38. local tick_counter = 0
  39. function events.tick()
  40.     tick_counter = tick_counter + 1
  41.     if is_showing_text then
  42.         current_max_character = math.floor((tick_counter - starting_speaking_tick) / SPEAKING_SPEED)
  43.         if current_max_character <= #text_to_speak then
  44.             SpeakTextTask:setText(string.sub(text_to_speak, 1, math.min(current_max_character, #text_to_speak)))
  45.             HEAD_PART:setScale(((math.sin(tick_counter * 2 + 1) + 1) / 30) + 0.9,
  46.                 ((math.sin(tick_counter * 2) + 1) / 17) +
  47.                 0.9, 1)
  48.             if dialog_noise:isPlaying() == false and math.random() > 0.3 then
  49.                 dialog_noise:play():setPos(player:getPos()):setPitch((math.random() * 0.5) + 0.75)
  50.             end
  51.             SpeakTextTask:setRot(0, 0, ((math.sin(tick_counter * 0.5 + 30)) * 2)):setScale((((math.sin(tick_counter * 1 + 14) + 1) / 30) + 0.9) *
  52.                 0.5)
  53.         else
  54.             SpeakTextTask:setScale(0.5)
  55.             SpeakTextTask:setRot(0, 0, ((math.sin(tick_counter * 0.2 + 30)) * 1))
  56.         end
  57.         local blockLight = world.getLightLevel(player:getPos())
  58.         local skyLight = world.getSkyLightLevel(player:getPos())
  59.         SpeakTextTask:setLight(math.max(blockLight, 5), skyLight)
  60.         if (current_max_character - #text_to_speak) * SPEAKING_SPEED > 300 then
  61.             is_showing_text = false
  62.             SpeakTextTask:setVisible(false)
  63.             SpeakTextTask:setText("")
  64.         end
  65.     end
  66. end
  67.  
  68.  
  69. local word_list = {
  70.         -- Red
  71.     fuck = {color = "§c"},
  72.     shit = {color = "§c"},
  73.     goddamn = {color = "§c"},
  74.     danger = {color = "§c"},
  75.     warning = {color = "§c"},
  76.  
  77.     -- Green
  78.     clipboard = {color = "§a"},
  79.     success = {color = "§a"},
  80.     enabled = {color = "§a"},
  81.     online = {color = "§a"},
  82.  
  83.     -- Light Purple
  84.     sylva = {color = "§d"},
  85.     figura = {color = "§d"},
  86.     amethyst = {color = "§d"},
  87.     magic = {color = "§d"},
  88.     mystical = {color = "§d"},
  89.  
  90.     -- Gold
  91.     minecraft = {color = "§6"},
  92.     legendary = {color = "§6"},
  93.     boss = {color = "§6"},
  94.     rare = {color = "§6"},
  95.  
  96.     -- Aqua
  97.     water = {color = "§b"},
  98.     ocean = {color = "§b"},
  99.     sky = {color = "§b"},
  100.     -- Blue
  101.    
  102.     ice = {color = "§9"},
  103.     frost = {color = "§9"},
  104.  
  105.     -- Yellow
  106.     gold = {color = "§e"},
  107.     sun = {color = "§e"},
  108.     bright = {color = "§e"},
  109.  
  110.     trans = {text = "§bt§dr§fa§dn§bs"},
  111.     rainbow = {text = "§cr§6a§ei§an§bb§do§cw"},
  112.     rainbows = {text = "§cr§6a§ei§an§bb§do§cw§6s"},
  113.     doglitch={text="§kglitchy§r"}
  114. }
  115.  
  116. basic_text = "§f"
  117.  
  118. local function text_colorifier(text)
  119.     return text:gsub("%f[%a](%a+)%f[%A]", function(word)
  120.         local data = word_list[word:lower()]
  121.         if not data then
  122.             return word
  123.         end
  124.  
  125.         if data.color then
  126.             return data.color .. word .. basic_text
  127.         end
  128.  
  129.         return data.text .. basic_text
  130.     end)
  131. end
  132.  
  133.  
  134. function pings.start_text(text_func)
  135.     starting_speaking_tick = tick_counter
  136.     text_to_speak = text_colorifier(text_func)
  137.     is_showing_text = true
  138.     SpeakTextTask:setText("")
  139.     SpeakTextTask:setVisible(true)
  140. end
  141.  
  142. function pings.stop_text()
  143.     is_showing_text = false
  144.     SpeakTextTask:setVisible(false)
  145.     SpeakTextTask:setText("")
  146. end
  147.  
  148. function events.chat_send_message(msg)
  149.     pings.start_text(msg)
  150.     return msg
  151.     --return nil --Used for if you don't want chat messages to be sent.
  152. end
  153.  
  154. local function speak_text()
  155.     if is_showing_text == false then
  156.         pings.start_text(host:getClipboard())
  157.     else
  158.         pings.stop_text()
  159.     end
  160. end
  161. SPEAK_BIND:setOnPress(speak_text)
  162.  
Add Comment
Please, Sign In to add comment