lua:custom_libraries
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
custom_libraries [2019/01/09 10:15] – created akuzmuk | lua:custom_libraries [2021/07/22 07:44] (current) – atolstov | ||
---|---|---|---|
Line 1: | Line 1: | ||
===== Libraries ===== | ===== Libraries ===== | ||
- | Since version 3.2 you can create your own libraries. These are special scripts that can be included from other scripts so you can share the same code across multiple scripts. | + | Since version 3.2 you can create your own libraries. These are special scripts that can be included from other scripts so you can share the same code across multiple scripts. |
- | <code lua> | + | |
+ | <code lua common.lib> | ||
+ | function myCommonFunction() | ||
+ | TRACE(" | ||
+ | end | ||
+ | COMMON_CONSTANT = 1.6180339887 | ||
+ | </ | ||
+ | Use special keyword **include** to include another script. Provide script title as parameter to include needed script. Here is example: | ||
+ | |||
+ | <code lua using_include> | ||
include " | include " | ||
function main(userId) | function main(userId) | ||
myCommonFunction(); | myCommonFunction(); | ||
+ | TRACE(" | ||
end | end | ||
</ | </ | ||
- | Best practice it is to put include outside any function calls. Please note that global variables in libraries will not be shared across all scripts. Only code will be shared. | + | Best practice it is to put include outside any function calls, such as '' |
lua/custom_libraries.txt · Last modified: 2021/07/22 07:44 by atolstov