Stuff by David
All my stuff in one place!
Home/News
Videos
Applications
Games
Resources
About me
Minecraft Note Block Studio tutorials
The Poptart Tragedy
Building songs in Minecraft
Redstone Display Maker tutorial
Auto closing wooden door!
View all...
Minecraft Note Block Studio
Redstone Display Maker
Minecraft Redstone Simulator
The ultimate D&D to GML converter
Image to RTF converter
View all...
Chaos
Die
View all...
Game Maker examples
Labyrinth generator and solver
Tetris
Text editor
Inventory and item engine
View all...
Game Maker scripts
GML syntax coloring in-game
Change colors of certain words in a text
Center the text in the built-in dialogues
Upgrade of keyboard_string
View all...
<
Previous
|
All scripts
Upgrade of keyboard_string
Please enable javascript to view this.
/* CALL: user_input_step() INFO: Sets the user_input variable, which acts like keyboard_string, but with a few improvements. This script must be called at least once per step in order for the variable to be updated correctly. ARGUMENTS: None WRITTEN BY: Davve http://www.stuffbydavid.com Credit not needed if used, but appreciated. */ if (!variable_global_exists('user_input')) { //Create user_input if it doesn't exist. globalvar user_input, __lastlength, __press; user_input = ''; __lastlength = string_length(keyboard_string); __press = current_time; } user_input += string_delete(keyboard_string, 1, __lastlength); //Add the last typed character(s) keyboard_string = '' + (string_length(keyboard_string) < 1024) * keyboard_string; //If keyboard_string have met the 1024 limit, erase it. __lastlength = string_length(keyboard_string); if (keyboard_check_pressed(vk_backspace)) { //Erase the last typed character with backspace. user_input = string_copy(user_input, 1, string_length(user_input) - 1); __press = current_time; } user_input = string_copy(user_input, 1, string_length(user_input) - (keyboard_check(vk_backspace) && current_time - __press > 450));
Comments
Constructive criticism is always welcome!
Please enable JavaScript to view comments.