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

Bios 206: [string "wood"]:39: '=' expected

Started by pandarenkuma, 16 December 2012 - 07:08 AM
pandarenkuma #1
Posted 16 December 2012 - 08:08 AM
i not an expert but trying to get the codes for this warehouse to work.
The ides comes form drtempels and it is mostly his code one in English and not German.
But as you see i get some error under the test runs and hope some one might help me with it
the code is her: http://pastebin.com/srrH6Va4
i know names repeat it self on the second menu I'm not finished with those yet
Ulthean #2
Posted 16 December 2012 - 08:12 AM
Line 38 in the pastebin file:

os.reboot should be os.reboot()
Ulthean #3
Posted 16 December 2012 - 08:22 AM
There are some other problems too:


write("stacs?: ")
amount= io.read()
  amount = quantity +0
  print(amount, "x raw z(64) soon ready")
  while amount > 0 do
	rednet.send(y,"top1")
	quantity = amount -1
	sleep(2)
	end

this will loop forever, since amount is never changed (you only change quantity. And quantity is never actually declared before you use it in the third line above
Try something similar to this:


write("stacks?: ")
amount= io.read()
print(amount, "x raw z(64) soon ready")
while amount > 0 do
	rednet.send(y,"top1")
	amount = amount -1
	sleep(2)
end

Also: Since a lot of your code is very similar I suggest making a seperate function for the code above (add parameters).
(should you need to change something later you only have to do it once and not 20 times)

Example:


function processOrder(userMessage, rednetMessage)
  write("stacks?: ")
  amount= io.read()
  print(amount, userMessage)
  while amount > 0 do
	rednet.send(y,rednetMessage)
	amount = amount -1
	sleep(2)
  end
end

The main body of your code would then be:


if input == 1 then
  processOrder("x raw z(64) soon ready", "top1")
elseif input == 2 then
  processOrder("x sticks z(64) soon ready", "top2")

...

end

pandarenkuma #4
Posted 16 December 2012 - 10:36 AM
OK created a smaller one but now i get attempt to compare string with number expected, got string instead.
after i have chosen form the menu.
new unfinished script: http://pastebin.com/DwiWHuCZ
I got the client PC to work and the main menu and startup. so i do have rednet connection.
so i have to ask again. thanks for you help.
Ulthean #5
Posted 16 December 2012 - 10:45 AM
I'm pretty sure you should make it:


input = tonumber(io.read())

amount=tonumber(io.read())

Sorry I didn't spot that to begin with
pandarenkuma #6
Posted 16 December 2012 - 11:02 AM
Thank you! i got it working now.

when i have all the test list up an going i will paste the codes in the forum for others to take a look at.