OnlineCop / kq-fork

Fork of KQ r910. Just for fun.
GNU General Public License v2.0
16 stars 9 forks source link

Console: Move everything console-related into KConsole class #97

Closed OnlineCop closed 2 years ago

OnlineCop commented 2 years ago

I don't even know how to use this console, other than to hold \ for a full second to see it. I can open the console, write things in it, backspace text, and close it again (yay!) but I have no idea what kinds of commands it accepts.

Changed from using char arrays to std::string, and from a base array to using std::deque to facilitate the push/pop.

It still feels clunky, so if @z9484 or anyone else wants to give feedback, I can make those changes.

And if there's a guide (or if typing 'help' in that console could give some hints), that may be a good-to-have.

z9484 commented 2 years ago

I'm not sure everything you can do with it but what I used it for was to do return progress.sidequest1 and progress.sidequest1=1 to set the lua variables in the middle of the game.

But since the change to SDL its not quite working as it used to. For example CTRL G used to print "return progress." so you wouldn't have to type the whole thing CTRL S used to print "progress." And the up/down key i'm pretty sure used to cycle through the history (in case you spelled it wrong). I can't remember if the left or right keys were ever implemented or not.

OnlineCop commented 2 years ago

Thanks, @z9484. That's at least a starting place. I know that the Ctrl-[whatever] isn't working; I see the SDL keyboard input code logic, and might have to add that back in. I also agree that up/down should act more like a terminal where it cycles through history (and I'd like left/right to be able to move the cursor so the user can insert or remove within the input string).

How do I know which functions are available in the console? Is return in return progress.sidequest1 a Lua command?

OnlineCop commented 2 years ago

I think I've got it: Lua syntax like I'd find in any of the scripts/ lua files (like change_map(...)).

Anyway, getting the Ctrl+G, Ctrl+P working could be a future commit, but unless it becomes a show stopper for getting this v1.0 out on time, I'll probably hold off till sometime down the road.

Although, having something intercept a command like help or help() and printing some useful "Here are a few examples you could try" might be nice.

z9484 commented 2 years ago

Yes its just lua commands so you can do set_gp(get_gp()+1) If you wanted to give yourself 1 gold.

pedro-w commented 2 years ago

Wow you guys are on fire! As you said it's just Lua commands, same as scripts. You may find it useful to load files with dofile "something.lua". It's easiest if the current directory is set to the location of those files, which is a debugger setting in Visual Studio? On the implementation it wasn't immediately obvious how to handle keys that didn't generate a character (i.e. CTRL-g, arrow keys) in SDL so I skipped that bit in the interests of getting something working. I thought a proper command line history, editing etc. would be a significant chunk of work that's only useful to us. On the code, I notice you've used this-> quite a bit to refer to member variables which I believe is entirely redundant

OnlineCop commented 2 years ago

The this-> for member variables is an old habit since it's not immediately obvious when something is a member variable, a global (which one day will be moved into a class), or declared locally. I definitely need to be consistent with it.

The other/codeformatting.txt file contradicts itself a few times, and needs some serious TLC, else I'd have adhered to that. Maybe a candidate for a new issue?