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

bios:338: [string "fullMine"]:1: '=' expected

Started by Cruoton, 21 March 2013 - 04:58 AM
Cruoton #1
Posted 21 March 2013 - 05:58 AM
[Resolved] Make sure your pastebin code is set to public in order for minecraft to use it, otherwise it will throw this error.

I recently started playing Feed the Beast and discovered mining turtles.
After using its default program of tunnel, I decided to make my own program that would create a 3x3 tunnel, along with branches while placing torches along the way.

I lightly modified the basic tunnel program and added in a branch program that I found on the internet, copied it into pastebin and loaded it into my turtle.

I named the program fullMine and upon running fullMine I received the following error message:
bios:338: [string "fullMine"]:1: '=' expected

This is the pastebin of my code: http://pastebin.com/CYNDyW0D
And this is the code :
Spoiler

--Creates a 3x3 Horizontal Mine Shaft of desired length with torches every 8 blocks
--Creates branches of desired length along Mine Shaft with 4 block spacing
--Place torches in slot 1 and fuel in any slot

local tArgs = { ... }
if #tArgs <2 then
		print("Usage: fullMine <Length> <Width>")
		return true
end

--length is shaft length
--steps is branch length

local length = tonumber(tArgs[1])
local steps = tonumber(tArgs[2])


--if #tArgs >= 2 and tArgs[2] == "nt" then
--	torch = false
--else
--	torch = true
--end


-- Mine in a quarry pattern until we hit something we can't dig
-- local length = tonumber( tArgs[1] )


if length < 1 then
		print( "Tunnel length must be positive" )
		return
end
	  
local depth = 0
local collected = 0


local function collect()
		collected = collected + 1
		if math.fmod(collected, 25) == 0 then
				print( "Mined "..collected.." items." )
		end
end

local function tryDig()
		while turtle.detect() do
				if turtle.dig() then
						collect()
						sleep(0.5)
				else
						return false
				end
		end
		return true
end

local function tryDigUp()
		while turtle.detectUp() do
				if turtle.digUp() then
						collect()
						sleep(0.5)
				else
						return false
				end
		end
		return true
end

local function tryDigDown()
		while turtle.detectDown() do
				if turtle.digDown() then
						collect()
						sleep(0.5)
				else
						return false
				end
		end
		return true
end

local function refuel()
		local fuelLevel = turtle.getFuelLevel()
		if fuelLevel == "unlimited" or fuelLevel > 0 then
				return
		end
	  
		local function tryRefuel()
				for n=1,16 do
						if turtle.getItemCount(n) > 0 then
								turtle.select(n)
								if turtle.refuel(1) then
										turtle.select(1)
										return true
								end
						end
				end
				turtle.select(1)
				return false
		end
	  
		if not tryRefuel() then
				print( "Add more fuel to continue." )
				while not tryRefuel() do
						sleep(1)
				end
				print( "Resuming Tunnel." )
		end
end

local function tryUp()
		refuel()
		while not turtle.up() do
				if turtle.detectUp() then
						if not tryDigUp() then
								return false
						end
						elseif turtle.attackUp() then
								collect()
				else
						sleep( 0.5 )
				end
		end
		return true
end

local function tryDown()
		refuel()
		while not turtle.down() do
				if turtle.detectDown() then
						if not tryDigDown() then
								return false
						end
				elseif turtle.attackDown() then
						collect()
				else
						sleep( 0.5 )
				end
		end
		return true
end

local function tryForward()
		refuel()
		while not turtle.forward() do
				if turtle.detect() then
						if not tryDig() then
								return false
						end
				elseif turtle.attack() then
						collect()
				else
						sleep( 0.5 )
				end
		end
		return true
end

local function branch()
		--Starting the dig for branch
		for x = 1, steps do
				if not turtle.forward() then
						repeat
				refuel()
				tryDig()
				sleep()
		until turtle.forward()
		end
end

	--Getting into position for the return
		tryDigUp()
		tryUp()
		turtle.turnRight()
		turtle.turnRight()

	--Starting the return
		for x = 1, steps do
				tryDigUp()
				if x % 8 == 0 then
				turtle.placeDown()
		end
		if not tryForward() then
				repeat
				tryDig()
				sleep(0.25)  
				until tryForward()
				end
		end
end
	  



print( "Tunnelling..." )



for n=1,length do
		if n % 8 == 0
				turtle.placeDown()
		end
		tryDigUp()
		turtle.turnLeft()
		tryDig()
		tryUp()
		tryDig()
		tryUp()
		tryDig()
		turtle.turnRight()
		turtle.turnRight()
		tryDig()
		tryDown()
		tryDig()
		tryDown()
		tryDig()
		turtle.turnLeft()

		if n % 4 == 0
				turtle.turnRight()
				tryForward()
				branch()
				tryDown()
				tryForward()
				turtle.turnRight()
		end

		if n % 4 == 2
				turtle.turnLeft()
				tryForward()
				branch()
				tryDown()
				tryForward()
				turtle.turnLeft()
		end  
	  
		if n<length then
				tryDig()
				depth = depth + 1
				if not tryForward() then
						print( "Aborting Tunnel." )
						break
				end
				else
				print( "Tunnel complete." )
		end
end

print( "Returning to start..." )

-- Return to where we started
turtle.turnLeft()
turtle.turnLeft()
while depth > 0 do
		if tryForward() then
				depth = depth - 1
		else
				tryDig()
		end
end

turtle.turnRight()
turtle.turnRight()
print( "Tunnel complete." )
print( "Mined "..collected.." items total." )



--Starting the dig for branch
--[[for x = 1, steps do
	if not turtle.forward() then
		repeat
			turtle.dig()
			sleep(0.6)
		until turtle.forward()
	end
end

--Getting into position for the return
turtle.digUp()
turtle.up()
turtle.turnRight()
turtle.turnRight()

--Starting the return
for x = 1, steps do
	turtle.digUp()
	if x % 8 == 0 then
		turtle.placeDown()
	end
	if not turtle.forward() then
		repeat
			turtle.dig()
			sleep(0.25)  
		until turtle.forward()
	end
end]]
Lyqyd #2
Posted 21 March 2013 - 06:33 AM
Split into new topic.

It is literally impossible for that code to throw that error. What is the code you are actually using?
Cruoton #3
Posted 21 March 2013 - 06:46 AM
Split into new topic.

It is literally impossible for that code to throw that error. What is the code you are actually using?

As far as I know that IS the code I am actually using. When I downloaded the file again, however, it threw me a missing then error which I fixed and now it seems to work fine until the first branch where it freezes and gives bios:133: expected number. I'll tweak the code for that part a bit but my original issue is resolved I guess.

Thank you for your help :)/>
Lyqyd #4
Posted 21 March 2013 - 06:47 AM
No problem! Feel free to ask further questions about this code (if you have any!) in this topic. :)/>
Cruoton #5
Posted 21 March 2013 - 06:58 AM
No problem! Feel free to ask further questions about this code (if you have any!) in this topic. :)/>

I did another edit to the code (it's the same link). I changed the branch()'s turtle.forwards to tryForward()s and it works like a charm now.

Once again thanks for the help and fast response time :)/>
Cruoton #6
Posted 24 March 2013 - 03:36 PM
[Resolved] I figured out the error after making another program.

If you create a program in pastebin and it is private it will not let minecraft download it properly and throw that error.
So basically, make sure your programs are set to public if you want your turtle to use them. Hopefully this will help anyone else with this problem.