Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- addLoc = peripheral.wrap("top")
- local ores = {"15:0","14:0", "2001:0"}
- if not fs.exists("/ores") then
- print ("creating ores file")
- local f = io.open("/ores", "w")
- f:write(textutils.serialize(ores))
- f:close()
- end
- function copyToDisk()
- if fs.exists("/disk") then
- local f = io.open("/disk/ores", "w")
- f:write(textutils.serialize(ores))
- f:close()
- end
- end
- function getOresFile()
- local f = io.open("/ores", "r")
- local data = f:read("*l")
- ores = textutils.unserialize(data)
- f:close()
- copyToDisk()
- end
- function isOre(ore)
- for k,v in pairs(ores) do
- if (ore == v) then
- return true
- end
- end
- return false
- end
- function addOre()
- local rawOre = addLoc.getStackInSlot(1)
- if rawOre ~= nil then
- iName = rawOre["name"]
- local oreAdd = tostring(rawOre["id"])..":"..tostring(rawOre["dmg"])
- --list.append(ores, oreAdd)
- if isOre(oreAdd) then
- print(rawOre["name"].." is already in the filter")
- elseif string.find(iName, "Ore") == nil and string.find(iName, "ore") == nil then
- print ("this is not an Ore")
- else
- fs.delete("/ores")
- local leng = table.getn(ores) + 1
- ores[leng] = oreAdd
- local f = io.open("/ores", "w")
- f:write(textutils.serialize(ores))
- f:close()
- getOresFile()
- print("Added "..iName)
- end
- else
- print("there is nothing in the first slot of the chest")
- end
- end
- getOresFile()
- addOre()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement