# Coding in Minetest for beginner ## 1.1 Prologue Minetest is an open source voxel game engine. But more Info here: [[https://www.minetest.net/]] [[https://wiki.ircnow.org/index.php?n=Minetest.Minetest]] Depends for this tutorial: There are no, it's for newbie. ## Table of contents Never we get all in one part. There will more then one part. And we get never the complete api in this tutorial. If you have questions ask in [[forums.minetest.net]]. But now table of Contents: # [ Basics in Lua](/https://wiki.ircnow.org/index.php?n=Lua.Minetest-1 ) # [ Our first mod](/https://wiki.ircnow.org/index.php?n=Lua.Minetest-2 ) ## 1.2 Basics in Lua ### 1.2.1 Installing lua Openbsd: # pkg_add lua-5.3.5 debian-based Linux: # apt install lua5.3 For other systems show here: [[http://www.lua.org/start.html#installing]] ### 1.2.3 Functions All who know the basics in lua can show here: [ Our first mod](/https://wiki.ircnow.org/index.php?n=Lua.Minetest-2 ) Functions are the most important in minetest. Without it or similar it where not possible to make a such game. You can easy run a function: function(argument) The first function which you learn is print(). Create a new file named "main.lua" in a new folder which you can name how you want and write in main.lua: print("Hello World!") Save it and run in the console following command: $ lua5.3 /main.lua If all working correct you should get put out: $ lua5.3 /main.lua Hello World! Troubleshooting: $ lua5.3 /main.lua lua5.3: main.lua:1: ')' expected near 'World' You forgot the "". Why you need this you will sea in 1.2.4 $ lua5.3 /main.lua bash: lua5.3: Command not found. You don't have lua installed. Maybe lua5.3 is to new for your os. Try to install older versions. But then do this: $ lua /main.lua ### 1.2.4 Variables In Variables can you save data. But if you end the programm it will deleted. In lua are 3 main types of variables: intenger, floats and string. Strings we have already met in 1.2.3. Like the name say are strings strings. Important is that we on begin and on end one of this Charachters need: ' or ". You can choose one of them, which you like more, but you must on beginn and on end the same charachter choose. If in strings should stand one of this charachters, you must choose the other charachter. If there is no of this charachters then think lua you meant a other variable which you want set in there. More to this thema in 1.2.5. But there are two more types: floats and integer. Both are number-values. The different is one are decimal numbers the floats and the other are integer(yes, the integer). Both types need no charachters on end beginning because variable names can't begin with numbers. Lets define our first variables: string = "Our first Integer and our first float: " integer = 12 float = 12.34 print(string) Output: $ lua5.3 main.lua Our first Integer and our first float: Nice, but we can only print one variable. How to fix it? ### 1.2.5 Functions with more then one argument Functions can not have only one argument, they can have more then one argument. We separate they with a comma. Lets test: string = "Our first Integer and our first float: " integer = 12 float = 12.34 print(string, integer, float) Output: l$ lua5.3 main.lua Our first Integer and our first float: 12 12.34 Ok thats nice. But there are spaces.