DarthRaff Posted December 31, 2012 Posted December 31, 2012 Hello everybody and very happy new year !! i usually program in c++ but i wanted to try lua for doors in the editor. I have a door sistem writed in c++ that works and i changed a little the code to addapt it to lua but not work. <So i decided to try something easier and wrote a simple program that creates a cube rotating to the right and when hit key e the rotation direction have to change but the direction changes from the beggining and does nothing when press e. So, please, what am i doing wrong ? here is the code and thanks in advance require("Scripts/constants/engine_const") RegisterAbstractPath("") Graphics(1024,768) fw=CreateFramework() cam=fw.main.camera cam:SetPosition(Vec3(0,0,-2)) light1 = CreateDirectionalLight() light1:SetRotation(Vec3(45,45,0)) mesh=CreateCube() mesh:SetPosition(Vec3(0,0,0)) vel=0.5 while KeyHit(KEY_ESCAPE)==0 do if KeyHit(KEY_E) then vel=-0.5 end mesh:Turn(Vec3(0,vel,0)) fw:Update() fw:Render() Flip(0) end Quote
ChrisMAN Posted December 31, 2012 Posted December 31, 2012 key hit is missing an == 1 if KeyHit(KEY_E) == 1 then Quote
ChrisMAN Posted December 31, 2012 Posted December 31, 2012 Unlike C 0 is a truthy value in lua. Only nil and false are falsy everything else is truthy. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.