• Welcome to Valhalla Legends Archive.
 

command help

Started by pileofcrap, February 27, 2003, 07:01 PM

Previous topic - Next topic

AnThRaX

#15
Well I am definetly going to be using a flags system, access levels with numbers from 1-100 kinda suck in my opinion but anyways, thanks for the info and everyone else feel free to add to what Kp said or give some other ideas!

Grok

#16
QuoteHey Grok, I like that function, think you could do a demonstration on the "user access" stuffs? I'm kinda having some trouble with it.

QuoteAlso notice that again the hard work has been passed off to an undescribed subroutine. ;)

Very undescribed.  My purpose was to suggest a clean and layered way to handle permissions checking.  Too often I see code (including in this thread) where large if-then or select-case structures exist for comparing commands to access levels or flags.

My way offloads the labor into a function which can end up looking very pretty if done right, and would be implementation-specific.  Someone else could simply replace IsPermitted() function with a new implementation, and just drop it into the bot.

Kp

#17
QuoteVery undescribed.  My purpose was to suggest a clean and layered way to handle permissions checking.  Too often I see code (including in this thread) where large if-then or select-case structures exist for comparing commands to access levels or flags.

My way offloads the labor into a function which can end up looking very pretty if done right, and would be implementation-specific.  Someone else could simply replace IsPermitted() function with a new implementation, and just drop it into the bot.
It's still entirely possible for this subroutine to be very clean.  My preferred implementation would be to have an array of bitmasks, indexed by the command's ID.  If the bitmask logical ANDed with the user's current flags yields nonzero, the command is permitted.  Nicely compact, and quite clean.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

AnThRaX

#18
Alright, I think I understand now, I'll try some stuff and see if I can get it to work. If I do, I'll post code to a fully working "commands" function with reading accesses and such if it's ok with the creators/writers of the above codes. Thanks guys!

Also, I'm wanting some tests done on my bot for stability and such... If anyone here can do that for me and check for bad coding (not source code but just simple errors in the program) then please contact me at [email protected] Thanks again!

pile@school

#19
Im not going to use the 1-100 thing. I would prefer Character not Numeral system. I guess like Ultimate Bot.

Grok

#20
QuoteAlright, I think I understand now, I'll try some stuff and see if I can get it to work. If I do, I'll post code to a fully working "commands" function with reading accesses and such if it's ok with the creators/writers of the above codes. Thanks guys!

Of course it's OK.  Any source code posted on this forum is admitted into public domain by EULA.