• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

How can I add chr(vk_enter) to font_add_sprite_ext()?

Drell

Member
Title, I'm trying to add a font for displaying the current keyboard mappings in the help sections as Steam requires this for completed games. To do so, I'm trying to add a font from a sprite which works for the vast majority of the keys. Specifically, the numeric value of each mapped key is stored in a ds_map, and then chr() is called to convert that key to a value the font understands. However, font_add_sprite_ext() seems to be processing any form of vk_enter as a \r instead of adding it as the enter character for the font. Here's my code:

GML:
#macro fon_Buttons_Keyboard font_add_sprite_ext(spr_Buttons_Keyboard,"abcdefghim`kQWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,.?     "+chr(vk_enter)+"-.$#\"!%'&(jklnopqrstuvw",false,1)
I believe that since chr(vk_enter) returns "\r" which font_add_sprite_ext() is not recognizing. I've tried doing @"
" as well to no avail. Is there anyway to add the enter key to a font_add_sprite_ext()?
 

sylvain_l

Member
I believe that since chr(vk_enter) returns "\r" which font_add_sprite_ext() is not recognizing.
I think this is the right point.
\r is a non printable char, and as GMS interpret it as a carriage return in string, logically there is no way it would be replaceable by a printable char.
you'll have to cheat your way around using an other char (any available uft8 char'll do)
 

Drell

Member
I think this is the right point.
\r is a non printable char, and as GMS interpret it as a carriage return in string, logically there is no way it would be replaceable by a printable char.
you'll have to cheat your way around using an other char (any available uft8 char'll do)
This is the conclusion I came to as well so I guess it can't be helped.
 

TsukaYuriko

☄️
Forum Staff
Moderator
Either work around it like that, or store the key code and then either draw something from the font or some other sprite depending on whether the key is Enter or anything else.
 
Top