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

bios:367: error, function arguments expected, whats wrong?

Started by jjjhfam, 21 June 2015 - 03:49 AM
jjjhfam #1
Posted 21 June 2015 - 05:49 AM
I'm getting an error: "bios:367: [string "treeFeller"]:13: function arguments expected" with a continuous program that fells trees. The function that the error contains is included.

ComputerCraft 1.73
Minecraft 1.7.10
Forge 10.13.2.1291

Slots:
Slot 1: Saplings
Slot 2: Bone Meal (The code should instead wait a minute if no bonemeal is detected or it runs out before the tree grows)
Slot 3: Logs
Slot 4: Fuel


function plantAndGrow()
  slotOne = turtle.getItemDetail(1)
  slotTwo = turtle.getItemDetail(2)
  if slotOne.name == minecraft:sapling	  --Line 13
    turtle.select(1)
    turtle.place()
   elseif slotOne == nil then
    print("Saplings must be in slot one")
  end
  if slotTwo.name == minecraft:dye then
    turtle.select(2)
    while turtle.inspect() == minecraft:sapling do
	  slotTwo = turtle.getItemDetail(2)
	  if slotTwo.count ~= 0 then
	    turtle.place()
	   elseif slotTwo == nil then
		 os.sleep(60)
	   else
		 print("An unknown error occurred")
	  end
	 elseif slotTwo == nil
	  repeat
	   block = turtle.inspect()
	   os.sleep(60)
	  until block.name = minecraft:log
	 else
	  print("An unknown error occurred")
    end
end
Grim Reaper #2
Posted 21 June 2015 - 06:55 AM
You have

minecraft:sapling
which Lua sees as

minecraft.sapling(minecraft)
where 'minecraft' is a table and 'sapling' is a function within the 'minecraft' table.

Just put quotes around "minecraft:sapling" at line 13, 19, 21, and 34. I'm not entirely familiar with the turtle API, but that's a solution to the first error that you're getting.
Bomb Bloke #3
Posted 21 June 2015 - 12:20 PM
Just put quotes around "minecraft:sapling" at line 13, 19, 21, and 34. I'm not entirely familiar with the turtle API, but that's a solution to the first error that you're getting.

That'll indeed fix the error at hand, but since you mention it, there is a bit more to it than that - turtle.inspect() doesn't simply return strings, it returns a success-indicating boolean followed by a table, and the block info (if one was found) is in said table. This is as opposed to turtle.getItemDetail(), which simply returns a table.

So, to make a loop with it, you might use this sort of structure:

while true do
	local blockFound, blockData = turtle.inspect()
	
	if blockFound and blockData.name == "minecraft:sapling" then
		-- Do stuff
	else break end
end

You're going to have to re-arrange things somewhat anyway, jjjhfam, as you've got an elseif where it doesn't belong. Fix that indentation!
Edited on 21 June 2015 - 10:21 AM
jjjhfam #4
Posted 21 June 2015 - 09:43 PM
Your suggestions worked! There are more problems that I believe I can work and and continue debugging on my own, thanks for the help!