The Basics

Index
functions
Variables
Variable functions
Loops

Introduction

This is the documentation for the PLEN Scripting Library, it is based of JavaScript, therefore requiring a basic knowledge of JavaScript.
Vector3f - An array consisting of 3 floats.
Vector2f - An array consisting of 2 floats.

Functions

Print

The print function is quite self explanitory, it simply prints the values it is given.
print("Hello World");
The code above would have the result of "Hello World" in the console. In every programming language variables can be concatenated in print statements. Like Java, to concatenate a variable into a print statement the following code can be written.
var myVariable = 5;
print("My variable's value :: "+myVariable);
The code above would have the result of "My variable's value :: 5" in the console.


Create Cube

This function simply creates a Cube object and stores the UUID of the cube object inside of the variable.
var myCube = createCube(c1, c2, c3, c4, pos, rot, scale, mat);
c1 - Color 1 (Vector3f)
c2 - Color 2 (Vector3f)
c3 - Color 3 (Vector3f)
c4 - Color 4 (Vector3f)


pos - Position (Vector3f)
rot - Rotation (Vector3f)
scale - Scale (Vector3f)


mat - Material (String (file path of image)) (if material is included, then function name is createTexturedCube)


Create Pyramid

As the create cube function, this function simply creates a pyramid object and stores it's UUID inside of the variable.
var myPyramid = createPyramid(c1, c2, c3, pos, rot, scale, mat);
c1 - Color 1 (Vector3f)
c2 - Color 2 (Vector3f)
c3 - Color 3 (Vector3f)
c4 - Color 4 (Vector3f)


pos - Position (Vector3f)
rot - Rotation (Vector3f)
scale - Scale (Vector3f)


mat - Material (String (file path of image)) (if material is included, then function name is createTexturedPyramid)


Load Object

This function loads an object from the given path, and sets it's position, rotation, and scale var loadedObject = loadObject(pto, ptt, ht, pos, rot, scale);
pto - Path to Object (String)
ptt - Path to Texture (String)
ht - Has texture (Boolean)
pos - Position (Vector3f)
rot - Rotation (Vector3f)
scale - Scale (Vector3f)


Push to Render stack

This function pushes the given variable to the user render stack. When the scripts are reloaded the user render stack is also reloaded overriding all the objects prior to the reload.
pushToRenderStack(myCube);
The code above pushes object "myCube" to the render stack, therfore rendering a cube. This function only OBJ variables, new OBJs cannot be created within the function or else it will give an error


Pop from Render Stack

This function pops the object with the given UUID from the user render stack, therfore, it is no longer going to be rendered.
popFromRenderStack(myCube);

Pop Render Stack

This function pops the entire user render stack, removing all objects inside of it.
popRenderStack();

Set Global Light Position

This function sets the global light's position, which could be refered to as the sun's position, to the given 3D vector
setGlobalLightPosition([0,100,0]);
The above code sets the position of the "sun" to X :: 0 Y :: 100 Z :: 0


Set Global Light Color

This function sets the global light's color, to the given 3D vector
setGlobalLightColor([0,0,1f]);
The above code sets the global light's color to R :: 0 G :: 0 B :: 1

Note: The brightness of the color, and the intensity of the light, depends on the value, the value of one is ten times less bright than the value of ten



Create Text

This function creates text object at the given coordinates. This function requires the parameters:
Text - String (e.g. "Text 123")
Vector2f - X, Y coordinates (e.g. [-1400,-370];) this would draw screen to the bottom left of the screen.)
Vector3f - R, G, B colors (e.g [1,1,1]; // Text color = white
new Vector3f(0,0,0); // Text color = black
) Float - Size of the text (e.g 64)

Note:
Vector2f coordinates are divided by the width and height of the screen and 0,0 is the center of the screen, as well as the anchor point of the text is the bottom left corner.
Float text sizes are divided by 100, this is to make it so that the size looks normal and is easy to change.


Render Text

This function renders a given text object renderText(text);


Remove Rendered Text

This function takes in an integer id of a text rendered text, starting at 0 and going to $tp (Current Text Pointer) This function is quite simple, but it does require some logical thinking.
removeRenderText($tp);
The above function call removes the last text to be rendered
removeRenderedText($tp-1)
The above function call removes the second to last rendered text.
removeRenderedText(text);
The above code removes the given text object.


Create Panel

This function creates a panel, it requires 4 Vector3fs and 2 Vector2fs
Vector3fs:

Vector2fs:

renderPanel(new Vector3f(1,0,0), new Vector3f(0,1,0), new Vector3f(0,0,1), new Vector3f(1,1,1), new Vector2f(-800f,-500f), new Vector2f(1675,1000));
Above code would render a colorful panel in the middle of the screen.


Render Text

This function renders a created panel. renderPanel(panel);


Remove Rendered Panel

This function takes in an integer id of a text rendered panel, starting at 0 and going to $pp (Current Panel Pointer) This function is quite simple, but it does require some logical thinking.
removeRenderPanel($pp);
The above function call removes the last panel to be rendered
removeRenderedPanel($pp-1)
The above function call removes the second to last rendered panel.
removeRendererdPanel(panel);
Removes the given panel object.


Play Sound

This function allows for audio to be played. This function takes in either an audio variable or a string.
String - The path to the audio file relative to the game exe / jar

playSound("res/path/to/my/audio.wav");

Note: All audio files require to be in .wav file format


Randoms

Random Int

This returns a random integer.
var rand = randomInt(); print(rand);


Random Int In Range

This returns a random integer within the given range.
var rand = randomInt(10); print(rand);


Random Float

This returns a random float.
var rand = randomFloat(); print(rand);


Random Double

This returns a random double.
var rand = randomDouble(); print(rand);


Random Long

This returns a random long.
var rand = randomLong(); print(rand);


Set Position

This function sets the position of the sepcified object and changes it to the given 3D vector
setPosition(myPyramid, [10,50,10]);
The code above sets the position of the object "myPyramid" to X :: 10 Y :: 50 Z :: 10


Set Rotation

This function sets the rotation of the sepcified object and changes it to the given 3D vector
myPyramid.setRotation(myPyramid, [10,50,10]);
The code above sets the rotation of the object "myPyramid" to X :: 10 Y :: 50 Z :: 10


Set Scale

This function sets the scale of the sepcified object and changes it to the given 3D vector
myPyramid.setScale(myPyramid, [10,50,10]);
The code above sets the scale of the object "myPyramid" to X :: 10 Y :: 50 Z :: 10


Back

6E 69 63 65

awewsomegamer