Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Farmcontrol V6.01
- --written in 07/2021 by Kay Michaelsen
- --updated in 02/2025
- --
- --vardef
- --
- monitor1 = peripheral.wrap("monitor_1")
- monitor2 = peripheral.wrap("monitor_4")
- monitor3 = peripheral.wrap("monitor_7")
- --monitor4 = peripheral.wrap("monitor_56")
- rss = peripheral.wrap("meBridge_0")
- --
- obergrenze = 50000
- aSeeds = 0
- aPro = 0
- myst = "mysticalagriculture:"
- imm = "immersiveengineering:"
- automat = true
- dPage = 1
- dMax = 0
- seeds = {}
- seeds[1] = myst.."inferium_seeds"
- seeds[2] = myst.."osmium_seeds"
- seeds[3] = myst.."uranium_seeds"
- seeds[4] = myst.."nether_star_seeds"
- seeds[5] = myst.."nether_quartz_seeds"
- seeds[6] = myst.."lead_seeds"
- seeds[7] = myst.."glowstone_seeds"
- seeds[8] = myst.."enderman_seeds"
- seeds[9] = myst.."emerald_seeds"
- seeds[10] = myst.."diamond_seeds"
- seeds[11] = myst.."redstone_seeds"
- seeds[12] = myst.."copper_seeds"
- seeds[13] = myst.."wither_skeleton_seeds"
- seeds[14] = myst.."netherite_seeds"
- seeds[15] = myst.."lapis_lazuli_seeds"
- seeds[16] = myst.."ghast_seeds"
- seeds[17] = myst.."certus_quartz_seeds"
- seeds[18] = myst.."gold_seeds"
- seeds[19] = myst.."blaze_seeds"
- seeds[20] = myst.."platinum_seeds"
- seeds[21] = myst.."dye_seeds"
- seeds[22] = myst.."cobalt_seeds"
- seeds[23] = myst.."creeper_seeds"
- seeds[24] = myst.."nature_seeds"
- seeds[25] = imm.."seeds"
- seeds[26] = myst.."coal_seeds"
- seeds[27] = myst.."chicken_seeds"
- seeds[28] = myst.."iron_seeds"
- seeds[29] = myst.."silver_seeds"
- seeds[30] = myst.."dirt_seeds"
- seeds[31] = myst.."honey_seeds"
- seeds[32] = myst.."rabbit_seeds"
- seeds[33] = myst.."allthemodium_seeds"
- seeds[34] = myst.."vibranium_seeds"
- seeds[35] = myst.."unobtainium_seeds"
- aSeeds = 35
- pName = {}
- pDN = {}
- pLine = {}
- pStat = {}
- pByte = {}
- pFound = {}
- pStored = {}
- pSide = {}
- pMax = {}
- aPro = 35
- dMax = math.floor(aPro / 18) +1
- for zahl = 1, aPro do
- pMax[zahl] = obergrenze
- end
- for lauf = 1,14 do
- pSide[lauf] = 1
- end
- for lauf = 1, aPro do
- pStored[lauf] = 0
- end
- pName[1] = "minecraft:glowstone_dust"
- pDN[1] = "GlowStone"
- pLine[1] = "green"
- pStat[1] = false
- pByte[1] = colors.green
- pSide[1] = 1
- pMax[1] = 100000
- pName[2] = "minecraft:white_wool"
- pDN[2] = "White Wool"
- pLine[2] = "brown"
- pStat[2] = false
- pByte[2] = colors.brown
- pSide[2] = 1
- pMax[2] = 50000
- pName[3] = "minecraft:iron_ingot"
- pDN[3] = "Iron"
- pLine[3] = "blue"
- pStat[3] = false
- pByte[3] = colors.blue
- pSide[3] = 1
- pMax[3] = 100000
- pName[4] = myst.."inferium_essence"
- pDN[4] = "Inferium"
- pLine[4] = "purple"
- pStat[4] = true
- pByte[4] = colors.purple
- pSide[4] = 1
- pMax[4] = 150000
- pName[5] = "minecraft:quartz"
- pDN[5] = "Neth.Quartz"
- pLine[5] = "cyan"
- pStat[5] = false
- pByte[5] = colors.cyan
- pSide[5] = 1
- pMax[5] = 100000
- pName[6] = "minecraft:redstone"
- pDN[6] = "Redstone"
- pLine[6] = "lightGray"
- pStat[6] = false
- pByte[6] = colors.lightGray
- pSide[6] = 1
- pMax[6] = 100000
- pName[7] = "ae2:certus_quartz_crystal"
- pDN[7] = "Certus"
- pLine[7] = "gray"
- pStat[7] = true
- pByte[7] = colors.gray
- pSide[7] = 1
- pName[8] = "minecraft:coal"
- pDN[8] = "Coal"
- pLine[8] = "pink"
- pStat[8] = true
- pByte[8] = colors.pink
- pSide[8] = 1
- pName[9] ="minecraft:blaze_rod"
- pDN[9] = "Blaze Rod"
- pLine[9] = "lime"
- pStat[9] = false
- pByte[9] = colors.lime
- pSide[9] = 1
- pName[10] = "minecraft:gold_ingot"
- pDN[10] = "Gold"
- pLine[10] = "lightBlue"
- pStat[10] = false
- pByte[10] = colors.lightBlue
- pSide[10] = 1
- pName[11] = "minecraft:bone_meal"
- pDN[11] = "Bone meal"
- pLine[11] = "orange"
- pStat[11] = false
- pByte[11] = colors.orange
- pSide[11] = 1
- pName[12] = "minecraft:ender_pearl"
- pDN[12] = "Ender Pearl"
- pLine[12] = "white"
- pStat[12] = false
- pByte[12] = colors.white
- pSide[12] = 2
- pName[13] = "allthemodium:vibranium_ingot"
- pDN[13] = "Vibranium"
- pLine[13] = "green"
- pStat[13] = true
- pByte[13] = colors.green
- pSide[13] = 2
- pName[14] = "minecraft:ghast_tear"
- pDN[14] = "Ghast Tear"
- pLine[14] = "black"
- pStat[14] = true
- pByte[14] = colors.black
- pMax[14] = 10000
- pSide[14] = 1
- pName[15] = "allthemodium:unobtainium_ingot"
- pDN[15] = "Unobtainium"
- pLine[15] = "brown"
- pStat[15] = true
- pByte[15] = colors.brown
- pSide[15] = 2
- pMax[15] = 10000
- pName[16] = "minecraft:netherite_ingot"
- pDN[16] = "Netherite"
- pLine[16] = "purple"
- pStat[16] = true
- pByte[16] = colors.purple
- pSide[16] = 2
- pMax[16] = 10000
- pName[17] = "alltheores:enderium_ingot"
- pDN[17] = "Enderium"
- pLine[17] = "cyan"
- pStat[17] = true
- pByte[17] = colors.cyan
- pSide[17] = 2
- pMax[17] = 30000
- pName[18] = "minecraft:nether_star"
- pDN[18] = "Nether Star"
- pLine[18] = "lightGray"
- pStat[18] = true
- pByte[18] = colors.lightGray
- pSide[18] = 2
- pMax[18] = 20000
- pName[19] = "allthemodium:allthemodium_ingot"
- pDN[19] = "Allthemodium"
- pLine[19] = "gray"
- pStat[19] = true
- pByte[19] = colors.gray
- pSide[19] = 2
- pMax[19] = 20000
- pName[20] = "minecraft:diamond"
- pDN[20] = "Diamond"
- pLine[20] = "pink"
- pStat[20] = true
- pByte[20] = colors.pink
- pSide[20] = 2
- pMax[20] = 30000
- pName[21] = "minecraft:emerald"
- pDN[21] = "Emerald"
- pLine[21] = "lime"
- pStat[21] = true
- pByte[21] = colors.lime
- pSide[21] = 2
- pMax[21] = 30000
- pName[22] = "minecraft:obsidian"
- pDN[22] = "Obsidian"
- pLine[22] = "yellow"
- pStat[22] = true
- pByte[22] = colors.yellow
- pSide[22] = 2
- pMax[22] = 50000
- pName[23] = "mekanism:ingot_refined_obsidian"
- pDN[23] = "Ref.Obsidian"
- pLine[23] = "magenta"
- pStat[23] = true
- pByte[23] = colors.magenta
- pSide[23] = 1
- pMax[23] = 30000
- pName[24] = "alltheores:osmium_ingot"
- pDN[24] = "Osmium"
- pLine[24] = "yellow"
- pStat[24] = true
- pByte[24] = colors.yellow
- pSide[24] = 1
- pMax[24] = 30000
- pName[25] = "alltheores:tin_ingot"
- pDN[25] = "Tin"
- pLine[25] = "green"
- pStat[25] = true
- pByte[25] = colors.green
- pSide[25] = 3
- pMax[25] = 50000
- pName[26] = "alltheores:bronze_ingot"
- pDN[26] = "Bronze"
- pLine[26] = "brown"
- pStat[26] = true
- pByte[26] = colors.brown
- pSide[26] = 3
- pMax[26] = 30000
- pName[27] = "alltheores:zinc_ingot"
- pDN[27] = "Zinc"
- pLine[27] = "blue"
- pStat[27] = true
- pByte[27] = colors.blue
- pSide[27] = 3
- pMax[27] = 50000
- pName[28] = "alltheores:aluminum_ingot"
- pDN[28] = "Aluminum"
- pLine[28] = "purple"
- pStat[28] = true
- pByte[28] = colors.purple
- pSide[28] = 3
- pMax[28] = 50000
- pName[29] = "alltheores:steel_ingot"
- pDN[29] = "Steel"
- pLine[29] = "cyan"
- pStat[29] = true
- pByte[29] = colors.cyan
- pSide[29] = 3
- pMax[29] = 50000
- pName[30] = "alltheores:silver_ingot"
- pDN[30] = "Silver"
- pLine[30] = "gray"
- pStat[30] = true
- pByte[30] = colors.gray
- pSide[30] = 3
- pMax[30] = 50000
- pName[31] = "alltheores:lead_ingot"
- pDN[31] = "Lead"
- pLine[31] = "lightGray"
- pStat[31] = true
- pByte[31] = colors.lightGray
- pSide[31] = 3
- pMax[31] = 50000
- pName[32] = "minecraft:copper_ingot"
- pDN[32] = "Copper"
- pLine[32] = "pink"
- pStat[32] = true
- pByte[32] = colors.pink
- pSide[32] = 3
- pMax[32] = 100000
- pName[33] = "alltheores:brass_ingot"
- pDN[33] = "Brass"
- pLine[33] = "lime"
- pStat[33] = true
- pByte[33] = colors.lime
- pSide[33] = 3
- pMax[33] = 30000
- pName[34] = "alltheores:sapphire"
- pDN[34] = "Sapphire"
- pLine[34] = "white"
- pStat[34] = true
- pByte[34] = colors.white
- pSide[34] = 1
- pMax[34] = 10000
- pName[35] = "alltheores:nickel_ingot"
- pDN[35] = "Nickel"
- pLine[35] = "yellow"
- pStat[35] = true
- pByte[35] = colors.yellow
- pSide[35] = 3
- pMax[35] = 30000
- function UserCommand( xpos, ypos)
- local bunt = {}
- print("UC" ,xpos ,ypos)
- if ypos == 23 then
- if (xpos>42) and (xpos<54) then
- if automat == true then
- automat = false
- else
- automat = true
- end
- end
- elseif ypos == 1 then
- if (xpos<6) then
- --prev page
- if dPage > 1 then
- dPage = dPage -1
- end
- elseif (xpos>52) then
- if dPage < dMax then
- dPage = dPage +1
- end
- end
- elseif (ypos == 4) or (ypos == 7) or (ypos == 10) or (ypos == 13) or (ypos == 16) or (ypos == 19) then
- npos = (ypos-1) / 3 - 1
- mpos = 0
- if (xpos>9) and (xpos<16) then
- mpos = 1
- elseif (xpos>28) and (xpos<35) then
- mpos = 2
- elseif (xpos>47) and (xpos<54) then
- mpos = 3
- end
- if not(mpos == 0) then
- proNr = (dPage - 1) * 18 + npos * 3 + mpos
- print(proNr)
- if pStat[proNr] == false then
- pStat[proNr] = true
- else
- pStat[proNr] = false
- end
- bunt[1] = 0
- bunt[2] = 0
- bunt[3] = 0
- for mpos = 1, aPro do
- if pStat[mpos] == true then
- bunt[pSide[mpos]] = bunt[pSide[mpos]] + pByte[mpos]
- end
- end
- redstone.setBundledOutput("back", bunt[1])
- redstone.setBundledOutput("right", bunt[2])
- redstone.setBundledOutput("bottom", bunt[3])
- print(bunt[1], bunt[2], bunt[3])
- end
- end
- end
- function CheckInferiumReihe(lesen)
- for i = 1,aPro do
- pFound[i] = false
- end
- such = {}
- such.name = "mysticalagriculture"
- rs = rss.listItems()
- if not(rs == nil) then
- for slot, item in pairs(rs) do
- for i = 1, aPro do
- if item.name == pName[i] then
- found = true
- pStored[i] = item.amount
- pFound[i] = true
- if automat == true then
- if item.amount > pMax[i] then
- pStat[i] = false
- else
- pStat[i] = true
- end
- end
- end
- end
- end
- for I = 1, aPro do
- if pFound[i] == false then
- print(pName[i].." not found!")
- end
- end
- end
- rs = rss.listfluid()
- if not(rs == nil) then
- for slot, item in pairs(rs) do
- for i = 1, aPro do
- if item.name == pName[i] then
- found = true
- pStored[i] = item.amount
- pFound[i] = true
- if automat == true then
- if item.amount > pMax[i] then
- pStat[i] = false
- else
- pStat[i] = true
- end
- end
- end
- end
- end
- end
- local bunt = {}
- bunt[1] = 0
- bunt[2] = 0
- bunt[3] = 0
- for i = 1, aPro do
- if pStat[i] == true then
- bunt[pSide[i]] = bunt[pSide[i]] + pByte[i]
- end
- end
- redstone.setBundledOutput("left", bunt[1])
- redstone.setBundledOutput("right", bunt[2])
- redstone.setBundledOutput("bottom", bunt[3])
- end
- function MonAufbau(moni)
- if not(moni == nil) then
- moni.setTextScale(0.5)
- moni.setBackgroundColor(colors.black)
- moni.clear()
- moni.setBackgroundColor(colors.green)
- moni.setTextColor(colors.black)
- moni.setCursorPos(10,1)
- moni.write(" *** Wuffelz Ressource Farm Control *** ")
- moni.setCursorPos(2,1)
- if dPage > 1 then
- moni.setBackgroundColor(colors.orange)
- else
- moni.setBackgroundColor(colors.black)
- moni.setTextColor(colors.orange)
- end
- moni.write(" << ")
- moni.setCursorPos(7,1)
- moni.setBackgroundColor(colors.black)
- moni.setTextColor(colors.orange)
- moni.write(string.format("%1d", dPage))
- moni.setCursorPos(53,1)
- if dPage < dMax then
- moni.setBackgroundColor(colors.orange)
- moni.setTextColor(colors.black)
- else
- moni.setBackgroundColor(colors.black)
- moni.setTextColor(colors.orange)
- end
- moni.write(" >> ")
- for i = 1,6 do
- k = (i-1) * 3 + 1
- for j = 0,2 do
- moni.setBackgroundColor(colors.black)
- moni.setTextColor(colors.blue)
- if j == 1 then
- moni.setTextColor(colors.orange)
- end
- px = j * 19
- py = (i-1) * 3 + 3
- moni.setCursorPos(px + 1, py)
- pr = k + j + ((dPage - 1) * 18)
- if pr <= aPro then
- moni.write(pDN[pr])
- moni.setCursorPos(px+13, py)
- moni.write(string.format("%6d", pStored[pr]))
- moni.setCursorPos(px + 1, py + 1)
- if pStat[pr] == true then
- moni.setTextColor(colors.lime)
- moni.write("online")
- moni.setTextColor(colors.white)
- moni.setBackgroundColor(colors.red)
- moni.setCursorPos(px + 10, py + 1)
- moni.write("-> off")
- else
- moni.setTextColor(colors.red)
- moni.write("offline")
- moni.setTextColor(colors.white)
- moni.setBackgroundColor(colors.lime)
- moni.setCursorPos(px + 10, py + 1)
- moni.write("-> on ")
- end
- end
- end
- end
- moni.setBackgroundColor(colors.black)
- moni.setTextColor(colors.blue)
- moni.setCursorPos(5,23)
- moni.write("Automatic limit control is ")
- moni.setCursorPos(33,23)
- if automat then
- moni.setTextColor(colors.lime)
- moni.write("enabled ")
- moni.setCursorPos(43,23)
- moni.setBackgroundColor(colors.red)
- moni.setTextColor(colors.white)
- moni.write("-> disable ")
- else
- moni.setTextColor(colors.red)
- moni.write("disabled ")
- moni.setCursorPos(43,23)
- moni.setBackgroundColor(colors.lime)
- moni.setTextColor(colors.white)
- moni.write("-> enable ")
- end
- end
- end
- while true do
- CheckInferiumReihe(lesen)
- MonAufbau(monitor1)
- MonAufbau(monitor2)
- MonAufbau(monitor3)
- --MonAufbau(monitor4)
- event, button, x, y = os.pullEventRaw()
- if event == "terminate" then
- break
- elseif event == "redstone" then
- --neuer Durchlauf
- elseif (event == "monitor_touch") and (button == "monitor_4") then
- UserCommand( x, y)
- elseif (event == "monitor_touch") and (button == "monitor_1") then
- UserCommand( x, y)
- elseif (event == "monitor_touch") and (button == "monitor_7") then
- UserCommand( x, y)
- elseif (event == "monitor_touch") and (button == "monitor_55") then
- UserCommand( x, y)
- else
- print(event, button, x, y)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment