User Tools

Site Tools


lua:introduction_to_lua_programming

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
introduction_to_lua_programming [2020/10/29 10:35] atolstovlua:introduction_to_lua_programming [2021/08/06 08:48] emozolyak
Line 1: Line 1:
 +{{ :lua_logo.png?nolink&100|}} 
 +
 ====== Introduction to Lua programming ====== ====== Introduction to Lua programming ======
-WebHMI allows you to create custom programs (scripts) in [[https://en.wikipedia.org/wiki/Lua | Lua]] 5.1 language. The scripts are managed in the **Setup -> Scripts** menu item. +WebHMI allows you to create custom programs (scripts) in [[https://en.wikipedia.org/wiki/Lua | Lua]] 5.1 language.  
 +The scripts are managed in the **Setup -> Scripts** menu item. 
  
 If you have no experience with Lua language read this tutorial at first  [[ https://gist.github.com/pateltej/bfec90ff449595f12236 | Lua in 15 minutes]].  If you have no experience with Lua language read this tutorial at first  [[ https://gist.github.com/pateltej/bfec90ff449595f12236 | Lua in 15 minutes]]. 
Line 11: Line 14:
  
 Here is an example of a simple script for WebHMI: Here is an example of a simple script for WebHMI:
-<code lua log>+<code lua>
 --[[ --[[
  these vars will be assigned only once  these vars will be assigned only once
Line 102: Line 105:
 Here we see that the error occurred while trying to perform an arithmetic operation with an undefined variable (value is **nil**). The error occurred in script with id=1, its name was 'Calculate humidity', the error occurred in line number 4 at 12:09:27.047. The variable that caused the error is called 'random'. Here we see that the error occurred while trying to perform an arithmetic operation with an undefined variable (value is **nil**). The error occurred in script with id=1, its name was 'Calculate humidity', the error occurred in line number 4 at 12:09:27.047. The variable that caused the error is called 'random'.
  
-Thus, using this log you can find all runtime errors in your scripts. Also for debugging you can use watch console window, which is available in [[scripts editor]].+Thus, using this log you can find all runtime errors in your scripts. Also for debugging you can use watch console window, which is available in [[lua:scripts_editor]].
lua/introduction_to_lua_programming.txt · Last modified: 2022/01/17 20:58 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki