LeekScript Next

LeekScript Next

> LeekScript

Presentation

The LeekScript Next is a future version of the LeekScript language based on a new faster compiler using LLVM. This version is currently on hiatus to focus on adding features in the current LeekScript (version 2, 3 etc.)

Project git repository: https://github.com/leek-wars/leekscript-v2 Forum topic: https://leekwars.com/forum/category-6/topic-7833

This is a draft based on the LSv1 tutorial, feel free to contribute!

Here is a pastebin listing all the functions under their module.

Literal Values

Literals are hard-coded representations of values in code. Leekscript allows you to directly write values of the following types:

Collections accept all types of literals (including collections) as values. As a reminder :

The expressions

An expression is composed of literals and application of operators or functions. Its simplest form is a simple literal: 0. Another more familiar form could be the composition of mathematical operator and numbers: -1, 1 + 1, 0 * 3, etc. . Finally, the most advanced form uses function applications: max(1, 2), rand(), etc.

In LeekScript, it is possible to evaluate several expressions in a row, ignoring the results, or keeping them in variables.

1+1 2*2 Number.cos(π * 2)

The above code will evaluate to 1.

The variables

A variable associates a name with a value. It can contain any object, assigning a literal or the result of an expression.

let me = Fight.getEntity() let y = 1 + 1 const RAD = 180.0 / π global DEBUG=false

Of these four declarations, two of them allow the declared variable to be modified, and two of them are accessible from anywhere in the code. It is advisable to use them in the following order of priority:

The const and global keywords are currently not implemented in the language. It is possible to achieve the same behavior with let and var by declaring all your functions with the anonymous syntax, thus using the scope properties of the variables.

For more details, the page on Variables is available. Although currently planned for the old version of leekscript, the operation remains the same, the new keywords only offering the new features mentioned above. A draft of the version planned for LS 2 is available on Les_Variables V2.

Control Structures

We have seen that it was possible to evaluate several expressions in a row, allowing somewhat more complex programs. This is what basic artificial intelligence does when you create a new file. However, this is far from being the most useful, which is why we have tools available that allow us to change the order in which expressions are evaluated.

Branches

We can evaluate some expressions over others depending on the result of a certain expression, for example, looking at what weapon is currently equipped, in order to equip a different weapon or avoid equipping the same weapon again .

####IF

This can be done with the if control structure. if expects an expression that evaluates to a boolean, a series of expressions to evaluate in case the result is true, and a series of expressions to evaluate in case the result is false.