• CS:S Prefab: Keyboard with a 16 character display
    18 replies, posted
[IMG]http://i46.tinypic.com/2gtrpmg.jpg[/IMG] [IMG]http://i50.tinypic.com/s28w2s.jpg[/IMG] This is an in-game keyboard with a 16 character display, you can input passwords and send "encouragement" to other players in the map. It was originally for my next surf map but because that's so far from being done I decided to just release it as a prefab. It works like an on-screen keyboard but unfortunately, using the same key in quick succession takes slightly longer to register than it should. It's most noticeable when using backspace consecutively. The default password is set to "Open" once you input the password the ENTER key unlocks and allows you to trigger the sliding doors. Video: [url]http://www.youtube.com/watch?v=4ORrpwtSM4w[/url] Download: [url]http://css.gamebanana.com/prefabs/6224[/url] I used the Press Start 2P font by Codeman38: [url]http://www.zone38.net/font/[/url] If you'd like to know how this works I'd suggest rooting around in the .vmf but here's an incoherent brief description anyway. The characters.vtf file is an ToggleTexture which from frame 0-96 has the keys of a UK style QWERTY keyboard. This texture is then applied to the func_brushes which form the display. Each brush of the display has an associated env_texturetoggle and math_counter. These counters receive values from an array of func_buttons which form the keyboard. Each button has a specific value it sends to these counters. This value corresponds to the frame number of the key which was pushed. When the math_counters receive this value they output it to their corresponding env_texturetoggle which then changes the texture of the display brush. Because the buttons send their values to all the math_counters at once, only one can be active at the same time. So, as the button sends a specific value they simultaneously send an "add 1" output to another math_counter. This counter triggers logic_relays in sequence which in turn enable the next math_counter and disable all the others. This way only one math_counter can receive inputs at a time, and which one depends on how many times the buttons have been pushed. The password system is a series of logic_branch entities, initially set to "false" they become "true" when a specific key gets pushed. The default password is "Open" so when the "O" key is pushed the first math_counter sends its value (70) to logic_compare entities which set their respective logic_branch to 1 or 0 (true or false) depending on the value it receives. A logic_branch_listener triggers when all the logic_branch entities are "true" which then unlocks the enter key. I hope that made sense and I hope you find a good use for this prefab. I'm gunna go lay down for a while. UPDATE: There are now 2 versions, the original uses 58.2% entdata whereas, the new version uses 25.1% but only has capital letters and numbers.
Total entity count?
Really nice work Kompile, nice way to unlock doors/vip rooms or something related.. [QUOTE=Kuro.;39248768]Total entity count?[/QUOTE] Over 9000 [highlight](User was banned for this post ("meme reply" - postal))[/highlight] [highlight](User was banned for this post ("meme reply" - postal))[/highlight]
I can barely wrap my head around the logic used for buttons, and then you release this.
I couldn't really make sense of your explanation but this is the way I would've done it: Setup a bunch of buttons and each set to a certain value starting at A (10), B (11), C (12), etc. and have a math_counter increase a certain amount any time a button is hit. Then have a logic_compare for the door's password value and the math_counter's current value and if at any point it was equal open it up. An example would be, let's say the password is Rock That value is stored in the logic_compare as 83. Now when the user enters ' R ' the math_counter would increase by 27. Followed by ' O ' which would increase it by 24. Then ' C ' and ' K ' which would increase it by 12 and 20 respectively. On pressing the ' Enter ' key it fires the 'OnEqualTo' output which enables a disabled logic_relay. The logic_relay then opens the door. e: I wouldn't have messed with the texture part of it though so kudos to you for that.
Wouldn't that also mean any rearrangement of the work "Rock" would work? as long as it added up to the total? I'm sorry you didn't understand my description I'll try to be clearer in the future, I just came back from the dentist when I wrote that. Although I have managed to reduce the entdata by 6.5% thanks to you! Instead of 28 logic_case entities I could've just used 4 logic_compares so cheers for the reminder. If any one has more ways to reduce the entdata I'm all for it. It's at 59.8% at the moment which is pretty bloated, If you wanted to reduce this, removing some of the keys would help a lot. I think you can have 150% in a map safely, though I may be wrong.
[QUOTE=Kompile;39253779]Wouldn't that also mean any rearrangement of the work "Rock" would work? as long as it added up to the total? I'm sorry you didn't understand my description I'll try to be clearer in the future, I just came back from the dentist when I wrote that. Although I have managed to reduce the entdata by 6.5% thanks to you! Instead of 28 logic_case entities I could've just used 4 logic_compares so cheers for the reminder. If any one has more ways to reduce the entdata I'm all for it. It's at 59.8% at the moment which is pretty bloated, If you wanted to reduce this, removing some of the keys would help a lot. I think you can have 150% in a map safely, though I may be wrong.[/QUOTE] Yeah 150% sounds right. It might be 125% though. In any case what you could do is set up a logic_compare for each password's value. So if it compares to ' R ' which is the value of 27 initially, and it finds it is equal to the password's first letter value, then it will increment the math_counter. In the same sense, using ' O ' which is 24 and using the logic_compare to compare the second letter value of the password then incrementing the math_counter if the logic_compare returns that the compared values are equal.
Would that reduce the entity count? You seem to be adding more entities to solve a problem which doesn't exist. Is something not working right?
Dude, that's some sweet stuff right there!
[QUOTE=Kompile;39254231]Would that reduce the entity count? You seem to be adding more entities to solve a problem which doesn't exist. Is something not working right?[/QUOTE] I was just saying what I would do, I wasn't actually messing with the prefab or anything.
[QUOTE=WitheredGryphon;39252053]I couldn't really make sense of your explanation but this is the way I would've done it: Setup a bunch of buttons and each set to a certain value starting at A (10), B (11), C (12), etc. and have a math_counter increase a certain amount any time a button is hit. Then have a logic_compare for the door's password value and the math_counter's current value and if at any point it was equal open it up. An example would be, let's say the password is Rock That value is stored in the logic_compare as 83. Now when the user enters ' R ' the math_counter would increase by 27. Followed by ' O ' which would increase it by 24. Then ' C ' and ' K ' which would increase it by 12 and 20 respectively. On pressing the ' Enter ' key it fires the 'OnEqualTo' output which enables a disabled logic_relay. The logic_relay then opens the door. e: I wouldn't have messed with the texture part of it though so kudos to you for that.[/QUOTE] The only real big flaw I see with that is that it would accept any letter combination so long as it added up correctly. I would use the same letter value system but multiple counters for different letter positions then compare all positions with preset ones when enter is pressed
[QUOTE]Wouldn't that also mean any rearrangement of the work "Rock" would work? as long as it added up to the total?[/QUOTE] At the moment the keys send their values to a bunch of math_counters, only one of which is active at a time. When the counter receives this number it sends it to a logic_compare with the SetValueCompare output. If the value is correct it will fire its OnEqualTo or if it's wrong OnLessThan outputs. There are four logic_compares (one for each letter of the password) each with a logic_branch it outputs to. When the value is equal it sets this logic_branch to "true" when all four of the logic_branches are "true" a logic_branch_listener fires its OnAllTrue output which unlocks the ENTER key. If an incorrect letter has been pushed the logic_compare fires its OnLessThan output which also sets it's respective logic_branch to "false". The logic_branch_listener then fires its OnMixed output which locks the ENTER key. Although as I said in the OP if you want to understand how it works you should look around in the .vmf it seems I'm incapable of describing it well enough. Thanks for the kind words everyone, I really appreciated it. :dance:
I don't know entity IO very well, but could you do something like storing each value for the correct password in a logic_caseand have a math_counter. Each time a key's hit, check if the key matches the value stored in the logic_case at the index of the math_counter and increment the math_counter. If it doesn't match, store the index where it happened. That way people can backspace and fix it. I just woke up after a massive caffeine crash so I'm not sure if anything I'm saying makes any sense. I'll see if I can make it myself.
Here's it in programming terms: [code] int password = { 20, 46, 24, 63 }; // Open stored as an ints in an array (a logic_case) int input[16]; // Holds the inputted characters int cursor = 0; // a math_counter int failedIndex = -1; // This stores the first character that failed for backspace purposes bool soFarSoGood = true; onButtonPress(int button) { input[cursor] = button; if(button == BTN_BKSP) { if(failedIndex == cursor) { if(input[cursor-1] == password[index-1]) { // If the deleted one is the one it failed on failedIndex = -1; soFarSoGood = true; } } input[cursor] = 0; cursor--; } if(password[i] != button) { soFarSoGood = false; failedIndex = i; } if(button == BTN_OPEN && soFarSoGood && cursor == password.length+1) // If the cursor is at the end of the password, the user hit the submit button, and everything was correct, it's the right password open(); // winner! :D } [/code] This is just some stuff I wrote off the top of my head, but it helps explain a lot better what I was thinking.
[QUOTE=Agent766;39279097]I don't know entity IO very well, but could you do something like storing each value for the correct password in a logic_caseand have a math_counter. Each time a key's hit, check if the key matches the value stored in the logic_case at the index of the math_counter and increment the math_counter. If it doesn't match, store the index where it happened. That way people can backspace and fix it. I just woke up after a massive caffeine crash so I'm not sure if anything I'm saying makes any sense. I'll see if I can make it myself.[/QUOTE] Yeah that should work I think
I remember trying to make something like this in SiN Episodes before I worked out how to use the VGUI screens. Did not end well. Nice work!
That's amazing. Wish it would take much less entdata though.
I've made a new version for people who're worried about entdata, it uses 25.1% but only has capital letters and numbers. I've included it along with the original which is now 58.2%. Here's what it looks like: [IMG]http://i50.tinypic.com/s28w2s.jpg[/IMG]
Jesus, that's [B]a lot[/B] of entities! Well worth it for someone who needs a non-code-based keypad like this, though.
Sorry, you need to Log In to post a reply to this thread.