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

[LUA] [Error] Code for Lumberjack not working

Started by Masoman3, 17 March 2012 - 09:18 AM
Masoman3 #1
Posted 17 March 2012 - 10:18 AM
I have been trying to create a program that will ask how large of an area should it mine, hoping its flat, and mining all trees in the area. It keeps coming up with an error saying "bios:206: [string "Lumberjack"]:8:unexpected symbol". Does anyone have any ideas?

The code is here, with a download underneath:
————————————————————————————
<script src="http://pastebin.com/embed_js.php?i=sjSVaQvF"></script>
————————————————————————————–


[attachment=94:Lumberjack.txt]


If it's something really obvious, it's the first program I tried to make.
Casper7526 #2
Posted 17 March 2012 - 11:11 AM
depth = read(*1)

if you want to read a number then do depth = tonumber(read())
Luanub #3
Posted 17 March 2012 - 11:13 AM
Bahh Ninja'd by Casper :D/>/>

Couple issues, see below

SpoilerFirst there is a couple of problems with your read statements. You need to remove the *1 and have it use tonumber so it collects the entry as a number.


print("Enter the width of the area.")
width = tonumber(read())
print("Enter the length of the area")
depth = tonumber(read())

Second when you are using your while turtle.compare and while turtle.detect your not giving it a value to check against.

Change to

   	 while turtle.compare() == "true" do
			while turtle.detect() == "true" do

Next your widthdone needs to update the variable when your doing your +1

change

widthdone + 1	end

to

widthdone = widthdone + 1	end

Hope that helps.
Edited on 17 March 2012 - 10:14 AM