For statement i cant fix

i have tried to find out whats causing the error but i cant figure it out. it says that it wants an = sign near end but when i put it there its says that an unexpected symbol is there. (my code may be fairly messy so any extra clean up help would be good as well). tbh it might not even do what its supposed to do to begin with but what ive managed to do so far before this error was like 90% of what i wanted.

function update(self, dt)
	self.input.x = 0
	self.input.y = 0
	local seed = math.random(6 * 10)
	local mov = math.random(1 * 4)
	local timeeer = timer.delay(0.5, true, function(self)
		local xpos = math.random(1 * 4)
		local ypos = math.random(1 * 4)
		local xposb = math.random(1 * 4)
		local yposb = math.random(1 * 4)
		local tim = timer.delay(seed, true, function(self)
			for i=1, mov do
				if mov == 1 then
					self.input.y = ypos
				elseif mov == 2 then
					self.input.y = -yposb
				elseif mov == 3 then
					self.input.x = -xposb
				elseif mov == 4 then
					self.input.x = 1 xpos
				 = end
				
				local pos = go.get_position()
				pos = pos + self.dir * self.speed * dt
				go.set_position(pos)
			end
		end)
	end)
end

oh yeah its supposed to be a basic random movement ai if anyone’s curious

1)"=" near end
2) self.input.x = 1 xpos
no sign after 1 before xpos

2 Likes
	self.input.x = xpos
	= end
				
				local pos = go.get_position()
				pos = pos + self.dir * self.speed * dt
				go.set_position(pos)

still throws an error unfortunately an i being dumb or is somthing else up?

= end

no need = before end

1 Like

works well enough now i think i can fix it from here

2 Likes

Your code would be much more legible and you probably wouldn’t have made these mistakes if you organized your code to separate out the function definitions. Defining a function inside a list of arguments inside a function definition inside a list of arguments inside a function is pretty much guaranteed to be confusing, right? There’s no reason not to define the timer callback functions by themselves and then just use the function name inside of timer.delay.

2 Likes