npm i -g lightpl
light <file_name>
light <file_name> -js
To print "Hello world" in terminal, create new file hello_world.lpl
, then print:
print('Hello world')
and run(in terminal):
light hello_world.lpl
Variables can be defined with "var" keyword
var variableName
Multiple variables can be defined together, separated by coma
var variable1, variable2, variable3
During definition variables can be initialized
var variable = 0
Variables can contain number
var variable = 0
String should be in single quote
var variable = 'Hello world'
Bool is one of two literals
var on = true
var off = false
Null represent nothing
var empty = null
to store similar data you can use lists
var list = [1, 23, 1234]
to store data as "key" "value" pares
var legs = [
'dog': 4,
'cat': 4,
'spider': 8
]
if statements with optional else statements:
if age < 18 {
print('Access deny')
} else {
print('Hello')
}
A while loop evaluates the condition before the loop:
while apples > 0 {
print('You have ' + apples + ' apples')
apples = apples - 1
}
"for" is iteration for collections:
for var item in beg {
print(item)
}
'+', '-', '*', '/'
var ourMoney = myMoney + yourMoney
'==', '!=', '>=', '<=', '>', '<'
if playerHealth == 0 {
print('You lose')
}
'!', '&&', '||'
if day == 'sunday' || day == 'saturday' {
print('This is weekend')
}
you can comment your code to explain it purpose
// We store time in seconds but show it in minutes
print(time / 60)