Jump to content




I really don't know what's wrong

help lua

2 replies to this topic

#1 ZKlack

  • Members
  • 9 posts
  • LocationRiyadh

Posted 07 January 2020 - 08:28 PM

I have been away for way too long. please help me I can't figure out what's wrong with this code

local mon = peripheral.find("monitor")
local steps = 1
local waittime = 1
local mycolors = { colors.red, colors.green, colors.blue, colors.white}
local pattern = {}
for x = 1,61 do
	pattern[x] = {}
	for y= 1,61 do
		pattern[x][y] = 4
	end
end
function draw()
	for y = 1,61 do
		mon.setCursorPos(1,y)
		for x = 1,61 do
			mon.setBackgroundColor(mycolors[pattern[x][y]])
			mon.write(" ")
		end
	end
end
function progress()
	for x = 1,61 do
		for y = 1,61 do
			if(pattern[x][y]==2) then pattern[x][y]=3 else pattern[x][y]=4 end
		end
	end
	for x = 1,61 do
		for y = 1,61 do
			sides = 0
			if(pattern[x][y]==4) then
				if(1<x  and 1<y ) then if(pattern[x-1][y-1]==3) then sides=sides+1 end end
				if(		 1<y ) then if(pattern[x  ][y-1]==3) then sides=sides+1 end end
				if(x<61 and 1<y ) then if(pattern[x+1][y-1]==3) then sides=sides+1 end end
				if(1<x		  ) then if(pattern[x-1][y  ]==3) then sides=sdies+1 end end
				if(x<61		 ) then if(pattern[x+1][y  ]==3) then sides=sides+1 end end
				if(1<x  and y<61) then if(pattern[x-1][y+1]==3) then sides=sides+1 end end
				if(		 y<61) then if(pattern[x  ][y+1]==3) then sides=sides+1 end end
				if(x<61 and y<61) then if(pattern[x+1][y+1]==3) then sides=sides+1 end end
			end
			if (sides!=0) then pattern[x][y]=(sides%2)+1 end
		end
	end
end
function mainloop()
	while true do
		draw()
		for i = 1,steps do progress() end
		os.sleep(waittime)
	end
end
pattern[16][16] = 1
mainloop()

this is the error message:
bios.lua:26: [string "mine.lua"]:42: ')' expected


if it wasn't obvious, the program is supposed to start with a dot then put new dots in any place that has odd amount of dots around it and remove old dots then repeat.

#2 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 07 January 2020 - 08:52 PM

sides != 0 should be sides ~= 0 instead.

#3 ZKlack

  • Members
  • 9 posts
  • LocationRiyadh

Posted 07 January 2020 - 09:11 PM

View PostSquidDev, on 07 January 2020 - 08:52 PM, said:

sides != 0 should be sides ~= 0 instead.

thanks.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users