Server Help

ASSS Custom Projects - <C> cmdlist

Samapico - Sun Jan 30, 2011 2:05 pm
Post subject: <C> cmdlist
Following the discussion in this topic, I made a simple ?cmdlist module.
It will list all the commands available to the player, for all the modules in the arena. The commands are sorted alphabetically. It lists commands that can only be sent privately separately. However, commands that can be sent both publicly and privately are only shown in the 'Public commands' section, it would be pretty spammy otherwise.

It needs to be loaded right after the chat module, in modules.conf.

Feel free to make improvements on this and post updates.

Source and windows binary included.

Possible improvements:
-Filter option (i.e. "?cmdlist set" would return all commands containing "set")
-Column formatting (sort commands and display them top to bottom, left to right, instead of left to right, top to bottom)
-Get the chat interface in POSTLOAD or on the first ?cmdlist called; this would allow us to load the cmdlist module earlier
-Variable number of columns / column width, perhaps even automatically adjust the column width depending on the longest command name


UPDATE 20/02/2011: Uploaded new version. Includes makefile. Compiles and runs properly both on Linux and Windows.
Cheese - Mon Jan 31, 2011 1:21 am
Post subject: Re: <C> cmdlist
Samapico wrote:
-Filter option (i.e. "?cmdlist set" would return all commands containing "set")
-Column formatting (sort commands and display them top to bottom, left to right, instead of left to right, top to bottom)
-Variable number of columns / column width, perhaps even automatically adjust the column width depending on the longest command name


i would say the first two would be substantially important, but the third one can not be done without knowing the client's resolution

Samapico wrote:
-Get the chat interface in POSTLOAD or on the first ?cmdlist called; this would allow us to load the cmdlist module earlier


this isnt even really needed, but if you feel the need to:
Get the chat interface in POSTLOAD=winner
the other one is just silly
Dr Brain - Mon Jan 31, 2011 6:52 am
Post subject:
The server does know the client's resolution, you know.
Samapico - Mon Jan 31, 2011 8:09 am
Post subject:
By the way, these 'possible improvements' are stuff that I probably won't do myself (unless I specifically need it at some point), but you're all welcome to do it tongue.gif
Cheese - Mon Jan 31, 2011 1:23 pm
Post subject:
Dr Brain wrote:
The server does know the client's resolution, you know.


lol i forgot about that






also, i rewrote this and compiled, and then it crashed when the first command got added, then i compiled your source file, same thing, then i used your included binary, same thing.
and yet you have a screenshot, so it must have worked at some point...
is there something missing?
Arnk Kilo Dylie - Mon Jan 31, 2011 2:16 pm
Post subject:
Server doesn't know the text size the client is using though

Anyway...I was hoping that you wrote something that magically could replace hz's cmdlist module. While you're doing a clever hack, I figure cmdman needs to be redone anyway...grouping commands into sections is a must--such that one could filter out staff vs player commands, commands for each module or game, etc. That's already on the list of 1,000 desirable asss revamps that might happen in the next 10 years...ramble ramble

P.S. Would recommend not using POSTLOAD.
Samapico - Mon Jan 31, 2011 5:38 pm
Post subject:
Cheese wrote:
...
Did you put cmdlist:cmdlist right after chat in modules.conf?
And it shouldn't be attached to any arena either.


As for splitting in sections...

if capman has a way to tell us if a capability is available for a normal player, we could get:

Player commands:
...

(if you have powers other than default)
Other/staff commands:
...


But splitting by modules is way trickier... Perhaps it could recognize a string in the helptext of a function (Module: ... Args: ... etc...) and categorize it as what's written at Module... If you don't write anything, or if the command doesn't have a helptext, it just puts it in a generic section.
So you could categorize your commands, but if you don't want to, you don't have to. But doing it automatically, as it is now, would be impossible icon_sad.gif


Either way, I think it's very useful, even as it is. When you forget how a particular command was spelled, or whatever.
Arnk Kilo Dylie - Mon Jan 31, 2011 5:54 pm
Post subject:
I know, that's why I brought up that cmdman needs an overhaul anyway. Oh, and capman too...

Brainstorm things you need in new versions of those and it might happen.
Samapico - Mon Jan 31, 2011 6:59 pm
Post subject:
One way to do things would be:

1) Add a 'AddCommand' function that has another parameter for a 'category'
2) The default AddCommand would use "" as category

Unless there's really a way to know from which module the AddCommand was called from...

And to differentiate player commands from staff commands, the only way I can think of is some kind of:
GroupHasCapability(somegroup (i.e. "default"), somecapability (i.e. "cmd_stats")); function.
From what I see and understand in capman.c, it would be pretty easy.........
Actually:
return(cfg->GetStr(groupdef, somegroup, cap) != NULL);
Samapico - Sun Feb 20, 2011 1:12 am
Post subject:
Found a stupid bug in function AddCommandInt...

Correct code:
Code: Show/Hide

local void AddCommandInt(const char *cmdname, CommandFunc func, Arena *arena, helptext_t ht)
{
   LOCK_MUTEX(lockcmd);


   commandInfo* cmdinfo = (commandInfo*)amalloc(sizeof(commandInfo));

instead of [...]sizeof(commandlist)[...]


Updated first post
Cheese - Sun Feb 20, 2011 10:25 am
Post subject:
recompiled from source with this fix, and it works 100% now

good job, this thing is awesome


also, since this is probably going to be used by everyone, variable column lengths and vertical alphabeticismness are going to be pretty much mandatory.
ill write it when i get some free time in about six months from now... tongue.gif

PS filter would be icing on the cake
Samapico - Sun Feb 20, 2011 11:49 am
Post subject:
Cheese wrote:

also, since this is probably going to be used by everyone, variable column lengths and vertical alphabeticismness are going to be pretty much mandatory.
ill write it when i get some free time in about six months from now... tongue.gif

PS filter would be icing on the cake
Yeah I know. I want all of these things too tongue.gif
Dr Brain - Sun Feb 20, 2011 4:33 pm
Post subject:
If your looking for output formatting, hs_util's menu module works decently well.

http://forums.minegoboom.com/viewtopic.php?t=8092
and
https://bitbucket.org/drbrain/hs_util/

I think Jowie wrote a python equivalent.
JoWie - Tue Feb 22, 2011 6:31 am
Post subject:


Requires cPickle
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group