
Originally Posted by
Pyroclastic
Not to threadjack, but I'm having trouble with some helper functions I wrote for the input support.
[highlight=lua]
registerFunction("cKeyValue", "s", "n", function(self, args)
local op1 = args[2]
local rv1 = op1[1](self,op1)
return string.byte(rv1)
end)
registerFunction("keyValue", "s", "n", function(self, args)
local op1 = args[2]
local rv1 = op1[1](self, op1)
if !InvertedKeyMap[string.byte(rv1)] then return 0 end
return InvertedKeyMap[string.byte(rv1)]
end)
[/highlight]
Ah very cool, I was thinking about adding something like that but I figured the e2 already had some helpers. It does, they're toByte(s) and toChar(N).
Also, the E2 user should never ever need the InvertedKeyMap nor the KeyMap, as they utilize the clientside KEY_* values which a user never sees nor interacts with. I made it all work with the Ascii values.

Originally Posted by
Pyroclastic
Thats what I've got so far, I'm fairly certain I'm doing it wrong as its not giving me the right values. This probably is because of the discrepancy between serverside and clientside key values.
Honestly when I wrote the initial version I used the regular input values from the wiki, but some people had mentioned they wanted ascii support so I changed to that, and it was confusing as hell to set up for me too. What I did was make the numbers the user supplies be in ascii and then it converts it to gmod values before sending. So to do it with regular letters you can do:
Code:
listenForKey(toByte("a")) 
Originally Posted by
Pyroclastic
keyDown(N) uses the IN_KEYS ones, correct?
cKeyDown(N) uses ASCII then?
Well, the IN_KEYS list has both. The keyDown() is serverside keys, so it uses the IN_* values. I didn't use Ascii here because those keys might be mapped to the mouse and the movement keys can be anywhere. They are all rebindable.
cKeyDown() takes ascii which are transformed into the KEY_* values in the function, the user isn't aware of this part.

Originally Posted by
Pyroclastic
What value would string.byte() return, IN_KEYS or ASCII?
Ascii

Originally Posted by
Pyroclastic
InvertedKeyMap is ASCII to IN_KEYS and Keyboard_ReMap is the opposite?
No, the ReMap is KEY_* to Ascii, and the Inverted is Ascii to KEY_*
Easy way to check is look at the actual file in the wire_keyboard folder, it has the regular ReMap and goes KEY_* to Ascii.

Originally Posted by
Pyroclastic
I know its a lot of questions, but I'm considerably confused on the matter, and I think these functions would be helpful.
Also, any possibility of this being SVNed? I'd love to be able to use it on other servers.
I don't mind answering questions, it's good to know someone's using the inputs and even adding on to them.
As per the SVN part, I doubt it, but you never know.
Bookmarks