couch-rust/main.lua

25 lines
630 B
Lua

print("Hello from a lua script!")
local roll_x = 0.0
function couch.init()
print("Hello from \"init\"")
end
function couch.update(delta)
local transform = couch.root:find_node("cube"):get_transform()
transform.rotation[2] = transform.rotation[2] + delta * roll_x
transform.rotation[1] = transform.rotation[1] - delta * 0.3
couch.root:find_node("cube"):set_transform(transform)
end
function couch.keypressed(scancode)
if scancode == 30 then roll_x = 1.0 end
if scancode == 32 then roll_x = -1.0 end
end
function couch.keyreleased(scancode)
if scancode == 30 or scancode == 32 then roll_x = 0.0 end
end