I've investigated the ingame console a bit and had some ideas how it could improved. I've problem to decide what is better:
-make the syntax like function calls:
/function value1 value2
-make the syntax like programm calls
/function param1=value1 param2=value2
the second option is much more flexible, it would allow a something like a real shell with much improved commands.
the first one only would allow to call functions with parameters and optional ones.
I want to improve that, because the current function CGame::ActionReceived in game.cpp is about ~2500 lines long, this has to be splitted into several parts, at best where it is used. this would allow easy add commands for example to debug something without changing game.cpp. In the 2500 lines is many redundant stuff, like type-converting / parameter evaluating, ... my improvement would allow easy adding of autocomplete / help / ...
Any ideas or suggestions there?
I don't ask how to implement that, i only ask what to implement and why to do it that way?
Ingame console: more function like or more shell-like?
Moderator: Moderators
- BrainDamage
- Lobby Developer
- Posts: 1164
- Joined: 25 Sep 2006, 13:56
Re: Ingame console: more function like or more shell-like?
the console is primarily used by players and often in hasty conditions ( eg trolls that need to be kicked quickly, ui reloaded before the enemy outmaneuvers you, etc ), adding extra characters and structured scheme would only slow down the typing and make it more error prone, if you want a special entry mode that is more easy for scripts/programs, you could use a different prefix and add it alongside
like
/kick foo
#kick player1=foo player2=bar
would be both valid
like
/kick foo
#kick player1=foo player2=bar
would be both valid
Re: Ingame console: more function like or more shell-like?
Don't change syntax of console commands we are used to, or we'll be angry.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Ingame console: more function like or more shell-like?
Yes, but if you wanted to add console commands and syntax, as BD pointed out, using # as the precedent would work nicely.
Basically, there is no way you could know this, but everything used to be preceded by a . instead of /
That caused a good deal of unrest (with me as well) because for years we had been using the . and the switch was quite unwelcome.
But yes, the console is used by hosts very hastily in many cases so changing what we now have would be a bad idea, however, like I said, if you're wanting to add something then all preceeding characters for that addition are fair game. Tbh I always liked ./ but no program that I know of has used that since the early 90's so I wouldn't listen to me
Basically, there is no way you could know this, but everything used to be preceded by a . instead of /
That caused a good deal of unrest (with me as well) because for years we had been using the . and the switch was quite unwelcome.
But yes, the console is used by hosts very hastily in many cases so changing what we now have would be a bad idea, however, like I said, if you're wanting to add something then all preceeding characters for that addition are fair game. Tbh I always liked ./ but no program that I know of has used that since the early 90's so I wouldn't listen to me

Re: Ingame console: more function like or more shell-like?
Shouldn't both options be possible... ?
i.e.
/give 1 armcom
/give unit=armcom qty=1
So the code first searches for the unit= & qty= and if that's not found, it goes back to the old syntax?
i.e.
/give 1 armcom
/give unit=armcom qty=1
So the code first searches for the unit= & qty= and if that's not found, it goes back to the old syntax?
Re: Ingame console: more function like or more shell-like?
What's wrong with both? Each function parameter has a name and a position, and callers can use positional parameters 0...N and then use the names for parameters N+1 if they choose.
Positional parameters are better for functions where you will always have the same short list of parameters, and named parameters are good for ones that have a very long list of parameters.
Positional parameters are better for functions where you will always have the same short list of parameters, and named parameters are good for ones that have a very long list of parameters.
Re: Ingame console: more function like or more shell-like?
Really, your first example is a subset of the second.