--local tables/variables
local w,h = term.getSize()
local ores = {ore1, ore2, ore3, ore4, ore5, ore6, ore7, ore8, ore9, ore10, ore11, ore12, ore13, ore14, ore15, ore16, ore17, ore18, ore19, ore20}
local vari
local ifs = {if1, if2, if3, if4, if5, if6, if7, if8, if9, if10, if11, if12, if13, if14, if15, if16, if17, if18, if19, if20}
local rate
local aot
--*variable tables*
lastvalue = {}
count = {}
--[for] counter statement
for i = 1, 15 do
lastvalue[i] = false
count[i] = 0
end
--syntax functions
local function printCentered(str, ypos)
term.setCursorPos(w/2 - #str/2, ypos)
term.write(str)
end
local function printInputCentered(vari, ypos)
term.setCursorPos(w/2 - #str/2)
term.write("-> ".. vari)
end
local function printCenteredTextutils(str, rate, ypos)
term.setCursorPos(w/2-2 - #str/2-2, ypos)
textutils.slowWrite(str, rate)
end
local function printCenteredBlinking(str, intervalspace, aot, ypos)
function loop()
while true do
for c = 1, aot do
term.setCursorPos(w/2 - #str/2, ypos)
term.write(str)
sleep(intervalspace)
term.setCursorPos(1,ypos)
term.clearline()
lastvalue[i] = false
count[i] = 0
end
end
end
end
local function keyEvent(key)
bRead = true
while(bRead) do
local sEvent, param = os.pullEvent("key")
if(sEvent == key ) then
break
end
send
local function keyEventTable(key, table)
bRead = true
while(bRead) do
local sEvent, param = os.pullEvent("key")
if(sEvent == key ) then
break
return
end
-- this is the counter UI
function UI()
print("|Item |Number of |")
print("|Type |Items |")
print("| |Recorded |")
print("|------------|--------------|")
print("|", i,ores[i]," ",count[i]," ")
end
--this asks if the user would like to display on a monitor or not.
--and this is were the counter part of the program should go ;)/>/>
function counter initiated()
printCenteredTextutils("would you like to display on a monitor?", 8, 4)
sleep(1)
printcentered("Yes? No?", 6)
bRead = true
while(bRead) do
local sEvent, param = os.pullEvent("key")
if(sEvent == 21 ) then
break
printCentered("what side is your monitor on?", 2)
printInputCentered(monitorside, 4)
local term = perhipheral.wrap(monitorside) term.redirect(monitorside)
UI()
elseif(sEvent == 49 ) then
printCenteredTextutils("OK. Thank You", 8, 6)
UI()
end
end
end
--this is the more ores than [if] statement
--this is used in the ore assign part of the program
function mot()
printInputCentered(more, 2)
if more == "yes" then
return
elseif more == "no" then
counter initiated()
end
end
-- this is the intro to the program
--i tryied to make it easier than haveing to use ASCII art becuase ASCII art dosnt fill the whole screen
-- and alot of people have diffrent size shell's/console's
printCenteredTectutils(string.rep("#", w), 8, 1)
printCenteredTectutils("#"string.rep(" ", w-1)"#", 8, 2)
printCenteredTectutils("#"string.rep(" ", w-1)"#", 8, 3)
printCenteredTectutils("#"string.rep(" ", w-1)"#", 8, 4)
printCenteredTectutils("#"string.rep(" ", w-1)"#", 8, 5)
printCenteredTectutils("#"string.rep(" ", w-1)"#", 8, 6)
printCenteredTectutils("#"string.rep(" ", w/2)"resource counter"string.rep(" ", w/2)"#", 8, 7)
printCenteredTectutils("#"string.rep(" ", w-1)"#", 8, 8)
printCenteredTectutils("#"string.rep(" ", w/2)"coded by:cmurtheepic"string.rep(" ", w/2)"#", 8, 9)
printCenteredTectutils("#"string.rep(" ", w-1)"#", 8, 10)
printCenteredTectutils("#"string.rep(" ", w-1)"#", 8, 11)
printCenteredTectutils("#"string.rep(" ", w-1)"#", 8, 12)
printCenteredTectutils("#"string.rep(" ", w-1)"#", 8, 13)
printCenteredTectutils(string.rep("#",w), 8, 14)
rawread(28)
--this assigns the variables a ore or [string] for the program to later compare t
function assign ores()
printCenteredTextutils("what should the first ore to be counted be?", 8, 4)
printInputCentered(ores[ore1] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the second ore to be counted be?", 8, 4)
printInputCentered(ores[ore2] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the third ore to be counted be?", 8, 4)
printInputCentered(ores[ore3] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the fourth ore to be counted be?", 8, 4)
printInputCentered(ores[ore4] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the fifth ore to be counted be?", 8, 4)
printInputCentered(ores[ore5] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the sixth ore to be counted be?", 8, 4)
printInputCentered(ores[ore6] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the seventh ore to be counted be?", 8, 4)
printInputCentered(ores[ore7] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the eighth ore to be counted be?", 8, 4)
printInputCentered(ores[ore8] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the ninth ore to be counted be?", 8, 4)
printInputCentered(ores[ore9] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the tenth ore to be counted be?", 8, 4)
printInputCentered(ores[ore10] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the eleventh ore to be counted be?", 8, 4)
printInputCentered(ores[ore11] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the twelvth ore to be counted be?", 8, 4)
printInputCentered(ores[ore12] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the thirteenth ore to be counted be?", 8, 4)
printInputCentered(ores[ore13] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the fourteenth ore to be counted be?", 8, 4)
printInputCentered(ores[ore14] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the fifteenth ore to be counted be?", 8, 4)
printInputCentered(ores[ore15] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the sixteenth ore to be counted be?", 8, 4)
printInputCentered(ores[ore16] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the seventeenth ore to be counted be?", 8, 4)
printInputCentered(ores[ore17] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the eighteenth ore to be counted be?", 8, 4)
printInputCentered(ores[ore18] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the nineteenth ore to be counted be?", 8, 4)
printInputCentered(ores[ore19] = io.read(), 6)
mot()
term.clear()
printCenteredTextutils("what should the twentith ore to be counted be?", 8, 4)
printInputCentered(ores[ore20] = io.read(), 6)
mot()
term.clear()
printCentered("their are no more ore slots in the counter available", 4)
sleep(.5)
printCentered("continue?", 6)
printCentered("Yes? No?", 8)
event, param1, param2 = os.pullEvent()
if event == "char" and param1 == "y" then
printCenteredTextutils("OK", 8, 10)
term.clear()
counter initiated()
elseif event == "char" and param2 == "n" then
printCenteredTextutils("OK", 8, 10)
sleep(1)
term.clear()
sleep(.3)
printCentered("would you like to restart?", 2)
printCentered("Yes? No?", 4)
event, param1, param2 = os.pullEvent()
if event == "char" and param1 == "y" then
printCenteredTextutils("OK", 8, 6)
assign ores()
elseif event == "char" and param2 == "n" then
term.clear()
printCenteredTextutils("OK. stopping program", 8, 5)
sleep(.5)
printCenteredBlinking("STOPPING PROGRAM", .8, 8, 7)
term.clear()
term.setCursorPos(1,1)
end
end
end
end
i need the counter to update automatically when it recieves a message over rednet that is equal to the table :
local ores = {ore1, ore2, ore3, ore4, ore5, ore6, ore7, ore8, ore9, ore10, ore11, ore12, ore13, ore14, ore15, ore16, ore17, ore18, ore19, ore20}
and then add the amount of messages that are equal to that variable in the table to the Counter UIand then constantly update