Jump to content

Recommended Posts

Posted

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...