Skip to content

Commit df07797

Browse files
committed
modules: some more WIP, native modules do work now arrrr, misses some minor stuff still/11+1
1 parent d493892 commit df07797

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

documentation/README-Modules.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
![LOGO](https://raw.githubusercontent.com/andreasdr/minitscript/master/resources/github/minitscript-logo.png)
2+
3+
# 1. Modules
4+
5+
MinitScript supports module script files, in short modules, including the transpilation of them.
6+
7+
## 1.1. Creating a module
8+
9+
You are declaring a script file as module script file by the "module" statement.
10+
Module script files are only allowed to have functions, callables and stacklets.
11+
12+
This is module_1.tscript, which will be used in module-test.tscript in section 1.2.
13+
14+
```
15+
module
16+
17+
# this function is provided by our module_1.tscript
18+
function: module1Function()
19+
console.printLine("-----------------")
20+
console.printLine("module1Function")
21+
console.printLine("-----------------")
22+
end
23+
```
24+
25+
## 1.2. Using a module
26+
27+
You are including a module by the "use: " statement. After the colon the relative path to the script module file is required.
28+
Note that modules can also include modules.
29+
30+
See a module-test.tscript, which uses module_1.tscript from the section 1.1. above.
31+
32+
```
33+
use: module_1.tscript
34+
35+
# initialize
36+
on: initialize
37+
console.printLine("-------------------------")
38+
console.printLine("module-test: Initialize")
39+
console.printLine("-------------------------")
40+
console.printLine()
41+
end
42+
43+
# if no condition is met, nothing will be executed, lol :D
44+
on: nothing
45+
console.printLine("-----------------------")
46+
console.printLine("module-test: Nothing")
47+
console.printLine("-----------------------")
48+
console.printLine()
49+
# call module 1 functions
50+
console.printLine("main: Calling module1Function() from module_1.tscript")
51+
module1Function()
52+
# done
53+
script.stop()
54+
end
55+
56+
# an error has occurred
57+
on: error
58+
console.printLine("--------------------")
59+
console.printLine("module-test: Error")
60+
console.printLine("--------------------")
61+
console.printLine("An error occurred")
62+
script.stop()
63+
end
64+
```
65+
66+
# 2. Links
67+
68+
## 2.1. Language Documentation
69+
- [Syntax](./documentation/README-Syntax.md)
70+
- [DataTypes](./documentation/README-DataTypes.md)
71+
- [Flow control - if, elseif, else](./documentation/README-FlowControl-Conditions.md)
72+
- [Flow Control - switch, case, default](./documentation/README-FlowControl-Conditions2.md)
73+
- [Flow Control - loops](./documentation/README-FlowControl-Loops.md)
74+
- [Classes](./documentation/README-Classes.md)
75+
- [Classes API](./documentation/README-Classes-API.md)
76+
- [Functions](./documentation/README-Functions.md)
77+
- [BuiltIn functions](./documentation/README-BuiltIn-Functions.md)
78+
- [Modules](./documentation/README-Modules.md)
79+
- [Operators](./documentation/README-Operators.md)
80+
- [Constants](./documentation/README-Constants.md)
81+
82+
## 2.2. Other Links
83+
84+
- MinitScript, see [README.md](./README.md)
85+
- MinitScript - How to build, see [README-BuildingHowTo.md](./README-BuildingHowTo.md)
86+
- MinitScript - How to use, see [README-Tools.md](./README-Tools.md)
87+
- The Mindty Kollektiv [Discord Server](https://discord.gg/Na4ACaFD)

0 commit comments

Comments
 (0)