Skip to content

5. Semantics

Matej Vanco edited this page Oct 7, 2023 · 15 revisions

Poly Engine's programming language contains a semantic dictionary that enables you to create simple applications in just a few seconds. Complete semantics are provided below.


Datatypes

Statement Syntactic Category Description Informal Example
int Default 32-bit Integer variable declaration int num 51
float Default 32-bit Floating decimal variable declaration. Use dot instead comma float num 5.1
string Default Immutable String characteristic variable declaration string word Hello World!
bool Default 8-bit boolean variable declaration bool check 0 or bool check True
object Default Object variable declaration for internal editor. Value must be corresponding with an existing object name in the scene object obj Cube

Internal-Source Statements

Console

Statement Syntactic Category Description Informal Example
Console-Out PARAMS Default Default console output Console-Out Hellow World!
Console-Clear(); Default Default console clear Console-Clear()

String

Statement Syntactic Category Description Informal Example
Substring VARNAME, STARTINDEX, LENGHT Default Edit an existing variable of type string by start index & length index. Start index must be less than length index, otherwise the program will throw a syntax error Substring mystringvariable, 0, 3
Replace VARNAME, REPLACEFROM, REPLACETO Default Replace specific characters in an existing variable of string datatype Replace mystringvariable, OldContent, NewLolContent
@VARNAME_Length Variable Connector Returns length of a string int length @string_Length

System-Special

Statement Syntactic Category Description Informal Example
Sleep VALUE Default Sleep statement - pauses a thread for X miliseconds Sleep 1000
Restart Default Restart statement - restarts the application Restart

Input Output Streaming

Statement Syntactic Category Description Informal Example
FileStream-Create PATH,FILENAME,EXTENSION Default Creates a file on a specific path. Extension does not require a dot FileStream-Create D://,MyFile,txt
FileStream-Write PATH,FILENAME,EXTENSION,CONTENT Default Writes a content into an existing file. Extension does not require a dot. Content is a type of string FileStream-Write D://,MyFile,txt,Hello world! or `FileStream-Write D://,@fileName,@extension,@content;
FileStream-Read PATH,FILENAME,EXTENSION,STRINGVARNAME Default Reads a content from an existing file to an existing variable of a string datatype. Extension does not require a dot. Content is a type of string FileStream-Read D://,MyFile,txt,mystringvartoreadto
FileStream-Delete PATH,FILENAME,EXTENSION Default Deletes a file in a specific path. Extension does not require a dot FileStream-Delete D://,MyFile,txt
FileStream-ImgRead PATH,FILENAME,EXTENSION,OBJECTVARNAME Default Reads an image data from an existing file to an existing variable of an object datatype. Extension does not require a dot. Content is a type of object FileStream-ImgRead D://,MyFile,png,myobjtoreadtheimage
AppPath() Flexible Statement Returns an application startup-path string appPath AppPath()
FileStream-Run PATH or URL Default Run a specific file or folder from an existing path or open an URL FileStream-Run D://text.txt or https://matejvanco.com

Math and Operations

Statement Syntactic Category Description Informal Example
@VARNAME>OPERATION VALUES or @VARNAME; Default Default operation keyword. Please see 'Programming Language' section for more details @num>+24 * @number;
$PI() Flexible Extended Statement Returns the constant of PI float pi $PI()
$Sin(VALUE) Flexible Extended Statement Returns a Sine of the included value float sin $Sin(number)
$Cos(VALUE) Flexible Extended Statement Returns a Cosine of the included value float cos $Cos(number)
$Round(VALUE) Flexible Extended Statement Returns a rounded value of the included value float r $Round(number)
$Random(MIN, MAX) Flexible Extended Statement Returns a random value by the min & max limits float rand $Random(1,8) or @num>+$Random(1,anynumber)
$Clamp(VALUE, MIN, MAX) Flexible Extended Statement Returns a value within the min & max limits float clamp $Clamp(clamp,1,8) or @num>+$Clamp(mynumber,1,anynumber)
$Lerp(A,B,T) Flexible Extended Statement Returns a linearly-interpolated value between A & B by T value @num>=$Lerp(1,5,t)
@VARNAME_Abs Variable Connector Returns an absolute value of the variable value int number @Num_Abs
@VARNAME_IsNum Variable Connector Checks if the included variable is a numerical type - INTEGER if @var1_IsNum = True then {...}
@VARNAME_IsNumF Variable Connector Checks if the included variable is a numerical type - FLOAT if @var1_IsNumF = True then {...}
@VARNAME_ToInt Variable Connector Converts a string variable to integer datatype int number @MyWord_ToInt
@VARNAME_ToFloat Variable Connector Convert a string variable to float datatype float number @MyWord_ToFloat

Condition

Statement Syntactic Category Description Informal Example
if VALUE1 OPERATOR VALUE2 then {...} Default Default condition keyword. Please see 'Programming Language' section for more details if @var1 = @var2 then {...}

Cycle For

Statement Syntactic Category Description Informal Example
for>STARTINDEX>LENGTH {...} Default Default cycle-for keyword. Please see 'Programming Language' section for more details for>0>10 {...}

Custom Functions and Methods

Statement Syntactic Category Description Informal Example
-FunctionName Default Default function declaration. Please see 'Programming Language' section for more details -MyFunction
#FunctionName Default Default function jump. Program will skip upcoming lines to the specific function index. Please see 'Programming Language' section for more details #MyFunction
%FunctionName Default Default function call. Program will call the specific function and then continue in a code. Please see 'Programming Language' section for more details %MyFunction

Internal-Engine Statements

Object Transform

Statement Syntactic Category Description Informal Example
CreateObject OBJECTTYPE, OBJNAME, XPOS, YPOS, COLOR, XSIZE, YSIZE Default Create an object of a specific type. Allowed types: Panel, Text, Button, Label. Optional parameters are COLOR, XSIZE and YSIZE, it's not necessary to write them in the statement. Color declaration can be typed as default known color [black/blue/cyan...] or you can type color in a byte pattern[0 to 255] #Rvalue-Gvalue-Bvalue-. It's a single statement which can be used as a variable declaration for object. Example: object myobj MyPanel; CreateObject Panel, MyPanel, 200, @posy or CreateObject Panel, myPanel, @ypos, 80, black, @sizex, 100
RemoveObject OBJNAME Default Remove a specific & existing object RemoveObject myobj
SetLocation OBJNAME, XPOS, YPOS Default Set location of an existing object in the editor. Existing object should be declared as an 'object' variable. Optional last value corresponds to the centric-object align. If the value is set to 0, default relocation will be proceeded SetLocation mypanel, 200, @yvalue,0(OPTIONAL)
SetColor OBJNAME, COLOR Default Set color of an existing object in the editor. Existing object should be declared as an 'object' variable. The RGB delceration is also allowed SetColor mypanel, black or SetColor mypanel, 240, 98, 48
SetText OBJNAME, TEXT Default Set text of an existing object in the editor. Existing object should be declared as an 'object' variable SetText mypanel, hello world!
SetSize OBJNAME, WIDTH, HEIGHT Default Set size of an existing object in the editor. Existing object should be declared as an 'object' variable SetSize mypanel, 240, @height
SetActive OBJNAME, VALUE Default Set activation value of an existing object in the editor. Existing object should be declared as an 'object' variable SetActive mypanel, True
SwitchImage OBJNAME, RESOURCENAME Default Switch an image with an existing resource on existing object variable. Existing object should be declared as an 'object' variable SwitchImage MyObj,image1.png
$Overlap(V1,V2) Flexible Extended Statement Returns True or False of two overlapped objects. The second object doesn't require variable declaration, use Object name as a reference bool overlapped $Overlap(obj1,obj2)
$Overlap(V1,V2,OUT) Flexible Extended Statement Returns True or False of two overlapped objects. Declares a new variable with overlapped object bool overlapped $Overlap(obj1,obj2,obj)
$TouchPixel(X,Y,R,G,B) or (X,Y,COLOR) Flexible Extended Statement Returns True or False if the specific 2D point (X/Y) is touching a specific pixel color. The color can be specified in RGB or by known color pattern bool touching $TouchPixel(15,4,white)
@VARNAME_LocationX Variable Connector Returns specific variable connector of an object's transform int posX @obj_LocationX
@VARNAME_LocationY Variable Connector Returns specific variable connector of an object's transform int posY @obj_LocationY
@VARNAME_CLocationX Variable Connector Returns specific variable connector of an object's centric-transform int posX @obj_CLocationX
@VARNAME_CLocationY Variable Connector Returns specific variable connector of an object's centric-transform int posY @obj_CLocationY
@VARNAME_LocationXS Variable Connector Returns specific variable connector of an object's transform related to the screen coordinates int posXs @obj_LocationXS
@VARNAME_LocationYS Variable Connector Returns specific variable connector of an object's transform related to the screen coordinates int posYs @obj_LocationYS
@VARNAME_CLocationXS Variable Connector Returns specific variable connector of an object's centric-transform related to the screen coordinates int posXs @obj_CLocationXS
@VARNAME_CLocationYS Variable Connector Returns specific variable connector of an object's centric-transform related to the screen coordinates int posYs @obj_CLocationYS
@VARNAME_Width Variable Connector Returns specific variable connector of an object's width int width @obj_Width
@VARNAME_Height Variable Connector Returns specific variable connector of an object's height int height @obj_Height
@VARNAME_Name Variable Connector Returns specific variable connector of an object's name string name @obj_Name
@VARNAME_Text Variable Connector Returns specific variable connector of an object's text string text @obj_Text
@VARNAME_Value Variable Connector Returns specific variable connector of an object's value int val @obj_Value
@VARNAME_Exists Variable Connector Returns specific variable connector of an object's existence - Returns True/False bool exist @obj_Exists
@VARNAME_ColorR or G or B Variable Connector Returns specific variable connector of an object's color - ColorR, ColorG, ColorB string Rcolor @obj_ColorR

Editor Window

Statement Syntactic Category Description Informal Example
Draw X,Y,BRUSHSIZE,COLOR Default Draw graphics on specific location with specific brush size & color. The color may be declared as a RGB value such as #R-G-B- or as known color like yellow, blue... Draw 42,CursorY(),30,#@r-@g-@b-
ClearDraw() Default Clear the whole environment of the created graphics. NOTICE: engine-related objects won't be removed. To make this happen, call ClearEditor() ClearDraw()
SetWindowSize WIDTH, HEIGHT Default Set engine editor window size at runtime by width & height value SetWindowSize 200, @height
ClearEditor() Default Clear all the created elements in the engine editor ClearEditor()
LoadScene SCENENAME Default Load an existing scene at runtime LoadScene Level1
PlayAnimation CLIPNAME,LOOP? Default Play an existing animation clip in a project. Define if the clip is loop or played once by 1 or 0 PlayAnimation Run,1 or PlayAnimation Run,True
StopAnimation() Default Stop currently running animation clip in a project StopAnimation()
ResetAnimation() Default Reset affected object's state of the currently running animation clip in a project ResetAnimation()
AnimationPlaying() Flexible Statement Returns if there's any animation currently running. Can be used during the variable declaration bool animRunning AnimationPlaying()
PlaySound SOUNDNAME,CHANNELINDEX Default Play a specific sound from the resources folder in a specific channel (0,1,2 channels available) PlaySound shot.wav,0
WindowWidth() Flexible Statement Returns current editor window width int windowWidth WindowWidth()
WindowHeight() Flexible Statement Returns current editor window height int windowHeight WindowHeight()
CursorX() Flexible Statement Returns cursor location X int cx CursorX()
CursorY() Flexible Statement Returns cursor location Y int cy CursorY()
CursorXS() Flexible Statement Returns cursor location X related to the screen coordinates int cxs CursorXS()
CursorYS() Flexible Statement Returns cursor location Y related to the screen coordinates int cys CursorYS()
Start() Default Begin to 'Tick' & executes the 'Update' function Start()
Stop() Default Stop the 'Update' function Stop()
Tick VALUE Default Set the 'Update' tick refresh rate Tick 100 - Default

Events

Statement Syntactic Category Description Informal Example
KeyEvent() Flexible Statement Returns a pressed key by the user. Can be used during the variable declaration string pressedKey KeyEvent()
MouseDown() Flexible Statement Returns a pressed left mouse by the user. Can be used during the variable declaration bool pressedMouse MouseDown()
MouseDownR() Flexible Statement Returns a pressed right mouse by the user. Can be used during the variable declaration bool pressedMouse MouseDownR()
MouseOver() Flexible Statement Returns True or False if the cursor is over the main window. Can be used during the variable declaration bool isOver MouseOver()
Clone this wiki locally