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

Error 338 when starting my program

Started by Wurstmann, 02 December 2014 - 08:56 PM
Wurstmann #1
Posted 02 December 2014 - 09:56 PM
Hello!
I have written my first own programm for the mining turtle, which should just mine! :D/>
It should mine above and down its self and infront. In the second and third slot comes cobble and dirt, which should never get filled.
The first slot is for coal.

When I start my programm it says "bios:330 [String :"Mining"]:1:"
pls help me :)/>


function mining()
for a = 0, 100, 1 do
  for b = 0, 100, 1 do
   turtle.dig()  
   turtle.forward()
   turtle.detectUp() do
				  turtle.digUp()
				  sleep(0.25)
   end
   turtle.detectDown() do
				  turtle.digDown()
				  sleep(0.25)
   end
   fuel = turtle.getFuleLevel()
   if(fuel < 400) then
    turtle.select(1)
    turtle.refuel()
   end
  turtle.select(2)
  turtle.drop(turtle.getItemCount() - 1)
  turtle.select(3)
  turtle.drop(turtle.getItemCount() - 1)
  end
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
  for b = 0, 100, 1 do
   turtle.dig()  
   turtle.forward()
   turtle.detectUp() do
				  turtle.digUp()
				  sleep(0.25)
   end
   turtle.detectDown() do
				  turtle.digDown()
				  sleep(0.25)
   end
   if(fuel < 400) then
    turtle.select(1)
    turtle.refuel()
   end
  turtle.select(2)
  turtle.drop(turtle.getItemCount() - 1)
  turtle.select(3)
  turtle.drop(turtle.getItemCount() - 1)
  end
turtle.turnRight()
turtle.forward()
turtle.turnRight()
end
end
function statusBildschirm()
	    term.setCursorPos( 1, 3)
	    term.clearLine()
	    fuellevel = turtle.getFuelLevel()
	    print("Fuel-Level: " .. fuellevel)
end
Cranium #2
Posted 02 December 2014 - 10:08 PM
Moved to Ask a Pro
TurtleHunter #3
Posted 02 December 2014 - 11:59 PM
Your error is in the 330 line of your program. Upload your FULL program to pastebin and share the link
KingofGamesYami #4
Posted 03 December 2014 - 12:00 AM
Your error is in the 330 line of your program. Upload your FULL program to pastebin and share the link

The error is on line 330 of bios.lua.

It is also supposedly on line 1 of the program.
Edited on 02 December 2014 - 11:01 PM
TurtleHunter #5
Posted 03 December 2014 - 12:02 AM
Your error is in the 330 line of your program. Upload your FULL program to pastebin and share the link

The error is on line 330 of bios.lua.

It is also supposedly on line 1 of the program.
Maybe he is trying to call Mining() instead of mining()
valithor #6
Posted 03 December 2014 - 12:06 AM
Your error is in the 330 line of your program. Upload your FULL program to pastebin and share the link

The error is on line 330 of bios.lua.

It is also supposedly on line 1 of the program.
Maybe he is trying to call Mining() instead of mining()

Its a error in the BIOS… This means that he is using a function, which is defined in the bios file incorrectly.

-snip

What version of CC are you using, and is that the full code? From what I can tell the code that you posted would not give a bios error with that line (if you are running cc 1.65) or that is not the full code.

Btw when posting code on the forums it is generally a good idea to hit the remove format button in the top left so the forums does not mess up your indenting.

edit: in CC 1.65 line 330 in the bios file is part of the read function, which he does not use.
Edited on 02 December 2014 - 11:07 PM
Bomb Bloke #7
Posted 03 December 2014 - 01:12 AM
Let's forget about bios.lua for now - it's a safe bet that the actual problem is in the mining script, yeah?

First, let's take a closer look at the code we've got here:

Spoiler
function mining()
	for a = 0, 100, 1 do
		for b = 0, 100, 1 do
			turtle.dig()  
			turtle.forward()
			
			turtle.detectUp()  -- Runs "turtle.detectUp()", but ignores the result.
			
			do  -- This gets done no matter what.
				turtle.digUp()
				sleep(0.25)
			end
		
			turtle.detectDown()  -- Runs "turtle.detectDown()", but ignores the result.

			do  -- This gets done no matter what.
				turtle.digDown()
				sleep(0.25)
			end
	
			fuel = turtle.getFuleLevel()  -- Typo; no such function.

			if(fuel < 400) then
				turtle.select(1)
				turtle.refuel()
			end
	
			turtle.select(2)
			turtle.drop(turtle.getItemCount() - 1)
			turtle.select(3)
			turtle.drop(turtle.getItemCount() - 1)
		end

		turtle.turnLeft()
		turtle.forward()
		turtle.turnLeft()

		for b = 0, 100, 1 do
			turtle.dig()  
			turtle.forward()
			
			turtle.detectUp()  -- Runs "turtle.detectUp()", but ignores the result.

			do  -- This gets done no matter what.
				turtle.digUp()
				sleep(0.25)
			end

			turtle.detectDown()  -- Runs "turtle.detectDown()", but ignores the result.

			do  -- This gets done no matter what.
				turtle.digDown()
				sleep(0.25)
			end

			if(fuel < 400) then  -- "fuel" isn't being updated...
				turtle.select(1)
				turtle.refuel()
			end

			turtle.select(2)
			turtle.drop(turtle.getItemCount() - 1)
			turtle.select(3)
			turtle.drop(turtle.getItemCount() - 1)
		end

		turtle.turnRight()
		turtle.forward()
		turtle.turnRight()
	end
end

function statusBildschirm()
	term.setCursorPos( 1, 3)
	term.clearLine()
	fuellevel = turtle.getFuelLevel()
	print("Fuel-Level: " .. fuellevel)
end

However you look at it, that's not going to run. There's a typo causing it to try to call a function that doesn't exist, and neither the mining() nor statusBildschirm() functions actually get called at all (suggesting this isn't the whole program?).

Here's a quick re-write which may be of use:

Spoiler
local function forward()  -- For convenience.
	while not turtle.forward() do  -- Attempt to go forward, and if it fails, loop...
		turtle.dig()
		turtle.attack()
	end
end

local function mining()
	for a = 0, 201 do
		for b = 0, 100 do  -- 101 movements per row, plus the starting block, is 102 blocks per row. Intentional, or should this only go to 99...?
			forward()

			while turtle.detectUp() do turtle.digUp() end  -- So long as blocks are above us, dig.

			if turtle.detectDown() then turtle.digDown() end  -- No need to repeat this.

			if turtle.getFuelLevel() < 400 then
				turtle.select(1)
				turtle.refuel()
			end

			for c = 2, 3 do
				if turtle.getItemCount(c) > 1 then  -- Changing slots is slow, so let's only do it if we need to.
					turtle.select(c)
					turtle.drop(turtle.getItemCount() - 1)
				end
			end
		end

		if bit.band(a,1) == 1 then  -- if "a" is an odd number, then...
			turtle.turnRight()
			forward()
			turtle.turnRight()
		else
			turtle.turnLeft()
			forward()
			turtle.turnLeft()
		end
	end
end

local function statusBildschirm()
	term.setCursorPos( 1, 3)
	term.clearLine()
	fuellevel = turtle.getFuelLevel()
	print("Fuel-Level: " .. fuellevel)
end
Wurstmann #8
Posted 03 December 2014 - 01:31 PM
What version of CC are you using, and is that the full code?
I play it in Tekkitlite, so i think its 1.5, isn't it?
Yeah it's the full code. I've written it by myself and I don't know anything about lua. I searched programmingparts in the internet and wrote them down. :D/>

Edit: it also says "unexpectet symbol"
The Code from BombBloke gives the same error
Edited on 03 December 2014 - 12:54 PM
Cranium #9
Posted 03 December 2014 - 04:37 PM
It'd help if you could post verbatim the error code.
Wurstmann #10
Posted 03 December 2014 - 06:36 PM
The error code is:
bios:330 [String :"Mining"]:1:
unexpectet symbol
ElvishJerricco #11
Posted 03 December 2014 - 07:07 PM
The error code is:
bios:330 [String :"Mining"]:1:
unexpectet symbol

Then what you've put on this topic isn't exactly what's in your in game file. That error means you're writing something that's syntactically incorrect (probably just by a tiny typo), and the code you posted here is syntactically fine.
Wurstmann #12
Posted 03 December 2014 - 07:24 PM
Oh… I saw i wrote it wrong… XD
It's 338 not 330.. I'm sorry for my madness :D/>
ElvishJerricco #13
Posted 03 December 2014 - 07:58 PM
Oh… I saw i wrote it wrong… XD
It's 338 not 330.. I'm sorry for my madness :D/>
That number isn't really the problem in question though. The error is saying that the very first line in the program that is on your computer has a typo. That typo is not present in the code you posted.
The_Cat #14
Posted 03 December 2014 - 09:44 PM
You should upload to pastebin and give us the link so we can see all the code to determine the problem.
Edited on 03 December 2014 - 09:00 PM