Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function string.split(str, spl)
- if spl == nil then
- spl = "%s"
- end
- local tab = {}
- for s in string.gmatch(str, "([^"..spl.."]+)") do
- table.insert(tab, s)
- end
- return tab
- end
- mobcount = 0
- mobs = {}
- local lts = fs.list("plugins/loottables")
- for _,entity in pairs(lts) do
- local mob = {}
- mob["Name"] = entity
- mob["Data"] = {}
- local file = fs.open("plugins/loottables/"..entity,"r")
- local line = file.readLine()
- while line do
- local dets = string.split(line, " ")
- local data = {}
- data["Item"] = dets[1]
- data["Count"] = tonumber(dets[2])
- data["Meta"] = tonumber(dets[3])
- data["Chance"] = tonumber(dets[4])
- table.insert(mob["Data"], data)
- line = file.readLine()
- end
- mobs[entity] = mob
- mobcount = mobcount + 1
- print("Loaded Entity #"..mobcount..": "..entity)
- end
- print("Loaded "..mobcount.." mobs")
- parallel.waitForAny(function()
- local c = 0
- while true do
- if c > 10000 then
- c = 0
- sleep(0)
- else
- c = c + 1
- end
- for _,tag in pairs(mobs) do
- if commands.exec("testfor @e[type="..tag["Name"]..",tag=!enhanced]") then
- commands.exec("effect @e[type="..tag["Name"]..",tag=!enhanced] invisibility 100 0 true")
- local sumScript = ""
- local sumScript2 = ""
- local unused = 5
- for _,i in pairs(tag["Data"]) do
- unused = unused - 1
- sumScript = sumScript.."{Count:"..i["Count"]..",id:\""..i["Item"].."\"},"
- sumScript2 = sumScript2..i["Chance"].."F,"
- end
- for i = 1,unused do
- sumScript = sumScript.."{},"
- sumScript2 = sumScript2.."1F,"
- end
- sumScript = sumScript:sub(1,-2)
- sumScript2 = sumScript2:sub(1,-4)
- commands.exec("execute @e[type="..tag["Name"]..",tag=!enhanced] ~ ~ ~ /summon "..tag["Name"].." ~ ~ ~ {ArmorItems:["..sumScript.."],ArmorDropChances:["..sumScript2.."],Tags:[\"enhanced\"]}")
- commands.exec("gamerule doMobLoot false")
- commands.exec("kill @e[type="..tag["Name"]..",tag=!enhanced]")
- commands.exec("gamerule doMobLoot true")
- end
- end
- end
- end,function()
- print("Press any key to cancel")
- os.pullEvent("key")
- end)
Advertisement
Add Comment
Please, Sign In to add comment