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
3 registered members (AndrewAMD, Grant, Neb), 908 guests, and 6 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
Page 1 of 2 1 2
Keyboard input #411658
11/18/12 16:24
11/18/12 16:24
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
I am working with the free version of A8
I'm making a simulation where the user can input some data points
I'd like to know if there's a way to set a variable as the "next number"
that is input. Or if I have to do if (key_1){} if (key_2){} etc...
thanks for the help

Re: Keyboard input [Re: rtsgamer706] #411660
11/18/12 16:52
11/18/12 16:52
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
key_lastpressed + some calculations should do it wink

here are the links:
- key_lastpressed
- key mapping (-> "Scancode")

if this isn't what you're looking for, please describe what you need in more detail.

EDIT: Do you want to get a number (0 - 9) based on the keys key_0 ... key_9
(that's how I understood you) or do you want to input a longer number (like 1234)?

Kartoffel smile

Last edited by Kartoffel; 11/18/12 16:59.

POTATO-MAN saves the day! - Random
Re: Keyboard input [Re: Kartoffel] #411681
11/18/12 20:01
11/18/12 20:01
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
nice to know
but I actually need longer numbers like 125 is hundred and twenty five
I might be able to figure that out with the scancodes, but if there's an easier way please let me know
thanks for the help

Re: Keyboard input [Re: rtsgamer706] #411686
11/18/12 20:34
11/18/12 20:34
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
use
inkey(STRING* );
together with
str_to_float(STRING* );

if you want to then I'll make a small example for you

EDIT: well... I just made an example grin

Code:
#include <acknex.h>

// small helper-define, waits until 'comparison' is false
#define wait_for_false(comparison) while(comparison) wait(1)

var inkey_var = 0;
STRING* inkey_string = "#10"; // create a string with 10 characters maximum

PANEL* test_pan =
{
	digits(20, 20, "Write a number end press [enter] ;)

Inkey String: %s", "Arial#26", 1, inkey_string);
	digits(20, 110, "The Input converted into a var: %.3f", "Arial#26", 1, inkey_var);
	flags = SHOW;
}

void main()
{
	fps_max = 60;
	
	while(1) // repeat this
	{
		inkey(inkey_string);
		
		wait_for_false(inkey_active); // wait until inkey is terminated
		
		inkey_var = (var)str_to_float(inkey_string); // convert the string into a var
		
		str_cpy(inkey_string, "          "); // clear 'inkey_string' by filling it again with 10 spaces
		
		wait_for_false(key_any); // wait until no key is pressed -> then again call inkey
		
		wait(1);
	}
}


the important stuff is in main()

I also made a #define which I use as wait_for_false(comparison);
don't let this irritate you, it's just a smaller version of
Code:
while(comparison)
{
	wait(1);
}


I'm just using it 'cause I'm too lazy to always write this 'while...wait'-stuff and because i'ts easier to read laugh

Last edited by Kartoffel; 11/18/12 20:55.

POTATO-MAN saves the day! - Random
Re: Keyboard input [Re: Kartoffel] #411692
11/18/12 21:20
11/18/12 21:20
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
wow, that was really nice of you
thanks for all the code, I'll put it to good use =)
Rtsgamer706

Re: Keyboard input [Re: rtsgamer706] #411695
11/18/12 21:36
11/18/12 21:36
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
no problem wink
If you've got more questions, feel free to ask!


POTATO-MAN saves the day! - Random
Re: Keyboard input [Re: Kartoffel] #411697
11/18/12 21:53
11/18/12 21:53
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
Does the code you have me disable entities or something?
I loaded an empty level and then
I tried to spawn in a model with an "ent_create" command and it just won't show up

Last edited by rtsgamer706; 11/18/12 21:54.
Re: Keyboard input [Re: rtsgamer706] #411698
11/18/12 22:04
11/18/12 22:04
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
err no?

At least it shouldn't...


POTATO-MAN saves the day! - Random
Re: Keyboard input [Re: Kartoffel] #411699
11/18/12 22:04
11/18/12 22:04
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
oh wait! did you place it after the while(1) { [...] } ?

EDIT: ...because this loop is endless so the stuff after it never gets called.
You can simply avoid this by creating a new function for the var-inkey stuff which you call if you want to input the number

Last edited by Kartoffel; 11/18/12 22:06.

POTATO-MAN saves the day! - Random
Re: Keyboard input [Re: Kartoffel] #411701
11/18/12 22:09
11/18/12 22:09
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
weird, the model won't show, I put the inkey stuff in a function
and I put the ent_create in main right after the level load
any ideas?

Page 1 of 2 1 2

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