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:
%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

  • What about changing it to function cc0 and using call("cc"@%i,%sender,%a2);?

    You should really be using double quotes instead of single, as you're using up tagged strings.
  • You only get something like 1.5 thousand tagged strings, until catastrophe.

    I wish you luck with that.
  • Aww you kill me head with codes
  • Quantium may have had all of its crap lumped into one function to avoid the function limit. However, you can expand the helps in you want. :p
  • God damn, as if datablock limits weren't enough.
  • Nope. That's not the reasoning behind it at all.
  • You won't run into the function limit unless you are doing some really funky stuff. The limit is somewhere around 12,000 functions.

    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.
  • I always wondered what was wrong with Shifter though. It has the same symptoms as described when the guys at AVM supposedly hit it.
  • Ah, good. It'd still be really nice to have a construction mod in the latest version of TGE or TGEA, which I believe have increased datablock limits and such.
  • Speaking of which, do we plan on doing one for Ascension?
  • Or, hell, even Fallen Empire: Legions. Though I'm afraid of the web-based thing making mods for it impossible.
  • Or, hell, even Fallen Empire: Legions. Though I'm afraid of the web-based thing making mods for it impossible.
    In a recent interview they noted that though mods wouldn't be included right out of the gate, it is important to them to suppost the user content and it is "really high on their priority list".

    We'll have to wait and see. :)
  • Ah! Decisions, decisions!
Sign In or Register to comment.