Posts: 4,628
Threads: 115
Joined: Dec 2011
Thanks: 693
Given 494 thank(s) in 423 post(s)
12-29-2013, 10:57 PM
(This post was last modified: 12-29-2013, 11:14 PM by NiLSPACE.)
But there are commands that use two "/" like //set BlockType.
I was thinking. I could also set all the commands in categories in the file itself. Like:
Navigation =
{
Descend = {
Command = "/descend;/desc"
etc...
},
etc...
}
Region =
{
etc...
Maybe we also need a plugin that generates a html page from these tables.
Oh wait.. the call function doesn't parse tables ;(
Wait! Maybe we can use the loadstring function for that.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
We don't need a separate plugin for that, we can make a source file that will expect this table to be called g_PluginInfo and will export them. Easy.
As for the doubleslash commands, even that is possible, although it looks a bit worse:
Commands =
{
["/set"] = { ... }
}
I think the categories should be a "member variable" for each command; this way a command doesn't need to be in a category, or could be in multiple categories at once; the exporting code would take care of that. And the categories could get a separate description, too:
g_PluginInfo =
{
...
Commands =
{
descend =
{
Category = "Navigation";
Permission = "..."; ...
},
...
},
CommandCategories =
{
Navigation =
{
Desc = "Commands in this category will teleport a player to various important places";
},
...
},
};
Posts: 4,628
Threads: 115
Joined: Dec 2011
Thanks: 693
Given 494 thank(s) in 423 post(s)
12-29-2013, 11:51 PM
(This post was last modified: 12-30-2013, 12:10 AM by NiLSPACE.)
xoft Wrote:although it looks a bit worse:
Yea that doesn't look pretty
xoft Wrote:I think the categories should be a "member variable" for each command; this way a command doesn't need to be in a category, or could be in multiple categories at once; the exporting code would take care of that. And the categories could get a separate description, too: That's a good idea
I created a branch where I'm now working on the new way of binding commands. Gonna work on the categories but I'l have some coffee first https://github.com/STRWarrior/WorldEdit/...escription
Posts: 4,628
Threads: 115
Joined: Dec 2011
Thanks: 693
Given 494 thank(s) in 423 post(s)
Ok Categories implented.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
12-30-2013, 03:31 AM
(This post was last modified: 12-30-2013, 03:42 AM by xoft.)
Very well, I'll write the same thing for Gallery and then write a processor that will use such a table to produce the documentation.
You are still using the explicit commands, is that really necessary?
Hmm, we have a problem. Gallery allows the server admin to select their own command prefix, so the command names are not exactly known.
Posts: 4,628
Threads: 115
Joined: Dec 2011
Thanks: 693
Given 494 thank(s) in 423 post(s)
12-30-2013, 03:57 AM
(This post was last modified: 12-30-2013, 04:02 AM by NiLSPACE.)
How were you planning on doing the processor. I started on it, but then we had dinner. Maybe you had a different approach in mind:
m_PluginManager = nil
m_Plugin = nil
m_ShouldReload = false
function Initialize(Plugin)
m_Plugin = Plugin
Plugin:SetName("DocumentPlugin")
Plugin:SetVersion(1)
m_PluginManager = cRoot:Get():GetPluginManager()
cPluginManager.AddHook(cPluginManager.HOOK_TICK, OnTick)
return true
end
function OnTick()
if m_ShouldReload then
m_PluginManager:DisablePlugin(m_Plugin:GetName())
m_PluginManager:LoadPlugin(m_Plugin:GetDirectory())
end
end
function DocumentPlugin(Plugin, FileName)
local Folder = Plugin:GetLocalFolder()
dofile(Folder .. "/" .. FileName)
-- Process the g_PluginInfo table
m_ShouldReload = true
return true
end
I'm still using the explicit commands because I can now easily create aliases. Or should I do it like
["/ascend"] =
{
Alias = "/asc",
-- etc
},
instead of
Ascend =
{
Command = "/ascend;/asc",
-- etc
},
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
12-30-2013, 04:33 AM
(This post was last modified: 12-30-2013, 04:35 AM by xoft.)
I'm writing the processor not as a separate plugin, but rather as a set of files that can be copied into any plugin and that will document that plugin.
I've started with the generic command registrator that will register all commands and subcommands based on the info in g_PluginInfo.Commands. I think it's getting close to being usable, so I'll commit it very soon to the Gallery plugin, if the net connection permits - I'm on a train back home.
I was planning on making a special variable available in each command, called Alias, which could be either a single string (for a single alias), or an array table of string for multiple aliases:
Commands =
{
ascend =
{
Alias = { "asc", "a", },
}
} ;
It fits better into the scheme of subcommands ("/gal info" etc.)
Posts: 4,628
Threads: 115
Joined: Dec 2011
Thanks: 693
Given 494 thank(s) in 423 post(s)
12-30-2013, 04:38 AM
(This post was last modified: 12-30-2013, 05:28 AM by NiLSPACE.)
(12-30-2013, 04:33 AM)xoft Wrote: I was planning on making a special variable available in each command, called Alias, which could be either a single string (for a single alias), or an array table of string for multiple aliases:
Commands =
{
ascend =
{
Alias = { "asc", "a", },
}
} ;
It fits better into the scheme of subcommands ("/gal info" etc.)
Oh then I'l edit my table.
I implented it.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
With all those superfluous slashes in the commands, I decided that the full command name will be the key to the info table. I've already changed WE's info table, I'm now working on the dumper.
I decided to flatten WE's folder hierarchy to simplify loading the plugin. You won't be pleased with how much I've moved stuff around
Posts: 4,628
Threads: 115
Joined: Dec 2011
Thanks: 693
Given 494 thank(s) in 423 post(s)
I guess all I can do is wait
|