Team Spartan Cookies & Milk Forums
Help with string.char() - Printable Version

+- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk)
+-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html)
+--- Forum: Starfall (https://teamscm.co.uk/forum-7.html)
+--- Thread: Help with string.char() (/thread-1016.html)



Help with string.char() - SuperPlayer - 24-06-2015

Hello i have a problem with my starfall screen. Whenever i try to convert keys into string i am getting weird symbols

I am using:

hook.add( "playerbuttondown", "ButtonDown", function( ply, key )
if ( IsTyping and ply == TypingPly and NextType < time.curTime() ) then
if TypeBox == 1 then
ReceiverNameBox = ReceiverNameBox..string.char(key)
NextType = timer.curTime()+0.5
end

end

end)
At the end i want to have a normal string BUT, i am getting those weird symbols ( In the Send to line ):

[Image: D3B3BE869F47074974D67D7E2D25DFF35302AA12]

I hope someone can help me


RE: Help with string.char() - Person8880 - 24-06-2015

The key argument isn't a character, it's an enum the Source engine uses to pick up keys. That's why you're getting weird characters.

You need to translate from the enum to the key it represents. All the enums are stored in the input library, the ones you want are the KEY_ enums. Look in the docs tab for a list of all of them.


RE: Help with string.char() - SuperPlayer - 24-06-2015

Ok works. Thank you!