Expression expected error
idk why but it keeps saying "expression expected" when i try to add an end for the draw function. pls help me out :(
idk why but it keeps saying "expression expected" when i try to add an end for the draw function. pls help me out :(
Could you please add the snippet of the code? if there's a function inside of the draw function using "=" then if you only have one it will say that. otherwise, I'm not sure what it's referring to
draw = function() screen.fillRect(0,0,screen.width,screen.height,"rgb(29,0,43)"
for i=-6 to 6 by 1 screen.drawSprite("wall",i*40-position%40,-80,40) end
screen.drawSprite("hero",-80,-50+hero_y,20) for i=0 to blades.length-1 screen.drawSprite("blade",blades[i]-position-80,-50,20) end
screen.drawText(score,120,80,20,"#FFF") if gameover then screen.fillRect(0,0,screen.width,screen.height,"rgba(255,0,0,.5)") screen.drawText("OWIE :(",0,0,50,"#FFF") elsif not running then screen.drawText("GO :3",0,30,50,"#FFF") end // screen.drawText(system.fps,-80,80,10,"#FFF") end
draw = function()
screen.fillRect(0,0,screen.width,screen.height,"rgb(29,0,43)")
for i=-6 to 6 by 1
screen.drawSprite("wall",i*40-position%40,-80,40)
end
screen.drawSprite("hero",-80,-50+hero_y,20)
for i=0 to blades.length-1
screen.drawSprite("blade",blades[i]-position-80,-50,20)
end
screen.drawText(score,120,80,20,"#FFF")
if gameover then
screen.fillRect(0,0,screen.width,screen.height,"rgba(255,0,0,.5)")
screen.drawText("OWIE :(",0,0,50,"#FFF")
elsif not running then
screen.drawText("GO :3",0,30,50,"#FFF") end // screen.drawText(system.fps,-80,80,10,"#FFF")
end
this code runs fine for me although I don't have the full code so if you paste all the code including init and update then I could help you
init = function() gameover = 0 running = 0 blades = [200,300,400] passed = [0,0,0] score = 0 position = 0 speed = 2 end
update = function() if gameover then gameover += 1 if gameover>300 then init() end elsif running then position = position+speed speed = speed + 0.001
if touch.touching and hero_y == 0 then
hero_vy = 7
// audio.beep("square tempo 20000 volume 10 span 100 C4 to C6")
end
hero_vy -= 0.3
hero_y = max(0,hero_y+hero_vy)
for i=0 to blades.length-1
if blades[i]<position-120 then
blades[i] = position+280+random.next()*200
passed[i] = 0
end
if abs(position-blades[i])<10 then
if hero_y<10 then
running = 0
gameover = 1
// audio.beep("saw tempo 10000 volume 50 span 50 C2 to C4 to C2 to C4")
elsif not passed[i] then
passed[i] = 1
score += 1
// audio.beep("saw tempo 960 volume 50 span 20 C6")
end
end
end
else if touch.touching then running = 1 end end end
draw = function() screen.fillRect(0,0,screen.width,screen.height,"rgb(29,0,43)"
for i=-6 to 6 by 1 screen.drawSprite("wall",i*40-position%40,-80,40) end
screen.drawSprite("hero",-80,-50+hero_y,20) for i=0 to blades.length-1 screen.drawSprite("blade",blades[i]-position-80,-50,20) end
screen.drawText(score,120,80,20,"#FFF") if gameover then screen.fillRect(0,0,screen.width,screen.height,"rgba(255,0,0,.5)") screen.drawText("OWIE :(",0,0,50,"#FFF") elsif not running then screen.drawText("GO :3",0,30,50,"#FFF") end // screen.drawText(system.fps,-80,80,10,"#FFF") end
ok so for the end there wasnt one for the draw function I think you tried to add this but the end ended up In a comment so this should fix it if you have any issues after this fix please publish your project then link it
init = function()
gameover = 0
running = 0
blades = [200,300,400]
passed = [0,0,0]
score = 0
position = 0
speed = 2
end
update = function()
if gameover then
gameover += 1
if gameover>300 then
init()
end
elsif running then
position = position+speed
speed = speed + 0.001
if touch.touching and hero_y == 0 then
hero_vy = 7
// audio.beep("square tempo 20000 volume 10 span 100 C4 to C6")
end
hero_vy -= 0.3
hero_y = max(0,hero_y+hero_vy)
for i=0 to blades.length-1
if blades[i]<position-120 then
blades[i] = position+280+random.next()*200
passed[i] = 0
end
if abs(position-blades[i])<10 then
if hero_y<10 then
running = 0
gameover = 1
// audio.beep("saw tempo 10000 volume 50 span 50 C2 to C4 to C2 to C4")
elsif not passed[i] then
passed[i] = 1
score += 1
// audio.beep("saw tempo 960 volume 50 span 20 C6")
end
end
end
else
if touch.touching then
running = 1
end
end
end
draw = function()
screen.fillRect(0,0,screen.width,screen.height,"rgb(29,0,43)")
for i=-6 to 6 by 1
screen.drawSprite("wall",i*40-position%40,-80,40)
end
screen.drawSprite("hero",-80,-50+hero_y,20)
for i=0 to blades.length-1
screen.drawSprite("blade",blades[i]-position-80,-50,20)
end
screen.drawText(score,120,80,20,"#FFF")
if gameover then
screen.fillRect(0,0,screen.width,screen.height,"rgba(255,0,0,.5)")
screen.drawText("OWIE :(",0,0,50,"#FFF")
elsif not running then
screen.drawText("GO :3",0,30,50,"#FFF")
end // screen.drawText(system.fps,-80,80,10,"#FFF")
end
thanks :D