Computer Science Canada how to make a timer and be able to get input running simultaniously |
Author: | aogborne [ Fri Apr 08, 2016 12:48 pm ] | ||
Post subject: | how to make a timer and be able to get input running simultaniously | ||
What is it you are trying to achieve? i am making a text based game that requires a timer to activate after a command but also have the user to be able to input information before the time runs out and to see the timer counting down. What is the problem you are having? the timers i have been stopping when i ask for input, via loops. Describe what you have tried to solve this problem searched timers, have tried loops with delays, loops with Time.Elapsed, procedures. I've tried functions but with the same result although i could be missing something with functions Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using 4.1.1 |
Author: | Dreadnought [ Fri Apr 08, 2016 1:50 pm ] |
Post subject: | Re: how to make a timer and be able to get input running simultaniously |
Unfortunately, get will prevent your program from running until the user hits the Enter key. This means that you can't do what you want with get. However, you could use functions like input.getchar and input.hasch to read the input from the user and display it to the screen (as if you were using get) and have a timer counting down at the same time. |
Author: | Mudgato [ Sat Apr 09, 2016 11:19 am ] |
Post subject: | Re: how to make a timer and be able to get input running simultaniously |
Dreadnought @ Fri Apr 08, 2016 1:50 pm wrote: Unfortunately, get will prevent your program from running until the user hits the Enter key. This means that you can't do what you want with get.
However, you could use functions like input.getchar and input.hasch to read the input from the user and display it to the screen (as if you were using get) and have a timer counting down at the same time. I'm also facing a similar problem with timers. Will be searching for other resources and share it back here. Can you give updates on this thread so we can share solutions? Thanks. |
Author: | aogborne [ Tue Apr 12, 2016 8:29 am ] | ||
Post subject: | Re: how to make a timer and be able to get input running simultaniously | ||
Dreadnought @ Fri Apr 08, 2016 1:50 pm wrote: Unfortunately, get will prevent your program from running until the user hits the Enter key. This means that you can't do what you want with get.
However, you could use functions like input.getchar and input.hasch to read the input from the user and display it to the screen (as if you were using get) and have a timer counting down at the same time. thanks dreadnought. so i was looking up the tutorials and this is what i have so far... any idea on how to store more than one character at a time. i have a feeling its to do with the loop??? also i just copied the var key line. i'm not sure why its (1)?
|
Author: | Dreadnought [ Tue Apr 12, 2016 10:05 am ] |
Post subject: | Re: how to make a timer and be able to get input running simultaniously |
aogborne wrote: also i just copied the var key line. i'm not sure why its (1)?
The type string (1) is a string of length 1 which is basically the same thing as a single character (my guess is that the char type was added to Turing after getch was). aogborne wrote: any idea on how to store more than one character at a time. i have a feeling its to do with the loop???
To store more than one character at a time, use a second string (not of length 1) and every time the use enters a character, add that character to your string. After that you can start getting fancy by checking if the user hit keys like backspace (see this keyboardmodule page for a list of useful constants). |