Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- @title makeAtom
- -- @description A Chemistry Turtle programm to process every atom you want with a Fusion Chamber, Oxygene and Hydrogene
- -- @author Flaming Talisker
- -- @authorYT http://youtube.com/FlamingTalisker (funny french inside)
- -- @version pre alpha anticiped release (because fuck customers)
- -- @remarque most commentary are in french, because i'am and i pee on other langage to show dominance
- -- @licence nudeware, send me a nude of you to commercialy use this
- -- @excuse sorry, it was a joke
- -- @... stop with @, go home, you're drunk
- -- adapt this setting to your world and needs
- local atom_target = 79 -- atom number to be created
- local stack_size = 64 -- size of stack to be created ! (you don't say !)
- local direction_left = "north" -- because side and direction blow our mind
- local direction_right ="south" -- indeed *Teal'c voice*
- local pause = 5 -- sleep time in sec between 2 checks, you don't want to smash your server, don't you ?
- if pause == 0 then pause = 1 end -- are you a lama ?
- -- don't touch that bitch
- local fusion = peripheral.wrap("right") -- la fusion chamber
- local chest = peripheral.wrap("top") -- le chest des atomes finaux
- local chest1 = peripheral.wrap("front") -- chest de gauche
- local chest2 = peripheral.wrap("back") -- chest de droite
- local mchem = peripheral.wrap("left") -- Minechem Atomic manipulator
- -- process principal
- function main()
- -- boucle infinie
- while true do
- -- activation pause
- make_pause = true
- -- verifions ce qu'il y a dans la fusion chamber
- stack1 = fusion.getStackInSlot(1)
- stack2 = fusion.getStackInSlot(2)
- if stack1 == nil and stack2 == nil then
- -- la chamber fusion est prete a un nouveau process, decidons quoi faire...
- turtle_slot = checkProcessInChest()
- -- si aucun element n'est a process dans la turtle
- if turtle_slot == 0 then
- -- si atom cible inferieur ou egal a O
- if atom_target <= 8 then
- -- on envoi 2 H
- chest1.pullItem("down",2,stack_size)
- chest2.pullItem("down",2,stack_size)
- -- si atome entre 8 et 15
- else
- if atom_target < 16 then
- -- on envoi 1 O et 1H
- chest1.pullItem("up",2,stack_size)
- chest2.pullItem("down",2,stack_size)
- -- si atome superieur ou egal a 2 O
- else
- -- on envoi 2 oxygene
- chest1.pullItem("up",2,stack_size)
- chest2.pullItem("up",2,stack_size)
- end
- end
- -- sinon on s'en occupe
- else
- -- si c'est l'atom cible
- if mchem.getAtomicMass() == atom_target then
- -- on le met dans le chest final
- chest.pullItem("down",turtle_slot,stack_size)
- -- on desactive la pause parce que pas besoin du coup
- make_pause = false
- -- on ecrit une connerie pour dire qu'on est content
- print("One stack of "..stack_size.." element(s) "..atom_target.." created !")
- -- sinon si l'ecart de l'atom cible est superieur a O
- else
- if atom_target - mchem.getAtomicMass() >= 8 then
- -- on l'envoi a gauche et oxygene a droite
- chest1.pullItem(direction_right,turtle_slot,stack_size)
- chest2.pullItem("up",2,stack_size)
- -- sinon l'ecart de l'atom cible est inferieur a O
- else
- -- on l'envoi a gauche et hydrogene a droite
- chest1.pullItem(direction_right,turtle_slot,stack_size)
- chest2.pullItem("down",2,stack_size)
- end
- end
- end
- -- on fait une pause pour attendre que les elements arrivent dans le fusion
- -- parce que les pipes ca rame sa race grave
- if make_pause then sleep(pause) end
- else
- -- la fusion chamber travaille, on a rien a faire
- -- une attente active etant degeulasse par nature on reduit sa nuisance en faisant une pause
- -- sinon Azenet va me defoncer
- print("pause "..pause.." sec")
- sleep(pause)
- end
- end
- end
- -- fonction qui scan la turtle pour voir si on a des atome a process
- function checkProcessInChest()
- -- on parcour tous les slots de la turtle
- for i=1,16 do
- turtle.select(i)
- -- si nous avons quelque chose dans le slot dans la bonne quantite
- if turtle.getItemCount() >= stack_size then
- -- si c'est un element chimique
- if mchem.getAtomicMass() > 0 then
- -- on retourne le slot a processer
- return i
- end
- end
- end
- -- on a rien trouve
- return 0
- end
- main()
- -- code pour exemple
- function dontcallme()
- stack1 = fusion.getStackInSlot(1)
- if stack1 ~= nil and stack1.raw_name == "minechem.itemelement.o" then
- print("oxygen")
- end
- print("------------------")
- for item,content in pairs(stack1) do
- print(item)
- end
- chest.pullItem("down",2,1) -- direction, slot, nb
- end
Add Comment
Please, Sign In to add comment