Advertisement
ecco7777

CC Plethora ME Player Potion Effect Supplier

Jun 4th, 2022 (edited)
1,647
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.92 KB | None | 0 0
  1. ni=peripheral.wrap("back")
  2. if ni.listModules~=nil then --NeuralInterface Script
  3.     --Modul Abfrage
  4.     if ni.hasModule("plethora:kinetic")==false then print("please add kinetic module") end
  5.     if ni.hasModule("plethora:introspection")==false then print("please add introspection module") end
  6.     if peripheral.getType("front")~="modem" then print("please add modem on front side") end
  7.  
  8.     --CheckEffects
  9.     function getEffects()
  10.         effByID={}
  11.         effects=ni.getMetaOwner().potionEffects
  12.         for ie=1, #effects do
  13.             effByID[effects[ie]]=true
  14.         end
  15.     end
  16.  
  17.     --connect
  18.     rednet.open("front")
  19.  
  20.     while true do
  21.         potionTimer=os.startTimer(1)
  22.         resp={os.pullEvent()}--rednet Event Abfrage
  23.         if resp[1]=="modem_message" then
  24.             mes=resp[5].message
  25.             if mes=="consume" then
  26.                 ni.getInventory().getItem(10).consume()
  27.                 ni.getInventory().pushItems("inventory",10,64,36)
  28.             end
  29.         end
  30.         if resp[1]=="timer" then
  31.             if ni.getInventory().getItem(10)==nil then
  32.                 redMes=""
  33.                 getEffects()
  34.                 if effByID["effect.moveSpeed"]==nil then redMes="effect.moveSpeed" end
  35.                 if effByID["effect.resistance"]==nil then redMes="effect.resistance" end
  36.                 if effByID["effect.damageBoost"]==nil then redMes="effect.damageBoost" end
  37.                 if effByID["effect.digSpeed"]==nil then redMes="effect.digSpeed" end
  38.                 if effByID["effect.luck"]==nil then redMes="effect.luck" end
  39.                 if effByID["effect.jump"]==nil then redMes="effect.jump" end
  40.                 if effByID["effect.absorption"]==nil then redMes="effect.absorption" end
  41.                 if effByID["effect.regeneration"]==nil then redMes="effect.regeneration" end
  42.                 if redMes~="" then rednet.broadcast(redMes) end
  43.             elseif ni.getInventory().getItem(10).consume~=nil then
  44.                 ni.getInventory().getItem(10).consume()
  45.                 ni.getInventory().pushItems("inventory",10,64,36)
  46.             end
  47.         end
  48.     end
  49. end
  50.  
  51. --Computer
  52. if ni.listModules==nil then
  53.     if peripheral.getType("right")~="appliedenergistics2:interface" then print("please add interface on right side") end
  54.     if peripheral.getType("top")~="manipulator" then print("please add manipulator on left side") end
  55.     if peripheral.getType("front")~="modem" then print("please add modem on back side") end
  56.     --peripherals
  57.     me=peripheral.wrap("right")
  58.     inv=peripheral.wrap("top")
  59.     rednet.open("back")
  60.     --variables
  61.     args={...}
  62.     file=args[1]
  63.     chestSide="south"
  64.     delay=0.4
  65.  
  66.     --sort blocks from me to colors
  67.     items=me.findItems(me.listAvailableItems()[1])
  68.     id={}
  69.     for i=1,#items do
  70.         name=items[i].getMetadata().displayName
  71.         if string.find(name,"Regeneration")~=nil then id["effect.regeneration"]=items[i] end
  72.         if string.find(name,"Swiftness")~=nil then id["effect.moveSpeed"]=items[i] end
  73.         if string.find(name,"resistance")~=nil then id["effect.resistance"]=items[i] end
  74.         if string.find(name,"Strength")~=nil then id["effect.damageBoost"]=items[i] end
  75.         if string.find(name,"haste")~=nil then id["effect.digSpeed"]=items[i] end
  76.         if string.find(name,"Luck")~=nil then id["effect.luck"]=items[i] end
  77.         if string.find(name,"Leaping")~=nil then id["effect.jump"]=items[i] end
  78.         if string.find(name,"absorption")~=nil then id["effect.absorption"]=items[i] end
  79.     end
  80.  
  81.     function pushPotion(item)
  82.         item.export("up",1,1)
  83.         inv.getInventory().pullItems(chestSide,1,1,10)
  84.     end
  85.  
  86.     while true do
  87.         resp={os.pullEvent("modem_message")}--rednet Event Abfrage
  88.         mes=resp[5].message
  89.         if string.find(mes,"effect") then
  90.             pushPotion(id[mes])
  91.         end
  92.         rednet.broadcast("consume")
  93.         sleep(delay)
  94.     end
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement