info.lua question
#1
Hi I got a question about info.lua.

Do I just have to register the commands in the info.lua or do I need to register the commands using the BindCommand function and the info.lua is just a info table?

Another question releated to info.lua, the Alias var in commands, can it be an array or is it only a string?
Reply
Thanks given by:
#2
Note that Info.lua needs to have a capital I, otherwise it won't work on case-sensitive filesystems, such as on most Linuxes.

You either use the Info.lua file or the BindCommand function; usually not both at the same time.

Note that Info.lua is really just a descriptor table, in order to register the commands, you need to do this:
	-- Load the InfoReg shared library:
	dofile(cPluginManager:GetPluginsPath() .. "/InfoReg.lua")
	
	-- Bind all the commands:
	RegisterPluginInfoCommands();
	
	-- Bind all the console commands:
	RegisterPluginInfoConsoleCommands();
This will load an aux library that provides the actual guts to Info.lua command handling, and can register the commands and console commands for you.

The Alias can be either a single string, or an array-table of strings.
Reply
Thanks given by:
#3
Can we get the server to do this automatically?
Reply
Thanks given by:
#4
We could, theoretically, when it finds out that the plugin has the Info.lua file, it could process it this way. But when should the server do that? Before calling Initialize()? Or after?
Reply
Thanks given by:
#5
Hmm... after checking the Article on the Info.lua I got two questions,
1) When/where is AdditionalInformation displayed? is it only for external services, like if you want to use it on a website or can you actually see the text in a command or something?

2) Can you have multiple lines in AdditionalInformation Table? like if you add a \n will that make it a new line?

Maybe add Author property too?
Reply
Thanks given by:
#6
@xoft We could make it a global function instead of the server doing things automatically.
Reply
Thanks given by:
#7
AdditionalInformation is displayed in the external documentation only - use the MCServer/Plugins/InfoDump.lua script together with a Lua executable to actually generate the docs. It is expected to be an array-table of tables, each item has a Title and Contents members, each a string. Each such item is output as a separate section in the documentation, with the specified heading. To split a paragraph, simply put two newlines in the string.

Have a look at the Gallery plugin (that is referenced in the Info.lua article), it has probably the most complete Info.lua file, because the technology was developed on that plugin. GalExport and WorldEdit have a decent info files, too. The info file for the Core is somewhat lacking, it could use some polishing touches.

Feel free to open a PR for improvements in the Info.lua article (it is stored in the main MCS repo at MCServer/Plugins/APIDump/InfoFile.html). I tried to write it as good as I can, but I'm not a native English speaker and I developed the technology, which makes it somewhat difficult for me to judge the article's clarity.

As for the Author property, we discourage putting "signatures" in the code, because it discourages cooperation. If someone's "signed" in a file, others are reluctant to make changes to such a file simply because they fear the authority. We prefer to have a CONTRIBUTORS file that lists the contributors - that way they get the attribution, but don't disturb the improvements process. Of course for your own plugin you are free to choose any schema you want.

--
@STR_Warrior what do you mean? That if the server detects the Info.lua file, it would auto-load the InfoReg.lua helper file so that the plugin can call it without the first "dofile"? That would be a small help but it would make the server somewhat inconsistent, special cases like that make changing the behavior later on nearly impossible.
Reply
Thanks given by: tryy3 , Seadragon91
#8
Ah thanks Smile
And hmm... Maybe I'll add a Contributors property in my lua files instead, I prefer to keep everything in 1 place, but yeah you are right about the Author stuff.
Thanks for the help Smile
I might do some PR on that article, found a few things that a newbie like me might want to know.
Reply
Thanks given by:




Users browsing this thread: 5 Guest(s)