This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
cmurtheepic's profile picture

resource counter

Started by cmurtheepic, 24 November 2012 - 01:51 PM
cmurtheepic #1
Posted 24 November 2012 - 02:51 PM
could someone please help me get this program i made into working order.


--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 UI
and then constantly update
cmurtheepic #2
Posted 24 November 2012 - 02:52 PM
oh and there are quite a bit of errors/ bugs i can't figure out.
please help as best you can
remiX #3
Posted 24 November 2012 - 03:28 PM
-- this is the intro to the program
printCenteredTectutils(string.rep("#", w), 8, 1)
– You spelt Textutils in each printCenteredTextutils after 'this is the intro to the program
cmurtheepic #4
Posted 24 November 2012 - 03:30 PM
oops. my bad ;)/>/>
ChunLing #5
Posted 24 November 2012 - 04:22 PM
Do you have an error message?
cmurtheepic #6
Posted 24 November 2012 - 04:30 PM
no i don't know how to make a realtime display that wil display the ore/mineral and the counted amount and how to get it to count how many messages for that ore/mineral it gets
cmurtheepic #7
Posted 24 November 2012 - 09:08 PM
help? anyone?
Doyle3694 #8
Posted 24 November 2012 - 11:52 PM
You have definetly taken water above your head on this one, after copying it into notepad++ and indenting it, I sww that your code makes no sense. Though trying to fix it now.


EDIT: I cant do this, its way to "messy". I think you should create a simpler program, because here it looks like a ton of copy pastes form various tutorials
cmurtheepic #9
Posted 25 November 2012 - 06:08 AM
i added comments to it
cmurtheepic #10
Posted 25 November 2012 - 06:09 AM
here ill edit the post and see if it helps anyone help me
cmurtheepic #11
Posted 25 November 2012 - 06:22 AM
oh and thanks Doyle3694
i made changes to it that will hopefully help you
and the way it is supposed to count is if i receives a message that is equal to a variable from the table [ores] of the ore1, ore2, ore3, etc through rednet from a set of turtle that a comparing the ores they receive and sending a message. oh and here is the code for the turtles if you would like to see it.and maybe it will help you understand my program.
man people on the computercraft forums are alot nicer than everybody in every day by day life :D/>/>
you guys are awesome :P/>/>
oh and here is the code
feel free to edit it if you see so mistakes or errors :lol:/>/>


--this announces that the variable w is equal to the width of the screen. and the variable h is equal to the height of the screen
local w,h = term.getSize()
local resourcecounterid
local material

-- this allows me to use a command to print a text centered
local function printCentered(str, ypos)
   term.setCursorPos((w - #str)/2, ypos)
   term.write(str)
end
--this allows me to combine the command [term.setCursorPos(,)], with[print ""]
local function printAjustablePos(str, ypos, xpos)
    term.setCursorPos(xpos,ypos)
    term.write(str)
end
--this allows me to print textutils centered
local function textutilsCentered(str, nRate, ypos)
    term.setCursorPos((w - #str)/2, ypos)
    textutils.slowWrite(str, nRate)
end
--this gets the resource counter's computercraft id.
term.clear() term.setCursorPos(1,1)
printCentered("Enter ID of resource computer", 2)
repeat
    term.setCursorPos(1,4) term.clearLine()
    printCentered("-> ", 4)
    resourcecounterid = tonumber(read())
until type(resourcecounterid) == "number"
printCentered("Thank you.", 6)
sleep(1)
term.clear()
term.setCursorPos(1,1)
--this asks what the ore/material should be called
printCentered("what is the material/ore", 4)
printCentered("for the turtle to detect?", 5)
printCentered("-> ", 7)
material = read()
printCentered("don't forget to put a compareable of that", 9)
printCentered("ore/material on slot 16 of the turtle", 10)
printCentered("or the program/turtle won't work!", 11)
sleep(4)
term.clear()
sleep(.5)
textutilsCentered("counting resources", 9, 3)
sleep(1)
--this is the loop that the turtle compares materials in
function detect()
    while true do
	    turtle.select(16)
	    turtle.compareTo(1)
	    if turtle.compareTo(1) then
		    rednet.send(resourcecounterid, ""..material)
		    turtle.drop(all)
	    elseif not turtle.compareTo(1) then
		    turtle.drop(all)
	    end
    end
end
detect()
-- Clean up
term.clear()
term.setCursorPos(1,1)
cmurtheepic #12
Posted 25 November 2012 - 09:54 AM
ok i put a lot of hard work into this and this is the new updated version of the program
***WARNING***
THIS IS QUIT BIG.
IT IS OVER 400 LINES!!
***WARNING***


--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 rate
local aot
local monitordiplay = {line1, line2, line3, line4, line5}
local turtleID = turtleResourceDetecterID = {id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, id12, id13, id14, id15, id16, id17, id18, id19, id20}
local incompletemessage
local dectID
--*variable tables*
lastvalue = {}
count = {}
--[for] counter statement not sure what this is supposed to-do
for i = 1, 15 do
lastvalue[i] = false
count[i] = 0
end
--this is the place where the info coming in from rednet will go to be comepared and the added to the UI later on
--ok but i don't know how to get the message variable that comes over rednet by its self and with the variable turtleID which holds the turtle's ID
function rednetinfo(message)
  if message == (ores[ore1]) or dectID == (turtleResourceDetectorID[id1]) then
  --add +1 to that variable or [ore1] on the UIMONITOR VERSION or UICONSOLE VERSION
  return
    elseif message == (ores[ore2]) or dectID == (turtleResourceDetectorID[id2]) then
--add +1 to the variable
return
   elseif message == (ores[ore3]) or dectID == (turtleResourceDetectorID[id3]) then
   --add +1 to the variable
   return
	 elseif message == (ores[ore4]) or dectID == (turtleResourceDetectorID[id4]) then
  --add +1 to the variable
  return
    elseif message == (ores[ore5]) or dectID == (turtleResourceDetectorID[id5]) then
    --add +1 to the variable
    return
	  elseif message == (ores[ore6]) or dectID == (turtleResourceDetectorID[id6]) then
   --add +1 to the variable
   return
	 elseif message == (ores[ore7]) or dectID == (turtleResourceDetectorID[id7]) then
	 --add +1 to the variable
	 return
	   elseif message == (ores[ore8]) or dectID == (turtleResourceDetectorID[id8]) then
    --add +1 to the variable
    return
	  elseif message == (ores[ore9]) or dectID == (turtleResourceDetectorID[id9]) then
	  --add +1 to the variable
	  return
	    elseif message == (ores[ore10]) or dectID == (turtleResourceDetectorID[id10]) then
	 --add +1 to the variable
	 return
	   elseif message == (ores[ore11]) or dectID == (turtleResourceDetectorID[id11]) then
	   --add +1 to the variable
	   return
		 elseif message == (ores[ore12]) or dectID == (turtleResourceDetectorID[id12]) then
	  --add +1 to the variable
	  return
	    elseif message == (ores[ore13]) or dectID == (turtleResourceDetectorID[id13]) then
	    --add +1 to the variable
	    return
		  elseif message == (ores[ore14]) or dectID == (turtleResourceDetectorID[id14]) then
	   --add +1 to the variable
	   return
		 elseif message == (ores[ore15]) or dectID == (turtleResourceDetectorID[id15]) then
		 --add +1 to the variable
		 return
		   elseif message == (ores[ore16]) or dectID == (turtleResourceDetectorID[id16]) then
	    --add +1 to the variable
	    return
		  elseif message == (ores[ore17]) or dectID == (turtleResourceDetectorID[id17]) then
		  --add +1 to the variable
		  return
		    elseif message == (ores[ore18]) or dectID == (turtleResourceDetectorID[id18]) then
		 --add +1 to the variable
		 return
		   elseif message == (ores[ore19]) or dectID == (turtleResourceDetectorID[id19]) then
		   --add +1 to the variable
		   return
			 elseif message == (ores[ore20]) or dectID == (turtleResourceDetectorID[id20]) then
		  --add +1 to the variable
		  return
									 end
		 end
	    end
	   end
	  end
	 end
    end
   end
  end
end
  end	 
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
local function resourceDetectorID((turtleResourceDetectorID[vari2]), ypos1, ypos2)
  text = "what is the [ID] of the turtle that has this ore to detect"
  inputSymbol = "->"
  term.setCursorPos(w/2 - #text/2, ypos1)
  term.write(text)
  term.setCursorPos(w/2 - #inputSymbol/2, ypos2)
  term.write(inputSymbol)
  (turtleResourceDetectorID[vari2]) = io.read()
  sleep(.5)
  printCenteredTextutils("Thank You!!!", 8, ypos2+2)
  sleep(1.5)
  term.clear()
end

-- this is the counter UI
function UIMONITOR VERSION()
term.clear()
sleep(.5)
monitor.clear()
sleep(.5)
line1 = print("|Item		    |Number of	   |")
line2 = print("|Type		    |Items		   |")
line3 = print("|			    |Recorded	    |")
line4 = print("|----------------|----------------|")
line5 = print("|", i,ores[i]," | ",count[i],"	    ")

monitor.setCursorPos(1,1)
monitor.write(line1)
monitor.setCursorPos(1,2)
monitor.write(line2)
monitor.setCursorPos(1,3)
monitor.write(line3)
monitor.setCursorPos(1,4)
monitor.write(line4)
monitor.setCursorPos(1,5)
monitor.write(line5)
end
function UICONSOLE VERSION()
term.clear()
sleep(.5)
line1 = print("|Item		    |Number of	   |")
line2 = print("|Type		    |Items		   |")
line3 = print("|			    |Recorded	    |")
line4 = print("|----------------|----------------|")
line5 = print("|", i,ores[i]," | ",count[i],"	    ")

term.setCursorPos(1,1)
term.write(line1)
term.setCursorPos(1,2)
term.write(line2)
term.setCursorPos(1,3)
term.write(line3)
term.setCursorPos(1,4)
term.write(line4)
term.setCursorPos(1,5)
term.write(line5)
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 :D/>/>/>/>
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()
  printCentered("are their more ores/turtle's?", 2)
  printInputCentered(more, 4)
  if more == "yes" then
  return
  elseif more == "no" then
  counter initiated()
  end
end
--this is the loop that is supposidly going to loop and constantly check if the resource counter is getting any messages over rednet
function loopCheck()
  while true do
    incompletemessage = rednet.recieve()
    if incompletemessage = rednet.recieve() and rednet.recieve() == true then
	   break
    --see but here the variable incompletemessage is not been separated where the info or message is not put into the variable message yet and it is still stuck together with the turtleID.
    --they have to be separated first and turtleID needs to be put into the variable dectID
    --and I don't know how todo this
    rednetinfo()
    end
	  elseif incompletemessage = rednet.recieve() and rednet.recieve() == false then
   loopCheck()
   end
    end
  end
end
--this is the loop that is going to loop [loopCheck()]
function loopLoopCheck()
  while true do
    loopCheck()
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 most of the time
-- and alot of people have diffrent size shell's/console's
function intro()
  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)
end
--this assigns the variables a ore or [string] for the program to later compare to
function assign ores()
  printCenteredTextutils("what should the first ore to be counted be?", 8, 2)
  printInputCentered(ores[ore1] = io.read(), 4)
  resourceDetectorID(id1, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the second ore to be counted be?", 8, 4)
  printInputCentered(ores[ore2] = io.read(), 6)
  resourceDetectorID(id2, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the third ore to be counted be?", 8, 4)
  printInputCentered(ores[ore3] = io.read(), 6)
  resourceDetectorID(id3, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the fourth ore to be counted be?", 8, 4)
  printInputCentered(ores[ore4] = io.read(), 6)
  resourceDetectorID(id4, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the fifth ore to be counted be?", 8, 4)
  printInputCentered(ores[ore5] = io.read(), 6)
  resourceDetectorID(id5, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the sixth ore to be counted be?", 8, 4)
  printInputCentered(ores[ore6] = io.read(), 6)
  resourceDetectorID(id6, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the seventh ore to be counted be?", 8, 4)
  printInputCentered(ores[ore7] = io.read(), 6)
  resourceDetectorID(id7, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the eighth ore to be counted be?", 8, 4)
  printInputCentered(ores[ore8] = io.read(), 6)
  resourceDetectorID(id8, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the ninth ore to be counted be?", 8, 4)
  printInputCentered(ores[ore9] = io.read(), 6)
  resourceDetectorID(id9, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the tenth ore to be counted be?", 8, 4)
  printInputCentered(ores[ore10] = io.read(), 6)
  resourceDetectorID(id10, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the eleventh ore to be counted be?", 8, 4)
  printInputCentered(ores[ore11] = io.read(), 6)
  resourceDetectorID(id11, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the twelvth ore to be counted be?", 8, 4)
  printInputCentered(ores[ore12] = io.read(), 6)
  resourceDetectorID(id12, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the thirteenth ore to be counted be?", 8, 4)
  printInputCentered(ores[ore13] = io.read(), 6)
  resourceDetectorID(id13, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the fourteenth ore to be counted be?", 8, 4)
  printInputCentered(ores[ore14] = io.read(), 6)
  resourceDetectorID(id14, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the fifteenth ore to be counted be?", 8, 4)
  printInputCentered(ores[ore15] = io.read(), 6)
  resourceDetectorID(id15, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the sixteenth ore to be counted be?", 8, 4)
  printInputCentered(ores[ore16] = io.read(), 6)
  resourceDetectorID(id16, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the seventeenth ore to be counted be?", 8, 4)
  printInputCentered(ores[ore17] = io.read(), 6)
  resourceDetectorID(id17, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the eighteenth ore to be counted be?", 8, 4)
  printInputCentered(ores[ore18] = io.read(), 6)
  resourceDetectorID(id18, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the nineteenth ore to be counted be?", 8, 4)
  printInputCentered(ores[ore19] = io.read(), 6)
  resourceDetectorID(id19, 6, 8)
  mot()
  term.clear()
  printCenteredTextutils("what should the twentith ore to be counted be?", 8, 4)
  printInputCentered(ores[ore20] = io.read(), 6)
  resourceDetectorID(id20, 6, 8)
  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
intro()
assign ores()
function rednet()
  while true do
  loopLoopCheck()


remiX #13
Posted 25 November 2012 - 01:26 PM
What exactly do you want to do now?

PS: Your intro function, you still have Textutils spelt incorrectly.
cmurtheepic #14
Posted 25 November 2012 - 01:29 PM
i need it to count up on the UI for that specific resource
and to separate the massage over rednet from the turtle's ID
ChunLing #15
Posted 26 November 2012 - 07:51 AM
The sending ID and the message body are already separate (and aren't even the same type).

Try using some for loops to handle some of those giant blocks of repetitive code. Like
for i = 1,20 do
  printCenteredTextutils("what should the first ore to be counted be?", 8, 2)
  printInputCentered(ores[i] = io.read(), 4) --you'll need to change the ores table to be indexed by numbers rather than strings
  resourceDetectorID(id[i], 6, 8) --and put all the ids in a table as well
  mot()
end
If you can't use loops properly, then you have no hope of making this work. So work on your loops.
cmurtheepic #16
Posted 26 November 2012 - 08:08 AM
ok and ho do i get it to go over the line to see if it gets anymessages over ednet while displaying resource count?
ChunLing #17
Posted 26 November 2012 - 01:57 PM
Okay, I'm not sure how you're counting resources because I don't quite have the patience to read 400 lines of code, the vast majority of which are highly repetitive.

But, I presume you are getting some kind of event that increments your counters. So what you need is to build your program around an os.pullEvent() loop, which then checks the pulled event for whether it is a rednet_message or the event that increments your ore counts, and takes the appropriate action.
repeat
    tvnt = {os.pullEvent()}
    if tvnt[1] == "whatever_event_type" then --do things to increment your ore counts
    elseif tvnt[1] == "rednet_message" then --do whatever the message says
    end
until false
cmurtheepic #18
Posted 26 November 2012 - 05:21 PM
OK but i need it to run while the other parts of the program are going
and i don't really have anything to increment counter or display the ores table on the display correctly.
i don't know how to do either of these things.
help.
ChunLing #19
Posted 26 November 2012 - 05:32 PM
So what you're saying is that you need a method to count ores? Will the turtles be counting their inventory and sending that info over rednet? Because if so then the central computer may not need any events other than rednet messages.
cmurtheepic #20
Posted 01 December 2012 - 02:20 PM
yes they are and i have been fidleing with the coding and it keep saying on line 56 a '=' is expected?
i don't know what is going on and i have been having problems just like it before!
help me figure this out please
Orwell #21
Posted 01 December 2012 - 03:04 PM
You have no problem on line 56 in the last code you posted. So can you please, once again, post the full code? Maybe in
Spoilertags this time. :P/>
cmurtheepic #22
Posted 02 December 2012 - 08:52 AM
that is the full code :)/>
KaoS #23
Posted 02 December 2012 - 07:42 PM
please note that both tables will be empty as you have not surrounded the strings in quotes, at the moment the code sees them as variables with no value so they are nil… empty
cmurtheepic #24
Posted 03 December 2012 - 04:20 PM
ok. but I still haven't gotten a working version or a fix for it.
and to be honest I really don't know how to fix it :(/>
*FACE PALM*
cmurtheepic #25
Posted 19 December 2012 - 05:41 PM
hello guest