Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local colors = require("colors")
- local sides = require("sides")
- local gpu = component.gpu
- local event = require("event")
- local term = require("term")
- local buttonAPI = require("buttonAPI")
- local redstone = component.redstone
- local filesystem = component.filesystem
- local shardNBT = {}
- shardNBT["459290845737459ef043705871f76e04"] = "Skeleton"
- shardNBT["5601d9da3abb021e1d79fd88804a20c5"] = "Zombie"
- shardNBT["8d792d9a1d11e4732b3c5f3b106b606f"] = "Enderman"
- function getClick()
- local _, _, x, y = event.pull(1,touch)
- if x == nil or y == nil then
- local h, w = gpu.getResolution()
- gpu.set(h, w, ".")
- gpu.set(h, w, " ")
- else
- buttonAPI.checkxy(x,y)
- end
- end
- function buttonAPI.fillTable()
- buttonAPI.setTable("Spawn Mobs (Shard)", spawnMobs, 10, 30, 5, 7)
- buttonAPI.setTable("Place Shard", placeShard, 10, 30, 9, 11)
- buttonAPI.setTable("Extract Shard", extractShard, 10, 30, 13, 15)
- buttonAPI.disableButton("Extract Shard")
- buttonAPI.disableButton("Spawn Mobs (Shard)")
- buttonAPI.setTable("Reset System", reset, 50, 70, 21, 23)
- buttonAPI.screen()
- end
- ---- Functions
- local spawning = false
- local hasShard = false
- local shardHash = ""
- local msgError = ""
- function placeShard()
- msgError = ""
- if(hasShard) then return end
- if(component.chest.getStackInSlot(1) == nil or component.chest.getStackInSlot(1).nbt_hash == nil) then msgError = "No shard found!" return end
- buttonAPI.toggleButton("Place Shard")
- shardHash = component.chest.getStackInSlot(1).nbt_hash
- if(shardNBT[shardHash] == nil) then
- --local file = filesystem.open("/usr/unknownshards.txt", "w")
- --file.write(shardhash)
- --file.close()
- end
- redstone.setBundledOutput(sides.south, colors.brown, 255)
- os.sleep(1)
- redstone.setBundledOutput(sides.south, colors.brown, 0)
- redstone.setBundledOutput(sides.south, colors.green, 255)
- os.sleep(1)
- redstone.setBundledOutput(sides.south, colors.green, 0)
- hasShard = true
- buttonAPI.toggleButton("Place Shard")
- buttonAPI.disableButton("Spawn Mobs (Shard)")
- buttonAPI.disableButton("Extract Shard")
- buttonAPI.disableButton("Place Shard")
- end
- function reset()
- msgError = ""
- buttonAPI.disableButton("Spawn Mobs (Shard)", false)
- buttonAPI.disableButton("Extract Shard", false)
- buttonAPI.disableButton("Place Shard", false)
- buttonAPI.toggleButton("Reset System")
- redstone.setBundledOutput(sides.south, colors.brown, 0)
- redstone.setBundledOutput(sides.south, colors.green, 0)
- redstone.setBundledOutput(sides.south, colors.red, 0)
- redstone.setBundledOutput(sides.top, colors.white, 0)
- hasShard = false
- spawning = false
- redstone.setBundledOutput(sides.south, colors.red, 255)
- os.sleep(1)
- redstone.setBundledOutput(sides.south, colors.red, 0)
- buttonAPI.toggleButton("Reset System")
- buttonAPI.disableButton("Spawn Mobs (Shard)", false)
- buttonAPI.disableButton("Extract Shard", false)
- buttonAPI.disableButton("Place Shard", true)
- end
- function extractShard()
- msgError = ""
- if(not hasShard) then return end
- buttonAPI.toggleButton("Extract Shard")
- buttonAPI.disableButton("Spawn Mobs (Shard)")
- buttonAPI.disableButton("Place Shard")
- redstone.setBundledOutput(sides.south, colors.red, 255)
- os.sleep(1)
- redstone.setBundledOutput(sides.south, colors.red, 0)
- shardHash = ""
- hasShard = false
- buttonAPI.toggleButton("Extract Shard")
- buttonAPI.disableButton("Extract Shard")
- buttonAPI.disableButton("Place Shard", true)
- end
- function spawnMobs()
- msgError = ""
- if(not hasShard) then return end
- buttonAPI.toggleButton("Spawn Mobs (Shard)")
- spawning = not spawning
- redstone.setBundledOutput(sides.top, colors.white, spawning and 255 or 0)
- buttonAPI.disableButton("Extract Shard", not spawning)
- buttonAPI.disableButton("Place Shard", false)
- end
- --useShard()
- --extractShard()
- --spawnMobs(false)
- term.setCursorBlink(false)
- gpu.setResolution(80, 25)
- buttonAPI.clear()
- buttonAPI.fillTable()
- buttonAPI.heading("Soul Shard Spawner - By Subtixx")
- while true do
- if(hasShard) then
- if (shardNBT[shardHash] ~= nil) then
- buttonAPI.label(10, 3, "Active Shard: " .. tostring(shardNBT[shardHash]) .. " ")
- else
- buttonAPI.label(10, 3, "Active Shard: " .. tostring(shardHash) .. " ")
- end
- else
- buttonAPI.label(10, 3, "Active Shard: No Shard ")
- end
- if(msgError ~= "") then
- buttonAPI.label(40, 12, "ERROR: " .. msgError)
- else
- buttonAPI.label(40, 12, " ")
- end
- getClick()
- end
Advertisement
Add Comment
Please, Sign In to add comment