I have been writing a lot of turtle programs lately and find that I am constantly rewriting the same functions. I would like to put all these functions into their own file and then include them at the top of my other turtle programs. Looking through the lua documentation it seems I need to use require
. However I can't seem to get it to work. Here is a basic example I tried:
program1:
print("Hello World")
program2
require program1
This resulted in the following error:
bios:366: [string "program2"]:1: '=' expected
I then tried setting the package path to the current directory before making the require statement like this:
package.path = package.path .. ';./?.lua;'
That also didn't work. It seem that turtles don't use the same syntax as lua for the require statement (if they support it at all)
Is there a way to do something like this with the turtles? If it is using 'require' then what is the proper syntax? (I don't have access to the files of the server I play on so simply editing them is not an option)