what is wrong with this code (or lua)?

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
jimjamjahaa
Posts: 17
Joined: Mon Oct 03, 2005 5:00 am

what is wrong with this code (or lua)?

Post by jimjamjahaa »

Code: Select all

   
        -- input handling
    if pad:l() then
        ship.aimdir = relative(ship.aimdir +2)
        end
    if pad:r() then
        ship.aimdir = relative(ship.aimdir -2)
        end
        
    ship.aimdir = math.abs(ship.aimdir)
    
    if ship.aimdir > 360 then
        ship.aimdir = ship.aimdir -360
        end
    if ship.aimdir <0 then
        ship.aimdir = ship.aimdir +360
        end



the ships aiming will go round anti clockwise (when ship.aimdir is being +ed) but if you go clockwise it gets stuck at the ship.aimdir = 0 mark.

i use this pice of code in loads of other languages and it works great.

whats going on??

edit: oops nver mind there is an unneccessary math.abs in there
chaos
Posts: 135
Joined: Sun Apr 10, 2005 5:05 pm

Post by chaos »

isn't it funny how you can always spot the answer 5 minutes after making a thread about it? :)
Chaosmachine Studios: High Quality Homebrew.
BePe86
Posts: 10
Joined: Sun Oct 02, 2005 3:36 am
Location: Norway

Post by BePe86 »

lol, it's an universal law :P
EU PSP 1.52 -> 2.0 -> 1.50
Untold Legends
32MB + 1GB Memory Sticks
Post Reply