Posted 12 March 2012 - 04:00 AM
At vacation home right now and I have no access to minecraft right now (the site's blocked for some reason)
and I wrote this out of when I was thinking about upgrading my quarries to a tunnel register
I know its riddled with bugs but I don't have a clue to where to find them right now.
and I wrote this out of when I was thinking about upgrading my quarries to a tunnel register
I know its riddled with bugs but I don't have a clue to where to find them right now.
Spoiler
--Ore counter
--This program goes to Computer #47 : "Quarry Fine Register"
--This program uses all 16 colors in RP2:D
--Uses Diamond gates and outputs from the top using rednet to transfer all
--information to main server : Computer #13 : "Master Control : Dream Realm"
--This program will archive all ores that pass through it.
--the right side counts all incoming ore to storage and
--the left side counts all outgoing resources.
--This program makes a log of all ore every 5 minutes and resets the
--log information every session
local right = rs.getBundledInput("right") --Servo to the right, inbound ore
local left = rs.getBundledInput("left") --Servo to the left, outbound resources
Ore = {Iron, Gold, Redstone, Coal, Diamond, Copper, Tin, Silver, Appitite,
Uranium, Nikalite, Ruby, Saphire, Emerald}
Ore_Value = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
Ore_Sent = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
function Income_Counter()
while true do
--adds 1 everytime an ore passes through its gate
if colors.test(right, 1 ) == true then
Ore_Value[1] = Ore_Value[1] + 1
elseif colors.test(right, 2 ) == true then
Ore_Value[2] = Ore_Value[2] + 1
elseif colors.test(right, 4 ) == true then
Ore_Value[3] = Ore_Value[3] + 1
elseif colors.test(right, 8 ) == true then
Ore_Value[4] = Ore_Value[4] + 1
elseif colors.test(right, 16 ) == true then
Ore_Value[5] = Ore_Value[5] + 1
elseif colors.test(right, 32 ) == true then
Ore_Value[6] = Ore_Value[6] + 1
elseif colors.test(right, 64 ) == true then
Ore_Value[7] = Ore_Value[7] + 1
elseif colors.test(right, 128 ) == true then
Ore_Value[8] = Ore_Value[8] + 1
elseif colors.test(right, 256 ) == true then
Ore_Value[9] = Ore_Value[9] + 1
elseif colors.test(right, 512 ) == true then
Ore_Value[10] = Ore_Value[10] + 1
elseif colors.test(right, 1024 ) == true then
Ore_Value[11] = Ore_Value[11] + 1
elseif colors.test(right, 2048 ) == true then
Ore_Value[12] = Ore_Value[12] + 1
elseif colors.test(right, 4096 ) == true then
Ore_Value[13] = Ore_Value[13] + 1
elseif colors.test(right, 8192 ) == true then
Ore_Value[14] = Ore_Value[14] + 1
end
end
end
function Spending_Counter()
while true do
--adds 1 for every resource sent
if colors.test(left, 1 ) == true then
ore_sent[1] = ore_sent[1] + 1
elseif colors.test(left, 2 ) == true then
ore_sent[2] = ore_sent[2] + 1
elseif colors.test(left, 4 ) == true then
ore_sent[3] = ore_sent[3] + 1
elseif colors.test(left, 8 ) == true then
ore_sent[4] = ore_sent[4] + 1
elseif colors.test(left, 16 ) == true then
ore_sent[5] = ore_sent[5] + 1
elseif colors.test(left, 32 ) == true then
ore_sent[6] = ore_sent[6] + 1
elseif colors.test(left, 64 ) == true then
ore_sent[7] = ore_sent[7] + 1
elseif colors.test(left, 128 ) == true then
ore_sent[8] = ore_sent[8] + 1
elseif colors.test(left, 256 ) == true then
ore_sent[9] = ore_sent[9] + 1
elseif colors.test(left, 512 ) == true then
ore_sent[10] = ore_sent[10] + 1
elseif colors.test(left, 1024 ) == true then
ore_sent[11] = ore_sent[11] + 1
elseif colors.test(left, 2048 ) == true then
ore_sent[12] = ore_sent[12] + 1
elseif colors.test(left, 4096 ) == true then
ore_sent[13] = ore_sent[13] + 1
elseif colors.test(left, 8192 ) == true then
ore_sent[14] = ore_sent[14] + 1
end
end
end
function Saving()
local update_timer = os.startTimer(1)
local full_timer = os.startTimer(60*5)
local timeleft = (60*5)
while true do
event, param = os.pullEvent()
if event == "timer" and param == update_timer then
update_timer = os.startTimer(1)
timeleft = timeleft - 1
end
if event == "timer" and param == full_timer then
print "Saving..."
io.open("Quarry Log.txt", "r+")
write(Ore[]"/n", Ore_Value[]"/n", Ore_Sent[]"/n")
flush()
break
end
end
end
function Register_Menu()
while true do
term.clear()
term.setCursorPos(1,1)
Income_Counter()
Spending_Counter()
print "-------------------------------------------------"
print ("| Quarry Resister "...timeleft..." |")
print "-------------------------------------------------"
print "| Ores Inbound Shipped |"
print ("| "Ore[1]" "Ore_Value[1]" "Ore_Sent[1]" |")
print ("| "Ore[2]" "Ore_Value[2]" "Ore_Sent[2]" |")
print ("| "Ore[3]" "Ore_Value[3]" "Ore_Sent[3]" |")
print ("| "Ore[4]" "Ore_Value[4]" "Ore_Sent[4]" |")
print ("| "Ore[5]" "Ore_Value[5]" "Ore_Sent[5]" |")
print ("| "Ore[6]" "Ore_Value[6]" "Ore_Sent[6]" |")
print ("| "Ore[7]" "Ore_Value[7]" "Ore_Sent[7]" |")
print ("| "Ore[8]" "Ore_Value[8]" "Ore_Sent[8]" |")
print ("| "Ore[9]" "Ore_Value[9]" "Ore_Sent[9]" |")
print ("| "Ore[10]" "Ore_Value[10]" "Ore_Sent[10]" |")
print ("| "Ore[11]" "Ore_Value[11]" "Ore_Sent[11]" |")
print ("| "Ore[12]" "Ore_Value[12]" "Ore_Sent[12]" |")
print ("| "Ore[13]" "Ore_Value[13]" "Ore_Sent[13]" |")
print ("| "Ore[14]" "Ore_Value[14]" "Ore_Sent[14]" |")
print "-------------------------------------------------"
event, param1, param2, param3 = os.pullEvent()
if event == "char" and param1 == "x" then break end
end
end
Register_Menu()