Note: Starting your code:
If you have a method and want to start code from that package, you need to have package - "Main", inside of it class - "Main" and inside of the main class a Main function.
If you don't have packages in your code then you need to have a class named "Main" and inside of it function "Main"
Semi-colons are
important!
Constructors don't do this in this version:
class Test {
public function Test() {
return this;
}
}
The constructor does it automatically!
And thats out of the way, everything is like Lua
How to start off:
class Main {
public function Main(args) {
print(args[1]);
}
}
//Input: tutorial.lua Hello,World!
//Output: Hello,World!
How to create a package:
package <name> {
...
}
How to create a class:
class <name> {
...
}
Function types:
public function <name>(...)
// or //
private function <name>(...)
How to declare a variable:
var <name>=<value>;
Comments:
//This is a one line comment.
/*
This
is
a
Multi-line
comment.
*/
How to use other packages:
using <name>;
How to use other classes and extend into them:
class Tutorial extends Lua {//Extending
...
}
class Tutorial {
var lua = new Lua();//Using
}
CraftOS:
class Main {
using CraftOS;
var term=new Term();
var shell=new Shell();
var os=new OS();
var paintutils=new Paintutils();
var fs=new FileSystem();
}
For loops:
for(i=1,maxNumber,addNumber) {
//...
}
//Another example:
for(i=1,maxNumber,--) { //or : ++
//...
}
Other stuff:
//Added:
i+=1;
i-=1;
i*=1;
i/=1;
i++;
i--;
Lambdas:
//1
var lambda=x->x*2;
print(lambda(2)); //output: 4
//2
var lambda;
lambda = x -> x*2;
print(lambda(2)); //output: 4
//3
public function Test(arg, input) {
return arg(input);
}
print(Test(x->x*1, 100)); //output: 0