lördag 6 september 2008

Script Support

Hi there,
I'm slow on the update side but a bit faster working...
The last week I have implemented script support via LuaBind so now you can control objects and components via lua-scripts. The engine is still not fully binded and probably won't be, i.e. it will have script support for different parts so you don't have to register luabind functions for everything if you don't want to.

this is the first test script I wrote (for an 3d-aim controlled by the mouse). It works well btw :)

function handleMouseEvent(this, mouseState)
obj = this:getOwner()
cpos = obj:getCPosition()
pos = cpos:getPosition()
relX = mouseState.X.rel
relY = mouseState.Y.rel
x = -relX/50
y = -relY/40
xPos = pos.x
yPos = pos.z

if ((xPos + x) > 7.5) then
x = 7.5 - xPos
end
if ((xPos + x) < -7.5) then
x = -7.5 - xPos
end
if ((yPos + y) > 7.5) then
y = 7.5 - yPos
end
if ((yPos + y) < 0.5) then
y = 0.5 - yPos
end

cpos:translate(x, 0, y)
return
end

Inga kommentarer: