towers.lua
towers_add(x, y, z, ?model_name)
towers_draw()
math.lua
dist(x, y, x2, y2) -> distance
collide2d(x, y, w, h, x2, y2, w2, h2) -> true/false
torad(degrees) -> radiant
a0.2
Main loop
function ELYOKO2D()
-- loop 2d
end
function ELYOKO3D()
-- loop 3d
end
delta time
local dt = deltatime() -- get time between 2 frame
color
local id_color = color(255,0,255,20) -- color r=255,g=0,b=255,a=20
local id_color = color(255,0,200) -- color r=255,g=0,b=200,a=255
camera 3d
-- get camera X
local camx = camerax()
-- get camera Y
local camy = cameray()
-- get camera Z
local camz = cameraz()
-- camera move
cameramove(x, y, z) -- add value to camera position
-- camera set position
camerasetpos(x, y, z) -- set value to camera position
-- camera rotate
camerarotate(rotx, roty, rotz) -- rotation in radiant
-- Camera set target
camerasettarget(x, y, z) -- set points than camera look
-- camera lock
cameralock(state)
-- state=true player can’t move/rotate camera
-- state=false player can move/rotate camera
Asset loading
! Outside loop / need protect for run once
-- load model
loadmodel(path) -- path is string
-- load texture
loadtexture(path) -- path is string
-- load plane textured
loadplanetexture(texture_name.ext) -- create model plane with loaded texture
Input
btn / btnp
if btn(0) then
-- key w is down or gamepad left stick up
elseif btnp(1) then
-- key s is pressed or gamepad left stick down
end
-- btn(id) : key is down
-- btnp(id) : key is pressed
-- id=0 → key w / gamepad left stick up
-- id=1 → key s / gamepad left stick down
-- id=2 → key a / gamepad left stick left
-- id=3 → key d / gamepad left stick right
-- id=4 → key x / gamepad button x
-- id=5 → key c / gamepad button a
mouse
local x,y,btnl,btnm,btnr = mouse()
-- x = x mouse
-- y = y mouse
-- btnl = true/false mouse left button
-- btnm = true/false mouse mid button
-- btnr = true/false mouse right button
2d
work only in ELYOKO2D
-- draw pixel
pix(x, y, color())
-- draw fill rectangle
rect(x, y, width, height, color())
-- draw line rectangle
rectb(x, y, width, height, color())
-- draw fill circle
circle(x, y, radius, color())
-- draw line circle
circleb(x, y, radius, color())
-- draw text
text(str, x, y, scale, color())
-- unload texture
deltexture(name.ext)
-- draw texture
drawtexture(name.ext, x, y)
3d
work only in ELYOKO3D()
-- draw cube
cube(x, y, z, width, height, depth, color())
-- draw sphere
sphere(x, y, z, radius, color())
-- unload model
delmodel(name.ext) -- name.ext is name without path
--draw model
drawmodel(name.ext, x, y, z, rot_x, rot_y, rot_z, scale)
-- rotation in radian
-- scale > 0 , float multiply scale of model