Chat Command Array Thing - Help?
I'm getting pretty tired of how much of a damn mess QX's message.cs is. I cry when I see the two chat command functions, the fact that only 5% of the commands are in /help (or {help, or {help2), and the ugliest indentation job I've ever seen. I also want to make it much easier to add each command to /help. I'm thinking of rewriting it, doing something like this:
Thing is, what I have above doesn't work. Can't have [] in a function name. Or in a package name. And Activate/DeactivatePackage don't like me using a variable, so I can't do 'package cc#' and '"cc" @ %i'.
In other words, I need help (maybe even in more ways than just one). :P Anyone got advice on what to do? Thanks.
%cc[0].cmd = 'repairpulse'; // Name of command %cc[0].syntax = '{repairpulse'; // Syntax, use spaces only to separate arguments %cc[0].admin = 0; // Admin or super admin only? 0 = false, 1 = admin only, 2 = super admin only %cc[0].desc = 'Emits a Repair Pulse from your position.'; // Description of command for /help command, set this to 'hidden' if you do not want the command to appear in /help function cc[0](%sender,%a2) { %plyr = %sender.player; Aidpulse(%plyr.getPosition(),%plyr,RepairPulseProjectile,%plyr.getRotation()); } [...] function welkjfhakfsldjfjhcmdZ(%sender,%a2) { // Function name brought to you by frustration for (%i = 0; %i < 1; %i ++) { if (getWord(%a2,0) $= %cc[%i].cmd) { if (getWordCount(%a2) == getWordCount(%cc[%i].syntax)) cc[%i](%sender,%a2); else MessageClient(%sender,0,'Syntax: ' @ %cc[0].syntax); return; } else echo(getWord(%a2,0) SPC %cc[%i].cmd); } }I'd bet there's a better way to do something like this, but I wouldn't know about it (yet?), or I'm too tired to think of it. And I'd like to be a bit nicer where I call the cc function so I only pass the amount of variables that are needed, if that's even possible.
Thing is, what I have above doesn't work. Can't have [] in a function name. Or in a package name. And Activate/DeactivatePackage don't like me using a variable, so I can't do 'package cc#' and '"cc" @ %i'.
In other words, I need help (maybe even in more ways than just one). :P Anyone got advice on what to do? Thanks.
Comments
You should really be using double quotes instead of single, as you're using up tagged strings.
I wish you luck with that.
I've hit it only when experimenting with quine type self-modifying functions (a function that continually copied itself to a new random name, and deactivated the old name).
You won't hit that limit in ordinary programming, even if you are as prolific as I am.
We'll have to wait and see.