-
Notifications
You must be signed in to change notification settings - Fork 0
Lua functions
CLASS
FUNCTION
DESCRIPTION
Globals
System_run(string filename, SCENE MainScene)
Runs the selected script under the current lua_State. Used for loading in function definitions and lua apis.
SCENE
Scene:load(string filename)
Loads (filename) into current scene
Scene:save(string filename)
Saves current scene to (filename)
Scene:Objects()
Returns the amount of objects in the current scene
Scene:RenderEffect(number effectID)
Renders (effectID) effect from “Scripts/EffectsConfig/effect.xml”
Scene:deltaTime()
Returns the deltaTime
Scene:SLog(string info)
prints (info) to the log
Scene:SNLog(string info, number data)
prints "info : data" to log
Scene:SSLog(string info, string data)
prints "info : data" to log
Scene:setDebug(number level(0-3))
sets the level of debug to (level)
Scene:setPhysicsDebug(number on(0 or 1))
Toggles physics debug
Scene:addMesh(string filename, number x, number y, number z, number rotx, number roty, number rotz, number scalex, number scaley, number scalez)
Adds mesh (filename) to the scene at the set pos, rot, and scale. Returns mesh ID.
Scene:getMesh(number id)
returns Mesh at (id)
Scene:addAnimatedMesh({SAME ARGUMENTS AS Scene:addMesh})
Adds animated mesh (filename) to the scene set pos, rot, scale. Returns AnimatedMesh ID.
Scene:getAnimatedMesh(number id)
returns AnimatedMesh at (id)
Scene:addParticle(number x, number y, number z, number xdir, number ydir, number zdir, number xscale, number yscale, number zscale, string filename)
Adds a particle system at (x, y, z) facing (xdir, ydir, zdir), with scale (xscale, yscale, zscale), using (filename) as the particle sprite. Returns ParticleSystem ID.
Scene:addEmpty(number x, number y, number z, number xrot, number yrot, number zrot, number xscale, number yscale, number zscale)
Adds an empty object at set location, rotation, and scale. Returns emptyobject id.
Scene:getEmpty(number id)
returns EmptyObject at (id)
Scene:addCamera(number type(0-2))
Adds a camera to the scene. TYPES: 1 = FPS camera, 2 = FREE camera, 3 = MAYA STYLE Focus camera
Scene:getCamera()
Returns the active camera
Scene:addSound(string filename, number x, number y, number z, number loop(1 or 0))
adds and plays sound (filename)
Scene:getSound(number id)
returns sound (id)
Scene:getKey(number EKEY_CODE)
Returns whether the key is depressed or not. For a list of key codes, look at the Irrlicht 1.8 documentation.
Scene:createCharacter(number height, number width, number stairheight)
Creates a character physics controller of (height, width) and can climb stairs of height (stairheight)
Scene:modifyCharacter(string function, ...data...)
Modifies character data. Check table below for character funcitons.
Scene:getCharacterData(string function)
returns character data at (function). Check table below for character datapoints
Scene:moveCharacter(number x, number y, number z, number camdirx, number camdiry, number camdirz, number speed)
Moves player in respect to the camera with multiplier (speed).
Scene:setSkydome(string filename)
Sets the skydome image.
Scene:removeObject(number id)
removes object (id)
Scene:setTimeScale(number timescale (defaults to 0.004))
sets the physics timescale. Useful for faster or slower physics.
Scene:getTimeScale()
returns the current physics timescale.
Scene:getMouseButton()
Returns the clicked mouse button
Scene:getMousePosition()
Returns X, Y mouse position
Scene:addWindow(string title, x1, y1, x2, y2, GUI parent, string scriptFilename)
Adds a window with (title) at (x1, y1) (x2, y2). Runs “onClose()” function in (scriptFilename) when the window is closed.
Scene:addSlider(number horizontal (0-1), number x1, number y1, number x2, number y2, number parentID, string scriptFilename)
Adds a slider at (x1, y1, x2, y2). Runs “onScroll(number pos)” function within (scriptFilename). Returns the ID of the gui object.
Scene:addButton(string title, string mouseover, number x1, number y1, number x2, number y2, number parentID, string scriptFilename)
Adds a button with text (title) and mouseover text of (mouseover) at (x1, y1, x2, y2). Runs the "onClick()" function in the script at (scriptFilename). Returns the ID of the gui object.
Scene:addEditBox(string defaultText, number x1, number y1, number x2, number y2, number border (0-1), number parentID, string scriptFilename)
Adds a text edit box at (x1, y1, x2, y2) with (defaultText) as it's starting value and a border if (border) is '1'. (scriptFilename) must contain the functions: “onEnter(string text)” which runs when text is submitted, “onChange()” which runs when the text is changed, and “onMarkChange()” when the highlighted region is changed. Returns the ID of the GUI object.
Scene:addText(string text, number x1, number y1, number x2, number y2, number parentID)
Adds (text) at (x1, y1, x2, y2). Returns the ID of the GUI object.
Scene:addListBox(number x1, number y1, number x2, number y2, number parentID, string scriptFilename)
Adds a list box at (x1, y1, x2, y2). Runs “onSelect(number selection)” in (scriptFilename) on selection.
Scene:addListItem(string itemName, number parentList)
Adds a list item named (itemName) to (parentList). Returns item ID within list.
Scene:removeListItem(number listBox, number itemID)
Removes (itemID) from (listBox).
Scene:addImage(number x1, number y1, number x2, number y2, string filename, number parentID)
Adds (filename) image to the GUI at (x1, y1, x2, y2). Returns the ID of the GUI object.
Scene:clearGUI()
Removes all GUI objects on screen.
Scene:setGUIColor(number r, number g, number b, number a)
Sets the color of the GUI to (r, g, b, a).
Scene:getGUIColor()
Returns (r, g, b, a).
Scene:setGUIFont(string filename)
Sets font to (filename). Accepts bitmap fonts.
Scene:getGUIObject(number guiID)
Returns the GUI object at (guiID)
Scene:setMetaData(string key, string data)
Sets (key) to (data).
Scene:getMetaData(string key)
Returns the data at (key)
Scene:getMouseControl()
Disables mouse.
Scene:giveMouseControl()
Enables mouse control (useful for GUI functions).
Scene:setGravity(number x, number y, number z)
Sets the gravity vector to (x, y, z).
OBJECT
Object:getCollider()
Returns the COLLIDER of the object.
Object:getPosition()
Returns (x, y, z) position.
Object:getRotation()
Returns (x, y, z) rotation.
Object:getScale()
Returns (x, y, z) scale.
Object:setPosition(number x, number y, number z)
Sets position of Object.
Object:setRotation(number x, number y, number z)
Sets rotation of Object.
Object:setScale(number x, number y, number z)
Sets scale of Object.
Object:getName()
Returns name of object.
Object:setName(string name)
Sets the name of Object.
Object:getID()
Returns the ID of Object,.
Object:addScript(SCENE MainScene, string filename)
Attaches a script to an object. The script MUST contain a function "init" a funciton "update" and a function "render". If it lacks any of these, the program will fail to run.
Object:setMaterial(string materialType(see Material Types table))
Sets the material type of Object.
Object:setMaterialFlag(string flag(see Material Flags table), ...values...)
Sets the values of (flag).
Object:setMaterialTexture(SCENE MainScene, number texture, string filename)
Sets (texture) to (filename).
Object:attachTo(OBJECT o)
Attaches Object to (o).
MESH
Mesh:addCollider(SCENE MainScene, string type (see types chart), number mass)
Creates a collider on Mesh of (type) and (mass).
Mesh:toObject()
Returns the OBJECT type of Mesh.
ANIMATED MESH
INHERITS ALL FUNCTIONS FROM MESH
AnimatedMesh:setFrameLoop(number first, number last)
Sets the animation frame range of the current animation.
AnimatedMesh:setSpeed(number fps)
Sets the speed of the animation in Frames per Second.
PARTICLE
Particle:setAge(number minAge, number maxAge)
Sets the minimum and maximum age of particles.
Particle:setColors(number r1, number g1, number b1, number a1, number r2, number g2, number b2, number a2)
Sets the color tint of the particles as they progress through their age.
Particle:setDirection(number x, number y, number z)
Sets the direciton in which the particles are emitted.
Particle:setRate(number minRate, number maxRate)
Sets the minimum and maximum rate of particle emissions.
Particle:setSize(number minSize, number maxSize)
Sets the minimum and maximum size of particles.
Particle:addAffector(string affector (see affectors table))
Adds an affector to the current particle system.
Particle:addCollider(SCENE MainScene, string type (see OBJECT collider types table), number mass)
Adds a collider to the particle system
Particle:toObject()
Returns OBJECT type of Particle.
SOUND
Sound:load(string filename, number x, number y, number z, number loop(0-1))
Loads sound (filename) and plays it at (x, y, z). If loop = 1, it will loop the track.
Sound:stop()
Stops Sound.
Sound:isPlaying()
Returns 1 if Sound is playing. Returns 0 otherwise.
Sound:setVolume(number volume)
Sets the volume of Sound.
Sound:setPosition(number x, number y, number z)
Sets the position of the sound.
Sound:setDropoff(number minDistance, number maxDistance)
Sets the dropoff of the sound.
Sound:enableChorus(number wetDryMix, number depth, number feedback, number frequency)
Enables chorus effect on Sound
Sound:disableChorus()
Disables the chorus effect on Sound.
Sound:enableCompressor(number gain, number attack, number release)
Enables a compressor effect on Sound
Sound:disableCompressor()
Disables compressor effect on Sound.
Sound:enableDistortion(number gain, number edge, number PostEQCenterFreq, number PostEQBandwidth, number preLowPassCutoff)
Enables Distortion effect on Sound.
Sound:disableDistortion()
Disables distortion effect.
Sound:enableEcho(number wetDryMix, number feedback, number leftDelay, number rightDelay, number PanDelay)
Enables Echo effect on Sound.
Sound:disableEcho()
Disables Echo Effect on Sound
Sound:enableReverb(number gain, number reverbMix, number reverbTime, number highFreqRTRatio)
Enables Reverb effect on Sound.
Sound:disableReverb()
Disables Reverb effect on Sound.
EMPTY OBJECT
EmptyObject:addCollider(SCENE MainScene, string type(see Object Collider Types table), number mass)
Adds a collider to the EmptyObject of (type) and (mass)
EmptyObject:toObject()
Returns OBJECT type of EmptyObject.
CAMERA
Camera:setFOV(number fov)
Sets the Field of View of the camera.
Camera:getFOV()
Returns the Field of View of the camera
Camera:setClipping(number nearClipping, number farClipping)
Sets the near and far clipping distances.
Camera:getClipping()
Returns (nearClipping, farClipping).
Camera:setTarget(OBJECT target)
Sets camera target to (target)
Camera:setAspect(number ratio)
Sets the camera aspect ratio.
Camera:setOffset(number x, number y, number z)
Adds an offset value to the camera's position. Useful for FPS camera.
Camera:setPosition(number x, number y, number z)
Sets the camera position.
Camera:getPosition()
Returns (x, y, z) camera position.
Camera:setRotation(number x, number y, number z)
Sets the rotation of the camera to (x, y, z).
Camera:attachTo(OBJECT o)
Attaches the camera to (o).
Camera:setUpVector(number x, number y, number z)
Sets the upward vector of the camera to (x, y, z). Is (0, 1, 0) by default.
LIGHT
Light:setColor(number r, number g, number b, number a)
Sets the light color to (r, g, b, a).
Light:getColor()
Returns (r, g, b, a) of the light color.
Light:setDropoff(number dropoff)
Sets the dropoff of the light to (dropoff).
Light:setType(number type (0-2)
Sets the type of the light to (type). 0=Point light, 1=Spot Light, and 2=Directional.
TERRAIN
Terrain:empty(number sizeX, number sizeY)
Initializes a flat terrain of size (sizeX, sizeY).
Terrain:load(string filename)
Loads a terrain from a monochrome image (filename).
Terrain:getHeight(number x, number y)
Returns the height of the terrain at (x, y).
Terrain:setHeight(number x, number y, number height)
Sets the height at (x, y) to (height).
Terrain:getSizeX()
Returns the X width of the terrain.
Terrain:getSizeY()
Returns the Y width of the terrain.
Terrain:addCollider(SCENE MainScene, string type (see types chart), number mass)
Creates a collider on Terrain of (type) and (mass).
COLLIDER
Collider:setVelocity(number x, number y, number z)
Sets velocity of Collider.
Collider:setAVelocity(number x, number y, number z)
Sets angular velocity of Collider.
Collider:setFriction(number friciton)
Sets the friction of Collider
Collider:setDamping(lDamping, aDamping)
Sets the linear and angular damping of Collider.
Collider:setMass(number mass)
Sets the mass of Collider.
Collider:setLocal(number local (0-1))
Sets the coordinates to local if (local) = 1. Relative if (local) = 0.
Collider:addCentralForce(number x, number y, number z)
Applies a force of (x, y, z) to the center of mass.
Collider:addForce(number forceX, number forceY, number forceZ, number x, number y, number z)
Applies a force of (forceX, forceY, forceZ) to (x, y, z) position on Collider.
Collider:addTorque(number x, number y, number z)
Adds torque of (x, y, z) to the collider.
Collider:setState(string state)
Sets the state of the collider. Possible states are: “ACTIVE”, “NO_DEACTIVATION”, or “SLEEPING”.
GUI
GUI:setText(string text)
Changes the text of the element to (text).
GUI:setTitle(string text)
Changes the title of the element to (text).
GUI:removeElement()
Removes current element.
|
FUNCTION | VALUES |
---|---|
jumpforce | (number force) |
jumpheight | (number height) |
maxslope | (number slopeangle) |
jump | (none) |
warp | (number x, number y, number z) |
Variables | Returns |
---|---|
jump | Returns 1 if player can jump |
onGround | Returns 1 if player is on the ground |
maxslope | Returns max slope angle |
posX | Returns X position of character |
posY | Returns Y position of character |
posZ | Returns Z position of character |
Collider Types | Description |
---|---|
CUBE | a basic bounding box collider |
SPHERE | a basic Sphere collider |
MESH_CONVEXHULL | Used for small solid meshs |
MESH_TRIMESH | Used for large level meshes |
MESH_GIMPACT | A more responsive version of MESH_TRIMESH |
Collider Types | Description |
---|---|
CUBE | A basic bounding box collider |
SPHERE | A basic sphere collider |
CAPSULE (EMPTYOBJECT ONLY) | A basic capsule collider. |
Material Types | Description/Requirements |
---|---|
solid | A basic solid rendering |
solid2 | A basic 2 layer solid rendering. Use setMaterialTexture() to set the second layer. |
lightmap | A lightmap rendering. Texture 1 is the main texture, Texture 2 is the lightmap |
lightmaplight | Same as lightmap, but accepts dynamic lighting |
normalmap_solid | A normalmapped solid. Texture 1 is the texture, Texture 2 is the normal map. |
parallax_solid | Same as Normal mapped, but using a parallax method |
sphere_map | Creates a reflective surface. Texture 1 is the spheremap texture. |
detail_map | Creates a detailmapped surface. Useful for terrain rendering. Texture 1 is the main texture, Texture 2 is the detailmap texture |
spheremap2 | Creates a textured spheremap. Texture 1 is the main texture, Texture 2 is the spheremap texture. |
transparent_alpha | IN PROGRESS |
transparent_alpha_fast | IN PROGRESS |
transparent_add | IN PROGRESS |
Material Flags | Values |
---|---|
wireframe | 0 or 1 |
pointcloud | 0 or 1 |
gouraud_shading | 0 or 1 |
lighting | 0 or 1 |
zbuffer | 0 or 1 |
zwrite | 0 or 1 |
backface_culling | 0 or 1 |
frontface_culling | 0 or 1 |
bilinear | 0 or 1 |
trilinear | 0 or 1 |
ansiotropic | 0 or 1 |
fog | 0 or 1 |
normalize_normals | 0 or 1 |
antialias | 0 or 1 |