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

Sorting system problem

Started by malo13, 07 May 2013 - 01:23 PM
malo13 #1
Posted 07 May 2013 - 03:23 PM
"Title:" Sortingsystemproblem
Hello i am trying to build a Sortingsystem with a interactive sorter. I can start my code (so i hope no logical mistakes) but when i put anything into the sorter i get the problem sort :8: attemt to call nil. And here is ma Code:


   
m = peripheral.wrap("right")
   
x =1
   
name = 0
   
function ItemName_Menge()
   
print(ID)
   
print(menge_hinzu)
   
items=fs.open(ID,"a")
   
name = items.readLine()
   
if ( name == 0 ) then
   
  while ( x ==1) do
   
  print("Was ist das Item mit der ID"..ID)
   
  name1 = read()
   
  name2 = print("Bitte kontroliere die Eingabe und wiederhole Sie")
   
  if name1 == name2 then
   
  items.writeLine(name)
   
  items.writeLine(menge_neu)
   
  x = 0
   
  end
   
  end
   
else
   
  menge_alt = items.readLine()
   
  items.close()
   
end
   
end
   
function item_empfangen()
   
event, ID, menge_hinzu = os.pullEvent("isort_item")
   
ID = tostring(ID)
   
menge_hinzu = tostring(menge_hinzu)
   
end
   
function menge_addieren()
   
fs.makeDir("items")
   
items=fs.open("items/"..ID,"w")
   
menge_neu = menge_alt + menge_hinzu
   
items.writeLine(name)
   
items.writeLine(menge_neu)
   
items.close()
   
end
   
function ausgabe()
   
shell.run("clear")
   
term.write(name.."wurde"..menge_hinzu" mal ins System aufgenommen und ist nun"..menge_neu.."vorhanden")
   
end
   
item_empfangen()
   
ItemName_Menge()
   
menge_addieren()
   
ausgabe()

thank you for helping
your malo13
Edited by
Lyqyd #2
Posted 07 May 2013 - 05:09 PM
Split into new topic.

You cannot use file reading functions when you open a file in either append or write modes. Try opening your file in read mode ("r") instead of append mode ("a").
malo13 #3
Posted 08 May 2013 - 04:41 PM
Thanks
H4X0RZ #4
Posted 08 May 2013 - 05:16 PM
[OFFTOPIC]
I can seebthat you are german :D/>
[/OFFTOPIC]