Advertisement
SemlerPDX

Mob Farm Chatty Turtle Script

Sep 3rd, 2024 (edited)
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.59 KB | Gaming | 0 0
  1. --Mob Farm Chatty Turtle Script
  2. --v1.1 by SemlerPDX Sept2024
  3.  
  4. -- pastebin get mzzf4cw1 startup
  5.  
  6. local farmOnline = false
  7. local currentState = true
  8. local playerRange = 10
  9.  
  10. local chatBox = peripheral.find("chatBox")
  11. local detector = peripheral.find("playerDetector")
  12.  
  13.  
  14. local titleOn = {
  15.     { text = "Spawner ON", color = "green"}
  16. }
  17.  
  18. local titleOff = {
  19.     { text = "Spawner OFF", color = "red"}
  20. }
  21.  
  22. local messageOn = {
  23.     { text = "I will kill any "},
  24.     { text = "Escaped Mobs ", color = "green"},
  25.     { text = "- you just focus on the murder hole!"}
  26. }
  27.  
  28. local messageOff = {
  29.     { text = "I will now kill "},
  30.     { text = "ALL Mobs ", color = "red"},
  31.     { text = "that continue spawning - go play, have fun!"}
  32. }
  33.  
  34. local titleOnJson = textutils.serializeJSON(titleOn)
  35. local titleOffJson = textutils.serializeJSON(titleOff)
  36. local messageOnJson = textutils.serialiseJSON(messageOn)
  37. local messageOffJson = textutils.serialiseJSON(messageOff)
  38.  
  39. local function SendNotice(online, playerName)
  40.   if online then
  41.     successful, error = chatBox.sendFormattedToastToPlayer(messageOnJson, titleOnJson, playerName, "&4&oMobBot", "()", "&4&o")
  42.   else
  43.     successful, error = chatBox.sendFormattedToastToPlayer(messageOffJson, titleOffJson, playerName, "&4&oMobBot", "()", "&4&o")
  44.   end
  45. end
  46.  
  47.  
  48. while true do
  49.   sleep(1)
  50.   farmOnline = turtle.detectUp()
  51.  
  52.   if not farmOnline == currentState then
  53.     playerNames = detector.getPlayersInRange(playerRange)
  54.     for key,value in pairs(playerNames) do
  55.       SendNotice(currentState, value)
  56.     end
  57.   end
  58.  
  59.   currentState = farmOnline
  60. end
  61.  
Tags: minecraft
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement