I wanted to take some ideas I saw in Java and apply them to Lua. I'm no Java expert, but I saw that Java supports annotations, which are NOT comments, which can somehow be fetched and searched for in other pieces of code. My extent of Java knowledge is printing "Hello World" and programming a simple SpongeForge Minecraft plugin.
Let's say I have items in the game. Since I want my game to be welcoming to mods, I don't want to lock my code into just registering "vanilla" items. So one approach is to have a file hard-coded to load in all the vanilla mods. The other method I see is to search files within the program for indicators for item load functions (i.e. functions that call the function that registers items, so then that mechanism can call the item function when the game needs it).
In java it looks something like this:
Code: Select all
import blaw.blaw.loadItem;
import blaw.blaw.spawnItem;
import blaw.blaw.useItem;
public class gun{
@loadItem("gun")
void loadItem(){
}
@spawnItem("gun")
void spawnItem(){
}
@useItem("gun")
void useItem(){
}
}