Ingame console: more function like or more shell-like?

Ingame console: more function like or more shell-like?

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply

Make the ingame console function like or shell like?

Poll ended at 28 Jul 2010, 18:38

i want it like function calls!
5
56%
i want it like a shell with commands
2
22%
don't know / other
2
22%
 
Total votes: 9

abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Ingame console: more function like or more shell-like?

Post by abma »

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?
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Re: Ingame console: more function like or more shell-like?

Post by BrainDamage »

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
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Ingame console: more function like or more shell-like?

Post by zwzsg »

Don't change syntax of console commands we are used to, or we'll be angry.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Ingame console: more function like or more shell-like?

Post by Forboding Angel »

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 :-)
User avatar
Zydox
Lobby Developer
Posts: 453
Joined: 23 May 2006, 13:54

Re: Ingame console: more function like or more shell-like?

Post by Zydox »

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?
User avatar
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

Re: Ingame console: more function like or more shell-like?

Post by Pxtl »

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.
slogic
AI Developer
Posts: 626
Joined: 17 Mar 2008, 19:03

Re: Ingame console: more function like or more shell-like?

Post by slogic »

Really, your first example is a subset of the second.
Post Reply

Return to “Engine”