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

Syntax Error?

Started by Nougat, 03 August 2015 - 01:26 AM
Nougat #1
Posted 03 August 2015 - 03:26 AM
The following code receives the error "bios:367: [string "makeHouse"]:22:syntax error


local length = ""
local width = ""
term.write("How long should the house be? ")
length = read()
term.write("How wide should the house be? ")
width = read()
function adjustStack()
   local dealer = turtle.getItemCount(1)
   local frog = 2
   local buttz = 2
   while dealer < 1 do
	  turtle.select(frog)
	  dealer = turtle.getItemCount(frog)
	  butts = frog + 1
	  frog = butts
   end
end
function frontSection(c)(z)
  
   isFrontEven = c % 2
  
   if z ~= 3 then
  
	  if isFrontEven == 1 then
		 d = c - 3
		 c = d / 2
	  else
		 d = c - 2
		 c = d / 2
	  end
  
	  for a = 1, c do
	  turtle.placeDown()
	  adjustStack()
	  turtle.forward()
	  end
  
	  if isFrontEven == 0 then
	  turtle.forward()
	  end
  
	  for b = 1, c do
	  turtle.placeDown()
	  adjustStack()
	  turtle.forward()
	  end
   end
   else
   for g = 1, c do
	  turtle.placeDown()
	  adjustStack()
	  turtle.forward()
end

print("Creating House")

turtle.select(1)
adjustStack()

for u = 1, 3 do

   turtle.up()
   turtle.forward()

  
for e = 1, 3 do

   for l = 1, length do
	  turtle.placeDown()
	  turtle.forward()
	  adjustStack()
   end

   turtle.turnLeft()
   turtle.forward()

  
   for w = 1, width do
	  turtle.placeDown()
	  turtle.forward()
	  adjustStack()
   end

  
turtle.turnLeft()
   turtle.forward()

  
for p = 1, length do
	  turtle.placeDown()
	  adjustStack()
	  turtle.forward()
   end

   turtle.turnLeft()
   turtle.forward()

   frontSection(width)(u)

   turtle.turnLeft()
   turtle.forward()

  
end
end
print("Looky here, I made a house!")

I tried the code in lua mode with the following code on the turtle but it worked fine.

isFrontEven = 4 % 2
print(isFrontEven)
isFrontEven = 5 % 2
print(isFrontEven)

What's wrong?
Lyqyd #2
Posted 03 August 2015 - 05:18 AM
Well, this is definitely a problem:


function frontSection(c)(z)

You probably want this instead:


function frontSection(c, z)
Nougat #3
Posted 03 August 2015 - 05:20 AM
Well, this is definitely a problem:


function frontSection(c)(z)

You probably want this instead:


function frontSection(c, z)

Thank you so much! I had no idea what was wrong.
Just to explain why I wrote it like that, I was watching direwolf20's video on functions and he didn't explain using multiple arguments, but it looked similar to another language I've used before, so I improvised.