I Wanna Be The Forums!

General Category => Game Design! => Topic started by: Benxamix2 on September 21, 2011, 02:59:02 pm

Title: Easy thing on GM, but I have no idea how to do it...
Post by: Benxamix2 on September 21, 2011, 02:59:02 pm
I need it to do this:

"Press " + string ( KEYNAME ) + " to Jump".

But I have no idea about how to get the key name from its keycode (for example 16 = "Shift")
How do I do that?
Are arrays the only way?
Title: Re: Easy thing on GM, but I have no idea how to do it...
Post by: Ellipsis on September 21, 2011, 02:59:55 pm
Sorry but as far as I know, yes that's the only way.
Title: Re: Easy thing on GM, but I have no idea how to do it...
Post by: El Barto on September 21, 2011, 04:01:58 pm
You can use YoSniper's controls script. Its called "controlIndex" and this is how it works: draw_text(x, y, "Press "+controlIndex( global.keyToPress )+" asshole!");

Code: [Select]
switch(argument0) {
    case vk_space: return "SPACE";
    case vk_shift: return "SHIFT";
    case vk_control: return "CONTROL";
    case vk_alt: return "ALT";
    case vk_enter: return "ENTER";
    case vk_up: return "UP";
    case vk_down: return "DOWN";
    case vk_left: return "LEFT";
    case vk_right: return "RIGHT";
    case vk_backspace: return "BACKSPACE";
    case vk_f1: return "F1";
    case vk_f3: return "F3";
    case vk_f4: return "F4";
    case vk_f5: return "F5";
    case vk_f6: return "F6";
    case vk_f7: return "F7";
    case vk_f8: return "F8";
    case vk_f9: return "F9";
    case vk_f10: return "F10";
    case vk_f11: return "F11";
    case vk_f12: return "F12";
    case vk_tab: return "TAB";
    case vk_numpad0: return "NUMPAD 0";
    case vk_numpad1: return "NUMPAD 1";
    case vk_numpad2: return "NUMPAD 2";
    case vk_numpad3: return "NUMPAD 3";
    case vk_numpad4: return "NUMPAD 4";
    case vk_numpad5: return "NUMPAD 5";
    case vk_numpad6: return "NUMPAD 6";
    case vk_numpad7: return "NUMPAD 7";
    case vk_numpad8: return "NUMPAD 8";
    case vk_numpad9: return "NUMPAD 9";
    default: return chr(argument0);
};
Title: Re: Easy thing on GM, but I have no idea how to do it...
Post by: Benxamix2 on September 21, 2011, 07:47:07 pm
You can use YoSniper's controls script. Its called "controlIndex" and this is how it works: draw_text(x, y, "Press "+controlIndex( global.keyToPress )+" asshole!");

I didn't know that thing even exist. Anyway, I did solve this by myself using global variables. But thanks anyway.