![]() |
Skyline Lua API
Version 1.0
Lua Script Reference for Skyline Game Engine.
|
#include <LUA_API_Draw.h>
Public Member Functions | |
| void | autoClear (int state) |
| Enables the update loop drawing clear routine. This is active by default. More... | |
| void | line (newType.vec3 lineStartV3, newType.vec3 lineEndV3, newType.color lineColour) |
| Draws a simple colored line between 2 vec3 vars. More... | |
| void | clear () |
| Forces the drawing to be cleared. More... | |
| void | circle (vec3 position, float radius, float segment, color col) |
| Draws a circle. More... | |
| void | circleFilled (vec3 position, float radius, float segment, color col) |
| Draws a filled circle. More... | |
| void | cylinder (vec3 position, float radius, float segment, float height, color col) |
| Draws a cylinder. More... | |
| void | cylinderFilled (vec3 position, float radius, float segment, float height, color col) |
| Draws a filled cylinder. More... | |
| void | tetra (vec3 position, float scale, color col) |
| Draws a tetra. More... | |
| void | tetraFilled (vec3 position, float scale, color col) |
| Draws a filled tetra. More... | |
| void | sphere (vec3 position, float radius, float smooth, color col) |
| Draws a sphere. More... | |
| void | sphereFilled (vec3 position, float radius, float smooth, color col) |
| Draws a filled sphere. More... | |
| void | cube (vec3 position, float scale, color col) |
| Draws a cube. More... | |
| void | cubeFilled (vec3 position, float scale, color col) |
| Draws a filled cube. More... | |
Debug drawing related functions can be found in this class. There are many times where you require some type of visual
feedback when coding.This library provides a handy set of commands to provide you with visual feedback.
Use as game.function()
posS = newType.vec3();
posE = newType.vec3();
col = newType.color(1,0,0,0.5);
obj = 0;
x,y,z = 0;
rx = 0;
radius = 5;
function onInit(objID)
sky.lprint("LUA: Demo - Debug Drawing script Active!");
obj = objID;
draw.autoClear(0); -- Stop the built in clearing on update so we can manage it ourselves
x,y,z = entity.getPosition(obj);
drawStack();
end
function onKeyDown( key )
posS = newType.vec3(entity.getPosition(obj));
posE = newType.vec3(posS.x,posS.y+20,posS.z);
col = newType.color(1,0,0,0.5);
radius = 10;
segment = 50;
height = 10;
scale = 7;
draw.clear();
if (key == "1") then draw.circle(posS,radius,segment,col); end
if (key == "2") then draw.circleFilled(posS,radius,segment,col); end
if (key == "3") then draw.cylinder(posS,radius,segment,height,col); end
if (key == "4") then draw.cylinderFilled(posS,radius,segment,height,col); end
if (key == "5") then draw.tetra(posS,scale,col); end
if (key == "6") then draw.tetraFilled(posS,scale,col); end
if (key == "7") then draw.sphere(posS,radius,1,col); end
if (key == "8") then draw.sphereFilled(posS,radius,1,col); end
if (key == "9") then draw.cube(posS,scale,col); end
if (key == "0") then draw.cubeFilled(posS,scale,col); end
if (key == "b") then drawStack() end
end
function drawStack()
for i=0,5 do
for j=0,5 do
for k=0,5 do
posS.x = x - i * 10
posS.y = y - j * 10
posS.z = k * 10 + z
col.r = 51 * i / 255
col.g = 51 * j / 255
col.b = 51 * k / 255
col.a = 0.3;
draw.cubeFilled(posS,3,col);
col.a = 0.7;
draw.cube(posS,3,col);
end
end
end
end
Note: To create a transparent drawing such as a box for bounds you can pass a low value to the color.a variable
For more information on how these functions can be used please visit the User Manual - https://home.aurasoft-skyline.co.uk
| void draw::autoClear | ( | int | state | ) |
Enables the update loop drawing clear routine. This is active by default.
| int | the arg int state can be either 1 or 0 |
There may be times when you require the drawn objects to be persistant between frames. Disable this option and
manually call draw.clear before doing any drawing.
The following is a Small Example on how to use this function:
function onInit(objID)
obj = objID;
draw.autoClear(0); -- Stop the built in clearing on update so we can manage it ourselves
pos = newType.vec3(entity.getPosition(obj));
end
| void draw::circle | ( | vec3 | position, |
| float | radius, | ||
| float | segment, | ||
| color | col | ||
| ) |
Draws a circle.
| vec3 | vector position |
| float | radius of circle |
| float | the segments or smoothness of curve |
| color | a color vector for rgba value |
The following is a Small Example on how to use this function:
function onKeyDown( key )
posS = newType.vec3(entity.getPosition(obj));
col = newType.color(1,0,0,0.5);
radius = 10;
segment = 50;
draw.clear();
if (key == "1") then draw.circle(posS,radius,segment,col); end
end
| void draw::circleFilled | ( | vec3 | position, |
| float | radius, | ||
| float | segment, | ||
| color | col | ||
| ) |
Draws a filled circle.
| vec3 | vector position |
| float | radius of circle |
| float | the segments or smoothness of curve |
| color | a color vector for rgba value |
The following is a Small Example on how to use this function:
function onKeyDown( key )
posS = newType.vec3(entity.getPosition(obj));
col = newType.color(1,0,0,0.5);
radius = 10;
segment = 50;
draw.clear();
if (key == "1") then draw.circleFilled(posS,radius,segment,col); end
end
| void draw::clear | ( | ) |
Forces the drawing to be cleared.
Clears any drawing and must be called before calling any draw commands.
The following is a Small Example on how to use this function:
function onKeyDown( key )
posS = newType.vec3(entity.getPosition(obj));
col = newType.color(1,0,0,0.5);
radius = 10;
segment = 50;
draw.clear();
if (key == "1") then draw.circle(posS,radius,segment,col); end
end
| void draw::cube | ( | vec3 | position, |
| float | scale, | ||
| color | col | ||
| ) |
Draws a cube.
| vec3 | vector position |
| float | scale of cylinder |
| color | a color vector for rgba value |
The following is a Small Example on how to use this function:
function onKeyDown( key )
posS = newType.vec3(entity.getPosition(obj));
col = newType.color(1,0,0,0.5);
scale = 7;
draw.clear();
if (key == "1") then draw.cube(posS,scale,col); end
end
| void draw::cubeFilled | ( | vec3 | position, |
| float | scale, | ||
| color | col | ||
| ) |
Draws a filled cube.
| vec3 | vector position |
| float | scale of cylinder |
| color | a color vector for rgba value |
The following is a Small Example on how to use this function:
function onKeyDown( key )
posS = newType.vec3(entity.getPosition(obj));
col = newType.color(1,0,0,0.5);
scale = 7;
draw.clear();
if (key == "1") then draw.cubeFilled(posS,scale,col); end
end
| void draw::cylinder | ( | vec3 | position, |
| float | radius, | ||
| float | segment, | ||
| float | height, | ||
| color | col | ||
| ) |
Draws a cylinder.
| vec3 | vector position |
| float | radius of cylinder |
| float | the segments or smoothness of curve |
| float | the height of the cylinder |
| color | a color vector for rgba value |
The following is a Small Example on how to use this function:
function onKeyDown( key )
posS = newType.vec3(entity.getPosition(obj));
col = newType.color(1,0,0,0.5);
radius = 10;
segment = 50;
draw.clear();
if (key == "1") then draw.cylinder(posS,radius,segment,height,col); end
end
| void draw::cylinderFilled | ( | vec3 | position, |
| float | radius, | ||
| float | segment, | ||
| float | height, | ||
| color | col | ||
| ) |
Draws a filled cylinder.
| vec3 | vector position |
| float | radius of cylinder |
| float | the segments or smoothness of curve |
| float | the height of the cylinder |
| color | a color vector for rgba value |
The following is a Small Example on how to use this function:
function onKeyDown( key )
posS = newType.vec3(entity.getPosition(obj));
col = newType.color(1,0,0,0.5);
radius = 10;
segment = 50;
draw.clear();
if (key == "1") then draw.cylinderFilled(posS,radius,segment,height,col); end
end
| void draw::line | ( | newType.vec3 | lineStartV3, |
| newType.vec3 | lineEndV3, | ||
| newType.color | lineColour | ||
| ) |
Draws a simple colored line between 2 vec3 vars.
| newType.vec3 | lineStartV3: the vec3 of the line start position |
| newType.vec3 | lineEndV3: the vec3 of the line end position |
| newType.color | lineColour: the color to use to draw the line |
The following is a Small Example on how to use this function:
function onInit(objID)
obj = objID;
draw.line(lineStartV3, lineEndV3, lineColour);
pos = newType.vec3(entity.getPosition(obj));
end
| void draw::sphere | ( | vec3 | position, |
| float | radius, | ||
| float | smooth, | ||
| color | col | ||
| ) |
Draws a sphere.
| vec3 | vector position |
| float | radius of cylinder |
| float | the smooth value or smoothness of curve |
| color | a color vector for rgba value |
The following is a Small Example on how to use this function:
function onKeyDown( key )
posS = newType.vec3(entity.getPosition(obj));
col = newType.color(1,0,0,0.5);
radius = 10;
smooth = 1;
draw.clear();
if (key == "1") then draw.sphere(posS,radius,smooth,col); end
end
| void draw::sphereFilled | ( | vec3 | position, |
| float | radius, | ||
| float | smooth, | ||
| color | col | ||
| ) |
Draws a filled sphere.
| vec3 | vector position |
| float | radius of cylinder |
| float | the smooth value or smoothness of curve |
| color | a color vector for rgba value |
The following is a Small Example on how to use this function:
function onKeyDown( key )
posS = newType.vec3(entity.getPosition(obj));
col = newType.color(1,0,0,0.5);
radius = 10;
smooth = 1;
draw.clear();
if (key == "1") then draw.sphereFilled(posS,radius,smooth,col); end
end
| void draw::tetra | ( | vec3 | position, |
| float | scale, | ||
| color | col | ||
| ) |
Draws a tetra.
| vec3 | vector position |
| float | scale of tetra |
| color | a color vector for rgba value |
The following is a Small Example on how to use this function:
function onKeyDown( key )
posS = newType.vec3(entity.getPosition(obj));
col = newType.color(1,0,0,0.5);
radius = 10;
segment = 50;
draw.clear();
if (key == "1") then draw.tetra(posS,scale,col); end
end
| void draw::tetraFilled | ( | vec3 | position, |
| float | scale, | ||
| color | col | ||
| ) |
Draws a filled tetra.
| vec3 | vector position |
| float | scale of tetra |
| color | a color vector for rgba value |
The following is a Small Example on how to use this function:
function onKeyDown( key )
posS = newType.vec3(entity.getPosition(obj));
col = newType.color(1,0,0,0.5);
radius = 10;
segment = 50;
draw.clear();
if (key == "1") then draw.tetraFilled(posS,scale,col); end
end