Our first script
Introduction
In this tutorial we will be the first introduction to scripts in Emp. Our script will not really do anything but displaying a message in the screen. However, you will learn a bit about how Emp works internally.
Writing our first script
The first thing you should do is to open a text editor, and create a new file called emp101.lua
. In that file write the following
The print()
function comes within Lua and it:
Receives any number of arguments and prints their values to stdout
The stdout is the "direction" where the normal output from a program goes to. By default it goes to the console, but we will see later how to redirect it to a file.
Now, we can run this simple script to see what happens.
And the output is
A warning?
Yes, there is a warning... however, we got the result we wanted! That is, the correct message was printed on the console.
What the warning is saying is that the Task Manager has no tasks. There are two obvious ways of solving this.
Pushing tasks to the Task Manager (i.e. ask Emp to calculate something)
Tell Emp that this script does not intend to perform calculations. That can be done by including
auto_solve = false
somewhere in the script.
So, our script would become
And now, when running it (just like before) we get
Conclusions
As mentioned in the Emp architecture section, every Emp execution has two object: the Emp Model and the Task Manager. By default, the Task Manager will try to solve all the tasks that you have provided, and will warn you if you did not provide any.
This warning can be avoided by using the auto_solve=false
option.
Last updated