Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- VIDEO SETUP : https://youtu.be/KPwwgZlGzX8
- -- VIDEO EXPLICATION DE CODE : https://youtu.be/LD0fan4-1uk
- pp={}
- cote={"EAST","DOWN","WEST"}
- function addPP(typ,coffre,compress1,compress2,compress3,methode,qte)
- pp[typ]={
- coffre=peripheral.wrap(coffre),
- compress={
- peripheral.wrap(compress1),
- peripheral.wrap(compress2),
- peripheral.wrap(compress3),
- },
- methode=methode,
- qte=qte
- }
- end
- function push(coffre,cote,slotOut,qte,slotIn)
- retour=0
- while retour==0 do
- retour=coffre.pushItemIntoSlot(cote,slotOut,qte,slotIn)
- end
- end
- function pushS(coffre,cote,slotOut,qte)
- retour=0
- while retour==0 do
- retour=coffre.pushItem(cote,slotOut,qte)
- end
- end
- complexListe={
- {
- {item='item.basicitem.compressedsteel',trouver=false},
- {item='item.basicitem.compressedaluminum',trouver=false},
- {item='item.basicitem.compressedbronze',trouver=false},
- {item='item.basicitem.compressedsteel',trouver=false},
- {item='item.basicitem.compressedaluminum',trouver=false},
- {item='item.basicitem.compressedbronze',trouver=false}
- },
- {
- {item='item.heavyplating',trouver=false},
- {item='item.compressedmeteoriciron',trouver=false}
- }
- }
- addPP("e1","copper_1","compresseur__lectrique_2","compresseur__lectrique_3","compresseur__lectrique_4","normal",2)
- addPP("e2","copper_2","compresseur__lectrique_6","compresseur__lectrique_7","compresseur__lectrique_5","normal",2)
- addPP("e3","copper_3","compresseur__lectrique_8","compresseur__lectrique_9","compresseur__lectrique_10","normal",2)
- addPP("e4","copper_4","compresseur__lectrique_11","compresseur__lectrique_12","compresseur__lectrique_13","normal",1)
- addPP("e5","copper_5","assembly_machine_3","assembly_machine_4","assembly_machine_2","simple1",2)
- addPP("e6","copper_6","FAUX","FAUX","FAUX","complex",2)
- while true do
- table.foreach(pp,function(id,v)
- for i=1, 3 do
- -- on condense les items dans le coffre de pre stockage
- pp[id].coffre.condenseItems()
- -- on recupΓ©re les stacks
- stacks1=pp[id].coffre.getAllStacks()
- -- on regarde la machine en methode normal
- if pp[id].methode=="normal" then
- stacks2=pp[id].compress[i].getAllStacks()
- else
- stacks2={}
- end
- -- Si le coffre de pre stockage contien au moin un item et que la machine est vide
- if #stacks1 ~= 0 and stacks2[4]==nil and stacks2[5]==nil then
- if pp[id].methode=="normal" then
- push(pp[id].coffre,cote[i],1,1,4)
- if pp[id].qte==2 then push(pp[id].coffre,cote[i],1,1,5) end
- elseif pp[id].methode=="simple1" then
- for u=1, pp[id].qte do
- pushS(pp[id].coffre,cote[i],1,1)
- end
- elseif pp[id].methode=="complex" then
- table.foreach(stacks1,function(is,data)
- trouverUneFois=false
- info=data.basic()
- for icl=1, #complexListe do
- for icl2=1, #complexListe[icl] do
- if info.raw_name==complexListe[icl][icl2].item then
- complexListe[icl][icl2].trouver=true
- trouverUneFois=true
- end
- end
- end
- if trouverUneFois==false then
- print(info.raw_name)
- end
- end)
- trouverUneFois=false
- for icl=1, #complexListe do
- if trouverUneFois==false then
- tousOk=true
- for icl2=1, #complexListe[icl] do
- if complexListe[icl][icl2].trouver==false then
- tousOk=false
- end
- complexListe[icl][icl2].trouver=false
- end
- if tousOk then
- trouverUneFois=true
- retour='Envoi complexe :'
- for icl2=1, #complexListe[icl] do
- retour=retour..' '..complexListe[icl][icl2].item
- trouver=false
- table.foreach(stacks1,function(is,data)
- if trouver==false then
- info=data.basic()
- if info.raw_name==complexListe[icl][icl2].item then
- trouver=true
- push(pp[id].coffre,cote[i],is,1,3+icl2)
- end
- end
- end)
- end
- print(retour)
- end
- else
- for icl2=1, #complexListe[icl] do
- complexListe[icl][icl2].trouver=false
- end
- end
- end
- end
- end
- end
- end)
- os.sleep(6)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement