Cuberite Forum
Another change in Lua plugins - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: Another change in Lua plugins (/thread-313.html)



Another change in Lua plugins - FakeTruth - 01-27-2012

I already started working on this, so I'll explain what's gonna happen. And before you're gonna scream your old plugins aren't gonna work, don't worry they willTongue

With the way things currently are, you need to put everything related to your plugin in a single file what I, as a C++ developer, really hate.

This new approach loads all Lua files from a directory inside the Plugins/ directory as a single plugin. This allows you to split parts of the plugin in separate files.

I have already uploaded a demonstration of these new plugins on the googlecode repository: http://code.google.com/p/mc-server/source/browse/#svn%2Ftrunk%2FPlugins%2FNewTest

The plugin is called NewTest and has two files main.lua and tick.lua
main.lua contains the mandatory Initialize() function in which it registers a Tick hook.
tick.lua contains the Tick() function and some scoping tests to see what variables it can access.

variables declared with the local keyword are limited to the file or function they are in, variables declared without any keywords are global variables that can be accessed from within all files of the plugin.