lua help

Posted by PL3X on Thu 27 Dec 2007 01:30 AM — 5 posts, 21,202 views.

#0
Hey, I quite new to lua and there are a few things that i cant get to work..

1.i have used the collsiion detection script as follows

function collisionCheck(object)
if (Player.x + playerWidth > object.x) and (Player.x < object.x + object.width) and (Player.y + playerHeight > object.y) and (Player.y < object.y + object.height) then
Player.x = oldx
Player.y = oldy
end
end

that works fine but when I try and use the same thing replacing Player with Enemy then Enemy just goes straight through it.

and also the following section doesnt work either:

if Player.y = Enemy.y and Player.x = Enemy.x then
screen:clear
screen:print(100,200,"you loose",red)
end

Please help
USA #1
Quote:
if Player.y = Enemy.y and Player.x = Enemy.x then
screen:clear
screen:print(100,200,"you loose",red)
end

The = is used for assignment of values not comparison. What you need is ==.
if Player.y == Enemy.y and Player.x == Enemy.x then
screen:clear
screen:print(100,200,"you loose",red)
end
#2
Thanks DArwin although now it says function arguments expected near 'screen' :( any ideas?
Australia Forum Administrator #3
To call a function you must supply an argument list even if it is empty. That is:


screen:clear ()
#4
ok thanks mate, sorry for the dum question im very new to lua and have only done a few tutorials all of your help is much appreciated :D