Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
1 registered members (Grant), 999 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
grave key and inkey/inchar #302114
12/16/09 18:29
12/16/09 18:29
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline OP
Expert
Germanunkol  Offline OP
Expert

Joined: Jun 2006
Posts: 2,640
Earth
I can't figure this one out:
The grave key ( ^ ) is used to open up the console in my game. Now if the user starts typing, the first letter is the grave, because when you press grave windows waits until you press another key and then puts down the grave symbol (if it can't make the second letter into an exponent, I believe).
So the first letter in the console input is ALWAYS ^. It's really annoying. I tried truncing it somehow, tried clipping it... doesn't seem to allow that.
Code:
void consoleDeleteGrave(STRING* activeStr)
{
	
	var length = str_len(activeStr);
	while(!inkey_active) wait(1);
	while(inkey_active)
	{
		if(str_len(activeStr) != length)
		{
			errorNum(str_len(activeStr));
			errorNum(length);
			if(str_stri(consoleInputString, "^") == 1) str_clip(consoleInputString, 1);
			
			
			return;
		}
		wait(1);
	}
}



Now I tried inkey. But Inkey is almost worse: When you press the first letter (since it can only read one char) when trying to input a command, it only reads "^" (no second letter) because windows seems to give it the two letters - ^ and the one you've typed - and it only accepts the first one.
Also, I can't get backspace to work correctly with inchar.

Really stupid... if you want to enter a quick command in the heat of battle... none of this is user friendly.

Help?


~"I never let school interfere with my education"~
-Mark Twain
Re: grave key and inkey/inchar [Re: Germanunkol] #302232
12/17/09 19:12
12/17/09 19:12
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline OP
Expert
Germanunkol  Offline OP
Expert

Joined: Jun 2006
Posts: 2,640
Earth
I should shower more. I always think of solutions while in the shower.

Got it to work. First i confused ASCII return value and scan_code return value, but now it works. For anyone who's interested:
Code:
var curScan = 0;
	do{
		//		if(key_any==1 && mouse_left==0 && mouse_right==0 && mouse_middle==0)
		//		{
			curScan = inchar(incharString);
			if(curScan != 8)		 //backspace is not pressed
			{
				if(curScan == 94 && key_lastpressed != 94)
				{
					str_for_key(incharString, key_lastpressed);
				}
				str_cat(consoleInputString,incharString);
			}
			else
			{   //backspace IS pressed
				str_trunc(consoleInputString,1);
			}
		//		}
		wait(1);
	}while(curScan!=27 && curScan != 13);



Thx to anyone who read this...
To give credits where credits are due: EvilSOB's code example in a post here in this forum helped me get started with this...


~"I never let school interfere with my education"~
-Mark Twain

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1