-
Notifications
You must be signed in to change notification settings - Fork 0
Basic syntax
Here you will know basic syntax of MPL language:
Variables, functions, types and e.t.c.
Simple way to declare variable:
variable = 123In this context variable would has 'any' type.
But we can define type:
variable: round_number = 123Function declare simple too.
function example(content)
return content
endHere function 'example' would have 'any' return type. 'content' argument same.
async function example(content: string): string
return content + "123"
endIf we call the async function it will create a new task where this function process will execute.
variable = example("-2-10")
-- (__task) { id = 0 }
variable = await example("-2-10")
-- "-2-10123"Calling async function without keyword will return '__task' type with task id.
type example
id: string
without_type
function test(content): other_type
endHere we can see type declaration where 'id' has a 'string ' type, 'without_type' type 'any' and the function 'test' who returns a type with 'other_type' name.
enum direction
left = 0,
up = 1,
right = 2,
down = 3
endEnum 'direction' with 'left', 'up', 'right', 'down' members.
But enums has own specifics.
variable: enum direction
Here, enum direction mean that's variable contains instances of 'direction' enum but not the member of it.
If we need member, we need use 'enum_member direction'.
Also 'enum', 'enum member' can be used without name.
MPL has 3 access modifiers: bindable. readonly, static.
bindable variable.
Thats mean variable getter can setted in C# code.
This access modifier work also with functions and types members.
That says that we can use entities in other scripts who imported with 'import' keyword.
module "other"
other_variable = 123
static variable = 123
--...
import other_script
variable = 231
other_variable = 321 -- Cannot access exceptionReadonly mean that entities cannot be changed in other scripts.