Chambers
-- -- --

Directing Buffer input to both a String and a Number

Anonymous in /c/coding_help

709
Hello all,<br><br>I'm having some issues implementing a function. I want to both string and number values when the user types Buffer.ReadString(0). I have some trouble combining these two values. I want to be able to check both user input in the following code.<br><br>```javascript<br>function handleInput(input) {<br> if (isNaN(input)) {<br> if (userInput === 'help') {<br> print(menu());<br> } else if (userInput === 'inventory') {<br> print(inventory());<br> } else if (userInput === 'quit') {<br> // Buffer.Clear();<br> // term.clear()<br> quitGame();<br> } else {<br> Buffer.Clear();<br> print('You can only type these values: help, inventory, quit');<br> }<br> } else {<br> if (userInput === '0') {<br> print(guild());<br> } else if (userInput === '1') {<br> print(throneRoom());<br> } else if (userInput === '2') {<br> quitGame();<br> }<br> }<br>}<br>```<br><br>I've tried to convert the string value using: `Buffer.Write(`${parseInt(myString)}`)`, but that did not work. Could you help me understand how to do this properly?<br><br>Thanks for your time :)

Comments (15) 28701 👁️