function getCurrentAnimation(object)
Retrieve the current animation ID the given object uses.
Parameter
object
Return: The animation ID as a number.
function changeAnimation(object, animationId)
Plays an animation.
Changes the current animation to the given one. No animation blending is done.
Parameter
object
animationId
function isAnimationOver(object)
Checks if the current animation has finished playing.
Also returns true for looped animations if the animation finished this frame.
Parameter
object
Return: A boolean value.
function getAnimationSpeed(object)
Retrieves the speed of the current animation.
TODO: Get data about the speed unit!
Parameter
object
Return: The animation speed.
function setAnimationSpeed(object, speed)
Changes the speed of the current animation.
TODO: Get data about the speed unit!
Parameter
object
speed
function getCurrentFrame(object)
Retrieves the current frame in the current animation.
Parameter
object
Return: The current frame as a number.
function setCurrentFrame(object, frame)
Jumps to the given frame of the current animation.
Parameter
object
frame
function changeCurrentCamera(object)
Changes the current active camera.
This change will apply in the next frame and not immediately.
Parameter
object
function getCurrentCamera()
Retrieves the active camera.
Return: The active camera.
function getCameraClearColor(object)
Retrieves the clear color from the given camera.
Example:
color = getCameraClearColor(camera)
print("Color: R = " .. color[1] .. " G = " .. color[2] .. " B = " .. color[3])
Return: The color as a vec3.
function getCameraFov(object)
Retrieves the field of view from the given camera.
Parameter
object
function getCameraNear(object)
Retrieves the distance to the near plane from the given camera.
Parameter
object
function getCameraFar(object)
Retrieves the distance to the far plane from the given camera.
Parameter
object
function getCameraFogDistance(object)
Retrieves the distance to the fog from the given camera.
Parameter
object
function isCameraOrtho(object)
Checks if the given camera is configured to be orthographic.
Parameter
object
Return: A boolean.
function isCameraFogEnabled(object)
Checks if the given camera is configured to render fog.
Parameter
object
Return: A boolean.
function setCameraFov(object, fov)
Changes the field of view of the given camera.
Parameter
object
fov
function setCameraNear(object, near)
Changes the distance to the near plane of the given camera.
Parameter
object
near
function setCameraFar(object, far)
Changes the distance to the far plane of the given camera.
Parameter
object
far
function setCameraFogDistance(object, fogDistance)
Changes the distance to the fog rendered by the given camera.
Parameter
object
fogDistance
function enableCameraOrtho(object, ortho)
Updates the cameras matrix setup to allow orthographic rendering.
Parameter
object
ortho
function enableCameraFog(object, fog)
Enables fog rendering for the given camera.
Parameter
object
fog
function enableCameraLayer(object, scene)
Turns the image that the given scene renders into an overlay over the given camera.
For rendering the scene as an overlay the default camera in that scene is used.
camera = getObject("MainCamera")
guiScene = getScene("GuiScene")
enableCameraLayer(camera, guiScene)
Parameter
object
scene
Disables the scene overlay attached to the given camera.
Parameter
object
function enableRenderToTexture(object, texturePath, renderWidth, renderHeight)
Enables render to texture for the given camera.
This function allows you to setup any camera to render to a specific
material. For this you specify the texture path to the texture you want to replace.
Attention: This will _not_ modify the texture on disk!
All surfaces referencing this texture file will be replaced by the rendered image.
camera = getObject("MainCamera")
enableRenderToTexture(camera, "maps/white.png", 1024, 1024)
Parameter
object
texturePath
renderWidth
renderHeight
function disableRenderToTexture(object)
Disables render to texture for the given camera.
Parameter
object
function getProjectedPoint(object, point)
Converts global vector to a projected vector inside the given camera viewport.
Parameter
object
point
Return: A vec3 containing the transformed vector.
function getUnProjectedPoint(object, point)
Converts a projected vector to a global vector using the given camera.
This conversion uses the camera to determine the global coordinates for a
perspectively transformed point. This can be used to generate a ray for use in
raytracing as shown in the example.
camera = getObject("MainCamera")
-- Start the ray at the center of the screen
p1 = getUnProjectedPoint(camera, vec3(0.5, 0.5, 0))
p2 = getUnProjectedPoint(camera, vec3(0.5, 0.5, 1))
point, object = rayHit(p1, p2)
Parameter
object
point
Return: A vec3 containing the converted data.
function vec3(float x, float y, float z)
Creates a 3D vector.
Parameter
x
y
z
Return: The newly created 3D vector
function length(vec3)
Calculates the length of a 3D vector.
Parameter
vec3
Return: The length of the vector.
function normalize(vec3)
Normalizes a vector
This function takes the input vector and transforms it
to a new vector with the length 1.0f.
Parameter
vec3
Return: The normalized vec3.
function dot(vecA, vecB)
This function calculates the dot product of two vectors.
Parameter
vecA
vecB
Return: The one dimensional scalar product.
function cross(vecA, vecB)
This function calculates the cross product of two vectors.
Parameter
vecA
vecB
Return: The calculated vector.
function isKeyPressed(key)
Checks, if the given key is currently pressed.
See also: http://www.neo-engine.de/wordpress/?wpwtds_article=key-and-axis-literals
Parameter
The
Return: A boolean value.
function onKeyDown(key)
Checks, if the given key got pressed in this frame.
See also: http://www.neo-engine.de/wordpress/?wpwtds_article=key-and-axis-literals
Parameter
The
Return: A boolean value.
function onKeyUp(key)
Checks, if the given key got released in this frame.
See also: http://www.neo-engine.de/wordpress/?wpwtds_article=key-and-axis-literals
Parameter
The
Return: A boolean value.
function getAxis(axis)
Retrieves the current axis value of a joystick or mouse.
The value is between 0.0 and 1.0
See also: http://www.neo-engine.de/wordpress/?wpwtds_article=key-and-axis-literals
Parameter
The
Return: A float value.
function getTouchPosition(touchId)
Retrieves the current touch position on touch devices.
Is the same as the mouse cursor position since SDL makes no difference between them.
Parameter
The
Return: The touch position.
function loadLevel(filename)
Loads a specific level file.
Example:
loadLevel("levels/menu.level")
Parameter
filename
function getScene(name)
Retrieves the scene with the given name.
Parameter
name
Return: The scene.
function changeScene(scene)
Changes the current scene to the given scene.
See also: getScene
Parameter
scene
function getCurrentSceneId()
Retrieves the ID of the current scene.
Return: A number.
function getScenesNumber()
Returns the number of scenes in the current level.
Return: A number.
function getLightColor(object)
Returns the color of the given light source.
The color is encoded as a vec3.
Parameter
object
Return: The color.
function getLightRadius(object)
Returns the radius of the given light source.
Parameter
object
Return: A number.
function getLightIntensity(object)
Returns the intensity of the given light source.
Parameter
object
Return: A number.
function getLightShadowQuality(object)
Returns the shadow quality of the given light source.
Parameter
object
Return: A number.
function getLightShadowBias(object)
Returns the bias of the given light source.
Parameter
object
Return: A number.
function getLightShadowBlur(object)
Returns the blur factor of the given light source.
Parameter
object
Return: A number.
function getLightSpotAngle(object)
Returns the spot angle of the given light source.
Parameter
object
Return: A number.
function getLightSpotExponent(object)
Returns the spot exponent of the given light source.
Parameter
object
Return: A number.
function setLightColor(object, color)
Changes the color of the given light source.
setLightColor(light, {0.5,0.5,0.5})
Parameter
object
color
function setLightRadius(object, radius)
Changes the radius of the given light source.
Parameter
object
radius
function setLightIntensity(object, intensity)
Changes the intensity of the given light source.
Parameter
object
intensity
function setLightShadowQuality(object, quality)
Changes the shadow quality of the given light source.
The shadow quality is basically the resolution of the texture
the depth data will be rendered to. The resolution looks like "quality x quality"
and works best if quality is a power of two like 1024 or 2048.
Parameter
object
quality
function setLightShadowBias(object, bias)
Changes the shadow bias of the given light source.
Parameter
object
bias
function setLightShadowBlur(object, blur)
Changes the shadow blur of the given light source.
The shadow blur describes the number of passes the GLSL shader
uses to blur the shadow edge. Bigger values might slow down your game!
Parameter
object
blur
function setLightSpotAngle(object, spotAngle)
Changes the spot angle of the given light source.
The spot angle describes the angle a spot light is able to illuminate.
A point light has an angle > 180° and can be turned into a spot light
by setting a smaller spot angle.
Parameter
object
spotAngle
function setLightSpotExponent(object, exponent)
Changes the spot exponent of the given light source.
The spot exponent describes the strength of blending out the
illuminated area of the spot light on the edges.
Parameter
object
exponent
function getObject(scene, name)
Gets the object with the given name.
Can also give objects from other scenes than the current one.
Parameter
scene
name
function getParent(object)
Retrieves the parent of an object.
Parameter
The
Return: The parent object.
function getChilds(object)
Returns a list of all childrens from the given object.
Parameter
object
Return: The list of all children.
function getClone(object)
Creates a clone of the given object.
Parameter
object
Return: The clone.
function setParent(object, parent)
Changes the parent of the given object.
Resets parent-child relationship if parent = nil.
Parameter
object
parent
function getName(object)
Retrieves the name of the given object.
Parameter
object
Return: The name of the object.
function activate(object)
Activates the given object.
Parameter
object
function deactivate(object)
Deactivates the given object.
This function does not delete the object from memory!
It will just set invisible and removed from the physics simulation.
Parameter
object
function isVisible(object)
Checks if the given object is visible.
Parameter
object
Return: A boolean value.
function isActive(object)
Checks if the given object is active.
Parameter
object
Return: A boolean value.
function enableShadow(object, shadow)
Specifies, if a light renders shadows or if an entity has a shadow.
Parameter
object
shadow
function isCastingShadow(object)
Checks if a light renders shadows or if an entity has a shadow.
Parameter
object
Return: A boolean value.
function setGravity(vec3)
Sets the current gravity.
Example:
setGravity({0,0,-0.5})
Parameter
vec3
function getGravity()
Returns the gravity in the current scene.
Return: A vec3 containing the gravitational pull.
function getLinearDamping(object)
Returns the linear damping from the given object.
Parameter
object
Return: A number containing the linear damping.
function setLinearDamping(object, damping)
Sets the linear damping of the given object.
Parameter
object
damping
function getAngularDamping(object)
Returns the angular damping from the given object.
Parameter
object
Return: A number containing the angular damping.
function setAngularDamping(object, damping)
Sets the angular damping of the given object.
Parameter
object
damping
function getLinearFactor(object)
Returns the linear factor from the given object.
Parameter
object
Return: A vec3 containing the linear factor.
function setLinearFactor(object, factor)
Sets the linear factor of the given object.
Parameter
object
factor
function getAngularFactor(object)
Returns the angular factor from the given object.
Return: A number containing the linear factor.
function setAngularFactor(object, factor)
Sets the angular factor of the given object.
Parameter
object
factor
function getMass(object)
Returns the mass of the given object.
Parameter
object
Return: A number.
function setMass(object, mass)
Sets the mass of the given object.
Parameter
object
mass
function getFriction(object)
Returns the friction constant of the given object.
Parameter
object
Return: A number.
function setFriction(object, friction)
Sets the friction constant of the given object.
Parameter
object
friction
function getRestitution(object)
Returns the physical restitution of the given object.
Parameter
object
Return: A number.
function setRestitution(object, restitution)
Sets the restitution of the given object.
Parameter
object
restitution
function clearForces(object)
Removes all active forces from the given object.
Parameter
object
function addCentralForce(object, force, mode)
Applies a new central force to the given object.
The new force will be added to the currently existing central force of the
object. The mode parameter is optional and allows you to apply forces relative to the objects
current rotation.
Parameter
object
force
mode
function addTorque(object, torque, mode)
Applies a new torque to the given object.
The new torque will be added to the currently existing torque of the
object. The mode parameter is optional and allows you to apply a torque relative to the objects
current rotation.
Parameter
object
torque
mode
function getCentralForce(object)
Returns the force applied to the given object.
Parameter
object
Return: A vec3.
function getTorque(object)
Returns the torque applied to the given object.
Parameter
object
Return: A vec3.
function isCollisionTest(object)
Checks if the object is colliding at all.
Parameter
object
Return: A boolean.
function isCollisionBetween(object1, object2)
Checks if the two given objects are colliding.
Parameter
object1
object2
Return: A boolean.
function getNumCollisions(object)
Returns the total number of collisions the given object currently has.
Parameter
object
Return: A number.
function pauseSound(object)
Pauses the given sound.
Playback can be resumed by using playSound.
Parameter
object
function stopSound(object)
Stops the given sound.
Playback can be restarted by using playSound.
Parameter
object
function getSoundGain(object)
Retrieves the sound volume from the given sound object.
Parameter
object
Return: A number.
function setSoundGain(object, gain)
Sets the sound volume of the given sound object.
The volume level is should be between 0.0 and 1.0 to prevent distortion.
Parameter
object
gain
function centerCursor()
Sets the cursor to the center of the screen.
function hideCursor()
Hides the cursor.
function showCursor()
Shows the cursor.
function getWindowScale()
Retrieves the current window resolution.
Example:
resolution = getWindowScale()
print("The window has a resolution of " .. resolution[1] .. "x" .. resolution[2])
Return: The resolution as a vec2.
function getSystemTick()
Returns the number of milliseconds that passed since the application started.
Return: The current tick count.
function quit()
Quits the game.
The player will terminate, the editor will return to an editing environment.
function dofile(file)
Includes a file into script for execution.
Will look for scripts in "$PROJECT_DIR/scripts".
The example would load "$PROJECT_DIR/scripts/filename.lua".
Example:
dofile("filename.lua")
Parameter
file
function setText(object , text)
Changes the string displayed by a text object.
Example:
setText(textobject, "Sometext!")
Parameter
object
text
function getText(object)
Retrieves the string displayed by a text object.
Parameter
object
Return: The current string.
function getTextColor(object)
Retrieves the color displayed by a text object.
Example:
color = getTextColor(object)
print("Color: R = " .. color[1] .. " G = " .. color[2] .. " B = " .. color[3] .. " A = " .. color[4])
Parameter
object
Return: The current color as a vec4.
function setTextColor(object, color)
Sets the color displayed by a text object.
Example:
setTextColor(object, {r,g,b,a})
Parameter
object
color
function rotate(object, axis, angle, "local")
Rotates an object.
The local parameter is optional.
Example:
-- Rotate around X-Axis
rotate(object, {1,0,0}, 90)
Parameter
object
axis
angle
local
function translate(object, {x, y, z}, "local")
Translates an object.
The local parameter is optional.
Example:
-- Translate on X-Axis in the local space
rotate(object, {15,0,0}, "local")
Parameter
object
axis
local
function getPosition(object)
Retrieves the position of an object.
Parameter
object
Return: A vec3 containing the current position.
function getRotation(object)
Retrieves the rotation of an object.
Parameter
object
Return: A vec3 containing the current rotation.
function getScale(object)
Retrieves the scale of an object.
Parameter
object
Return: A vec3 containing the current scale.
function setPosition(object, pos)
Sets the position of an object.
Parameter
object
pos
function setRotation(object, rot)
Sets the rotation of an object.
Parameter
object
rot
function setScale(object, scale)
Sets the scale of an object.
Parameter
object
scale
function getTransformedPosition(object)
Retrieves the transformed position of an object.
This includes all transformations done by parents.
Parameter
object
Return: A vec3 containing the current position.
function getTransformedRotation(object)
Retrieves the transformed rotation of an object.
This includes all transformations done by parents.
Parameter
object
Return: A vec3 containing the current rotation.
function getTransformedScale(object)
Retrieves the transformed scale of an object.
This includes all transformations done by parents.
Parameter
object
Return: A vec3 containing the current scale.
function getInverseRotatedVector(object, vector)
Calculates the inverse rotated vector according to the matrix of the object.
Parameter
object
vector
Return: A vec3 with the transformed data.
function getRotatedVector(object, vector)
Rotates the given vector according to the matrix of the given object.
Parameter
object
vector
Return: A vec3 with the transformed data.
function getInverseVector(object, vector)
Calculates the inverse vector according to the matrix of the object.
This can be useful for converting global vectors into local vectors.
Parameter
object
vector
Return: A vec3 with the transformed data.
function getTransformedVector(object, vector)
Multiplies the given with the matrix of the given object.
This is useful for converting local to global coordinates.
Parameter
object
vector
Return: A vec3 with the transformed data.
function updateMatrix(object)
Recalculates the matrix of the given object.
Parameter
object
function getMatrix(object)
Retrieves the matrix of an object as a table.
Parameter
object
Return: A table containing the current matrix.
function objectExists(name)
Checks if the object with the given name exists.
Parameter
name
Return: A boolean.
function loadCameraSkybox(camera, path)
Loads a skybox from the given path.
The textures need to be in a directory and need to be named
in the fashion of "posx.jpg", "negx.jpg", "posy.jpg", "negy.jpg",
"posz.jpg", "negz.jpg"
Parameter
camera
path
function deleteObject(object)
Deletes the given object from the scene and
free's its memory.
Attention: Do not use objects after deleting them!
Parameter
object
function resizeWindow(width, height)
Resizes the game window.
Parameter
width
height
function getMeshFilename(object)
Retrieves the filename of the mesh from the given entity.
Parameter
An
Return: A string containing the path
function loadMesh(filename)
Loads a mesh from disk and adds it as an entity to the current
scene.
Parameter
filename
Return: The new object
function getObjectType(object)
Retrieves the object type of the given object
Valid return values are
"Entity", "Camera", "Light", "Sound", "Text", "Object"
Return: The type as a string
function getBoundingMax(object)
Returns the maximum point of the given entity as a vec3.
Parameter
object
Return: The point in space
function getBoundingMin(object)
Returns the minimum point of the given entity as a vec3.
Parameter
object
Return: The point in space
function createGroup()
Creates an empty group.
Groups have the type "Object" when using "getObjectType(object)"
Return: The empty group
function getBehaviorsNumber(object)
Returns the number of behaviors an object has attached.
If the operation fails it returns '-1'.
Parameter
object
Return: The number of behaviors
function getBehaviorName(object, idx)
Returns the name of a behavior that is attached to the given object.
Parameter
object
idx
Return: The name as a string.
function getBehaviorVariablesNumber(object, idx)
Returns the number of variables a behavior owns.
Parameter
object
idx
Return: The count as a number.
function getBehaviorVariableType(object, bid, vid)
Returns the variable type of a variable that belongs to a behavior
as a string.
Valid values are:
"bool", "vec2", "vec3", "vec4", "float", "int", "string", "uint"
Parameter
object
bid
vid
Return: The type as a string
function addBehavior(object, behaviorName)
Adds a new behavior to the given object.
Parameter
object
behaviorName
function enablePhysics(object, enabled)
Enables or disables all physics properties of an object.
Parameter
object
enabled
function setMass(object, mass)
Sets the physical mass of an object.
Parameter
object
mass
function getMass(object)
Returns the physical mass of an object.
Parameter
object
Return: The mass as a number.
function getFriction(object)
Returns the physical friction of an entity.
Parameter
object
Return: The friction as a number.
function setFriction(object, friction)
Sets the physical friction of an entity.
Parameter
object
friction
function getRestitution()
Returns the physical restitution of an object.
Parameter
object
Return: The restitution as a number.
function setRestitution(object, rest)
Sets the physical restitution of an entity.
Parameter
object
rest
function getAngularFactor(object)
Returns the physical angular factor of an object.
Parameter
object
Return: The angular factor as a number.
function setAngularFactor(object, value)
Sets the physical angular factor of an entity.
Parameter
object
value
function getLinearFactor()
Returns the physical linear factor of an object.
Parameter
object
Return: The linear factor as a number.
function setLinearFactor(object, value)
Sets the physical linear factor of an entity.
Parameter
object
value
function setPhysicsQuality(value)
Sets the physics quality. The default value is 2, higher values mean
higher precision.
Parameter
value
function setConstraintParent()
Changes the physical parent of an entity.
Parameter
object
parent
function getConstraintParent()
Returns the current physical parent or nil if there is none.
Parameter
object
Return: The parent as an object.
function enableParentCollision(object, enabled)
Enables or disables collision with the physical parent object.
Parameter
object
enabled
function isGhost(object)
Returns if the given entity is or is no ghost object.
Parameter
object
Return: A boolean
function enableGhost(object, enabled)
Enables/Disables the ghost property of an entity.
Parameter
object
enabled
function loadSound(filename)
Loads a sound from the given file and adds it to the current scene.
Parameter
filename
Return: The new sound object
function getSoundFilename(sound)
Returns the filename of the given sound object.
Parameter
The
Return: The filename as a string
function getSoundPitch(object)
Returns the sound pitch of a sound object.
Parameter
object
Return: The pitch as a number.
function setSoundPitch(object, value)
Changes the sound pitch.
Parameter
object
value
function getSoundRolloff(object)
Returns the sound rolloff value
Parameter
object
Return: The sound rolloff as a number
function setSoundRolloff(object, value)
Changes the sound rolloff of a sound
Parameter
object
value
function getSoundRadius(object)
Returns the sound radius of a sound object.
Parameter
object
Return: The radius as a number
function setSoundRadius(object, value)
Changes the sound radius of a sound object.
Parameter
object
value
function isSoundRelative(object)
Checks if the sound is relative
Parameter
object
Return: A boolean
function setSoundRelative(object, enabled)
Sets the sound relative according to the given value
Parameter
object
enabled
function isSoundLooping(object)
Checks if the sound is looping
Parameter
object
Return: A boolean
function setSoundLooping()
Sets the sound relative according to the given value
Parameter
object
enabled
function createLight()
Creates a new light object
Return: The new light object
function createCamera()
Creates a new camera object
Return: The new camera
function loadTextFont(filename)
Creates a new text object with the given font
Parameter
filename
Return: A new text object
function getFontFilename(object)
Returns the file name of the font used by the given text object.
Parameter
object
Return: the file as a string
function getTextFontSize(object)
Returns the font size of the given text
Parameter
object
Return: The font size as a number
function setTextFontSize(object, size)
Changes the font size of the given text
Parameter
object
size
function setTextAlignment(object, alignment)
Changes the text alignment
The alignment is given as a string.
Valid values are: "Center", "Left", "Right"
Parameter
object
align
function getTextAlignment(object)
Returns the text alignment
The alignment is given as a string.
Valid values are: "Center", "Left", "Right"
Parameter
object
Return: The alignment as a string
function getWorkingDirectory()
Returns the current working directory
Return: The working directory as a string
function loadTextFile(filename)
Loads a text file completely from disk. Also accesses files inside
the game NPK after the game is published.
Parameter
filename
Return: The content as a string
function isFileExist(filename)
Checks if a file exists
Parameter
filename
Return: A boolean
function createDirectory(path)
Creates a new directory.
Parameter
path