Posted 12 September 2014 - 05:51 PM
Hi all again, I bring a program I made with the intention of automating the alveary the forestry mod, for those who like it to computerize the simplest things XD
The pastebin file, I put the translation of the Spanish / English for you can change languages
I'm sorry if my English is very bad
here i show you how the program work http://gravlann.gith...stebin=fBn7jvp0
and here is the code and if you see any bug, or if you see you can improve the code, just let me know
http://pastebin.com/fBn7jvp0
The pastebin file, I put the translation of the Spanish / English for you can change languages
I'm sorry if my English is very bad
here i show you how the program work http://gravlann.gith...stebin=fBn7jvp0
and here is the code and if you see any bug, or if you see you can improve the code, just let me know
http://pastebin.com/fBn7jvp0
Spoiler
-- Programa realizado por GalactusX
local side = "left"
local timeup = 15
local timedown = 15
local Logo = {
[[ ___ __ _ __ ____ ___ ___ __ __]],
[[ / _ | / / | | / // __// _ | / _ \\ \/ /]],
[[ / __ | / /__| |/ // _/ / __ | / , _/ \ / ]],
[[ /_/ |_|/____/|___//___//_/ |_|/_/|_| /_/ ]],
}
x,y=term.getSize()
function setPos(x,y)
term.setCursorPos(x,y)
end
function printC( text, ypos )
term.setCursorPos(x/2 - (#text/2) + 1, ypos)
term.write(text)
end
function color(color1)
term.setTextColor(color1)
end
function menu(x1,y1)
term.clear()
color(colors.yellow)
setPos(3,3)
for i = 1, #Logo do
print(Logo[i])
end
color(colors.brown)
for i=1, x1-1 do
setPos(i,1)
write("xx")
end
for i=1, x1-1 do
setPos(i,y1)
write("xx")
end
for i=1, y1-1 do
setPos(1,i)
write("xx")
end
for i=1, y1-1 do
setPos(x-1,i)
write("xx")
end
end
local function newmenu(tList,x,y)
x=x or 1
y=y or 1
y=y-1
local selected=1
local function render()
for num,item in ipairs(tList) do
term.setCursorPos(x,y+num)
write((num==selected and '[' or ' ')..(type(item)=='table' and item[1] or item)..(num==selected and ']' or ' '))
end
end
while true do
render()
local evts={os.pullEvent('key')}
if evts[1]=="key" and evts[2]==200 and selected>1 then
selected=selected-1
elseif evts[1]=="key" and evts[2]==208 and selected<#tList then
selected=selected+1
elseif evts[1]=="key" and evts[2]==28 or evts[2]==156 then
return (type(tList[selected])=='table' and tList[selected][2](tList[selected][1]) or tList[selected])
end
end
end
function provenframes()
menu(x,y)
for i=1,timeup,1 do
redstone.setBundledOutput(side,colors.purple)
printC("Realizando purga de frames: " ..tostring(timeup -i).." segundos",13)
-- printC("Performing purge of frames: " ..tostring(timeup -i).." seconds",13)
sleep(0.5)
redstone.setBundledOutput(side,0)
sleep(0.5)
end
menu(x,y)
for i=1,timedown,1 do
printC("Enviando frames...: " ..tostring(timedown-i).." segundos",13)
-- printC("Sending frames...: " ..tostring(timedown-i).." seconds",13)
redstone.setBundledOutput(side,colors.red)
sleep(0.5)
redstone.setBundledOutput(side,0)
sleep(0.5)
end
menu(x,y)
crearmenu()
end
function chocolate()
menu(x,y)
for i=1,timeup ,1 do
redstone.setBundledOutput(side,colors.purple)
printC("Realizando purga de frames: " ..tostring(timeup -i).." segundos",13)
-- printC("Performing purge of frames: " ..tostring(timeup -i).." seconds",13)
sleep(0.5)
redstone.setBundledOutput(side,0)
sleep(0.5)
end
menu(x,y)
for i=1,timedown,1 do
printC("Enviando frames...: " ..tostring(timedown-i).." segundos",13)
-- printC("Sending frames...: " ..tostring(timedown-i).." seconds",13)
redstone.setBundledOutput(side,colors.yellow)
sleep(0.5)
redstone.setBundledOutput(side,0)
sleep(0.5)
end
menu(x,y)
crearmenu()
end
function soulframes()
menu(x,y)
for i=1,timeup ,1 do
redstone.setBundledOutput(side,colors.purple)
printC("Realizando purga de frames: " ..tostring(timeup -i).." segundos",13)
-- printC("Performing purge of frames: " ..tostring(timeup -i).." seconds",13)
sleep(0.5)
redstone.setBundledOutput(side,0)
sleep(0.5)
end
menu(x,y)
for i=1,timedown,1 do
redstone.setBundledOutput(side,colors.white)
printC("Enviando frames...: " ..tostring(timedown-i).." segundos",13)
-- printC("Sending frames...: " ..tostring(timedown-i).." seconds",13)
sleep(0.5)
redstone.setBundledOutput(side,0)
sleep(0.5)
end
menu(x,y)
crearmenu()
end
function vaciar()
menu(x,y)
for i=1,timedown,1 do
redstone.setBundledOutput(side,colors.purple)
printC("Realizando purga de frames: " ..tostring(timedown-i).." segundos",13)
-- printC("Performing purge of frames: " ..tostring(timeup -i).." seconds",13)
sleep(0.5)
redstone.setBundledOutput(side,0)
sleep(0.5)
end
menu(x,y)
crearmenu()
end
function salir()
os.shutdown()
end
function crearmenu()
color(colors.lime)
newmenu({
{"1. Meter Proven frames", function(param) return provenframes() end},
-- {"2. Send Proven frames", function(param) return chocolate() end},
{"2. Meter Chocolate frames", function(param) return chocolate() end},
-- {"2. Send Chocolate frames", function(param) return chocolate() end},
{"3. Meter Soul Frames", function(param) return soulframes() end},
-- {"3. Send Soul Frames", function(param) return soulframes() end},
{"4. Vaciar Alveary", function(param) return vaciar() end},
-- {"4. Purgue Alveary", function(param) return vaciar() end},
{"5. Salir", function(param) return salir() end}
-- {"5. Exit", function(param) return salir() end}
},13,10)
end
menu(x,y)
crearmenu()
redstone.setBundledOutput(side,0)
Edited on 12 September 2014 - 04:07 PM