# Lua Code

The instructions that we wrote in chapter 1 is called Lua

Lua is a lightweight, high-level, multi-paradigm programming language designed primarily for embedded use in applications. ——Wiki)

Version : Lua5.3

Note: Beginning PixelsWorld v3.2.0, using Lua5.4

So Lua plays the role that manages the communication between Ae and Users. It is quite similar to Ae script and expression language. Basically, you can draw highly variant scenes by remembering just a few words. For instance, if you want to draw a cube that can interact with Ae camera, just type:

DrawCube.lua

version3()
move(width/2,height/2)
dim3()
cube(300)


dim3() means draw shapes in 3 dimension.

If you want to run GLSL code, just type:

RunGlsl.lua

version3()
glsl([==[
void main(){
vec3 col = 0.5 + 0.5*cos(time+uv.xyx+vec3(0,2,4));
outColor = vec4(col,1.0);
}
]==])


If you want to run code from shadertoy, just type:

version3()
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord/iResolution.xy;
vec3 col = 0.5 + 0.5*cos(iTime+uv.xyx+vec3(0,2,4));
fragColor = vec4(col,1.0);
}
]==])


In Lua, you can :

• Get pixels data
• Write pixels data
• Run JavaScript
• Run GLSL
• Get parameters data
• Run outer C library (COOL!)