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

ERROR: bios:339: [string "Nexus"]:4: '=' expected

Started by Dragon911XX, 08 June 2014 - 06:59 PM
Dragon911XX #1
Posted 08 June 2014 - 08:59 PM
I'm familiar with other codes, (VisualBasics whatever, and Java) LUA seems pretty basic and I've got a borderline understanding of what I'm typing.

Anyways, after spending a good couple of hours watching videos and looking at websites and forum fixes, none that work, upon running my program it gives me this error:

bios:339: [string "Nexus"]:4: '=' expected

I'm guessing there is something wrong with the 4th line in the code, but the wiki page for conditions says I'm doing my coding correctly(?)

http://computercraft...onal_statements

I know that 'for's require 2 equals signs to function, so having >= should work.

local time = os.time()
local formattedTime = textutils.formatTime(time, false)

While do
local i = 0
  if time >= 12000 then
	print("Placing Moonstone blocks...")
	turtle.select(2)

	for i = 1, 4, 1 do
	  turtle.digDown()
	  turtle.placeDown()
		for i = 0, 4, 1 do
		  turtle.forward()
		end
	  turtle.turnLeft()
  else if time >= 1 then
	print("Placing Diamond blocks...")
	turtle.select(1)

	for i == 1, 4, 1 do
	  turtle.digDown()
	  turtle.placedown()
		for i == 1, 4, 1 do
		  turtle.forward()
		end
	  turtle.turnLeft
	end
  end
Lyqyd #2
Posted 08 June 2014 - 09:10 PM
You've capitalized "while", making it "While", which is not a Lua keyword. You also need a condition there. Perhaps you're looking for "while true do"? Also, your first two for loops are correct, with an assignment operator, but your second two have the comparison operator, which is not correct. "else if" should be one word, "elseif". Your first for loop is missing an end. Your while loop is missing an end.
Lua.is.the.best #3
Posted 09 June 2014 - 06:02 AM
While do
I'm assuming you mean
while true do
by that.
for i == 1, 4, 1 do --line 21
for i == 1, 4, 1 do --line 24
You are not comparing 1, 4, 1 to i!
The "==" should be "=".
Lyqyd #4
Posted 09 June 2014 - 06:04 AM
Why did that need repeating?
Dragon911XX #5
Posted 13 June 2014 - 10:14 PM
Thanks for the replies! Certainly helped to know the true needed to be there and its one = as well as ifelse being one word.

The update is as follows;

>Nexus
Placing diamond blocks…
nexus:24: attempt to call nil

Here's my updated code:

local time = os.time()
local formattedTime = textutils.formatTime(time, false)

while true do
  local i = 0
  if time >= 12000 then
    print("Placing Moonstone blocks...")
    turtle.select(2)

    for i = 1, 4 do
	  turtle.digDown()
	  turtle.placeDown(2)
	    for i = 1, 4 do
		  turtle.forward()
	    end
	  turtle.turnLeft()
    end
  elseif time >= 1 then
    print("Placing Diamond blocks...")
    turtle.select(1)
  
    for i = 1, 4 do
	  turtle.digDown()
	  turtle.placedown(1)
	    for i = 1, 4 do
		  turtle.forward()
	    end
	  turtle.turnLeft()
    end
  end
end
natedogith1 #6
Posted 14 June 2014 - 01:01 AM
the issue is that on line 4 you have "turtle.placedown(1)" when you should have "turtle.placeDown(1)", capitalization matters in Lua (and standard formatting uses camel case(explaining the capital 'D'))
Edited on 13 June 2014 - 11:01 PM
flaghacker #7
Posted 14 June 2014 - 07:05 AM
And why do you have a "1" in your function call turtle.placeDown?
Dragon911XX #8
Posted 24 June 2014 - 05:50 PM
Alright, update on code, haven't done much on it since I've had exams and stuff but here it is so far.


local time = os.time()
local formattedTime = textutils.formatTime(time, false)
print("The time is "..formattedTime..".")
while true do
  local i = 0  --i = action loop
  local m = 0  --m = movement loop
 
  if time >= 12000 then
    print("Placing Moonstone blocks...")
    turtle.select(2)
 
    for i = 1, 4 do
	  turtle.select(2)
	  turtle.digDown()
	  turtle.placeDown()
	    for m = 1, 4 do
		  turtle.forward()
	    end
	  turtle.turnLeft()
    end
  elseif time <= 11999 then
    print("Placing Diamond blocks...")
    turtle.select(1)
   
    for i = 1, 4 do
	  turtle.select(1)
	  turtle.digDown()
	  turtle.placeDown()
	    for m = 1, 4 do
		  turtle.forward()
	    end
	  turtle.turnLeft()
    end
  end
end

Upon running, even if it's night, it still wants to place the diamond blocks. It has no problem destroying and placing the blocks, instead, it doesn't want to move forward. It turns and repeats itself over.

Here's what it does.

>Nexus
The time is 1:52 AM.
Placing Diamond blocks...
Placing Diamond blocks...
Placing Diamond blocks...
Terminated