|
3 registered members (AndrewAMD, Grant, Neb),
908
guests, and 6
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
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
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
key_lastpressed + some calculations should do it  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 
Last edited by Kartoffel; 11/18/12 16:59.
POTATO-MAN saves the day! - Random
|
|
|
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
Expert
|
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 
#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
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 
Last edited by Kartoffel; 11/18/12 20:55.
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
rtsgamer706
OP
Senior Member
|
OP
Senior Member
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: Kartoffel]
#411699
11/18/12 22:04
11/18/12 22:04
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
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
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|