ID:154992
 
Seeing as BYONDs default input alert didn't appeal to me, I made my own. The problem is that you can type in anything in the input. Is their a way to restrict anything besides numbers from being entered in the input?
AbdelJN wrote:
Seeing as BYONDs default input alert didn't appeal to me, I made my own. The problem is that you can type in anything in the input. Is their a way to restrict anything besides numbers from being entered in the input?

You cant restrict them from writing numbers in input, however you can do something to restrict posting the numbers using Findtext() proc
input() as num // I guess
In response to Avainer1 (#1)
Zaoshi wrote:
> input() as num // I guess
>

first thing I tried. If only it was that simple:/

Avainer1 wrote:
AbdelJN wrote:
Seeing as BYONDs default input alert didn't appeal to me, I made my own. The problem is that you can type in anything in the input. Is their a way to restrict anything besides numbers from being entered in the input?

You cant restrict them from writing numbers in input, however you can do something to restrict posting the numbers using Findtext() proc

Yeah I know, I was hoping for completely restricting though-_-
In response to AbdelJN (#3)
BYOND does not offer such stuff.
You can either use a browser window with a form input and Topic(), along with some javascript, or you can write your own system on the HUD (if it's for like PIN input, an on-screen keypad would be kinda cool).

Or you can just use the built-in input() as num.
In response to DarkProtest (#5)
DarkProtest wrote:
You can either use a browser window with a form input and Topic(), along with some javascript, or you can write your own system on the HUD (if it's for like PIN input, an on-screen keypad would be kinda cool).

Or you can just use the built-in input() as num.

Yeah, all of these work but not really what I'm trying to accomplish. I suggested number-only inputs but it hasn't been looked at yet-_-
In response to Avainer1 (#4)
Avainer1 wrote:
BYOND does not offer such stuff.

Bummer.
In response to AbdelJN (#3)
Why does input() as num not work exactly for what you're doing? What are you trying to do?
In response to LordAndrew (#8)
LordAndrew wrote:
Why does input() as num not work exactly for what you're doing? What are you trying to do?

I made custom alert and a custom input alert for my game. I'm using an interface input for the input alert. It has a password mask, multi-line, and "don't use this control for commands" toggles. Unfortunately no numbers only toggle.

I've tried input() as num but I was still able to type in letters. I went further as to type a word and hit enter using input() as num and all it does is give a runtime error. Sure it restricts whats entered, but I'd like it to completely restrict players from typing things besides numbers.

I'm using my own custom verb for my custom inputs default command.

        Input(n as num)
src.Input=n
In response to AbdelJN (#9)
That's your problem. Quit trying to change and customize input(). Just try something like this.

mob
player
verb
Input_Number()
var/num = input("Please input a Number") as num
src << "The number is [num]!"


That will work for you, every time. And restrict everything you type to only numbers.

What you're doing in the code you posted has nothing to do with what you want. This snippet:
Input(n as num)

means that when you call the proc Input(), it will be expecting you to call it with variable n as a number, this does not mean that it won't let you type whatever in for n before parsing it into the proc. So it won't restrict anything, just fail to read it when it does get around to parsing the variable n.
In response to Solomn Architect (#10)
Doesn't work, still the same issue. If I hit enter on my custom input when it's blank on the other hand, I get BYOND's default input and in there I can only type numbers. Not what I'm really looking for though. I really dislike the default input.
In response to AbdelJN (#11)
As far as I know, there's no way to create a custom UI input box and have it filter out text as it's being typed. You can, however, still have it filter out text as it's parsed by your processing code. If a player is asked to type in a number, and they type in letters as well, you can pop up a warning box saying, "Only numbers will be accepted!" or something of the sort.
In response to Solomn Architect (#12)
Solomn Architect wrote:
As far as I know, there's no way to create a custom UI input box and have it filter out text as it's being typed. You can, however, still have it filter out text as it's parsed by your processing code. If a player is asked to type in a number, and they type in letters as well, you can pop up a warning box saying, "Only numbers will be accepted!" or something of the sort.

Yeah I know, I guess I'll just do that until BYOND gets some sort of number-only toggle for inputs.
In response to AbdelJN (#13)
Feature Request it.
In response to Solomn Architect (#14)
Solomn Architect wrote:
Feature Request it.

Did like a week ago. Hasn't been looked at. That's why I've been wondering if their was some type of way to program it, but I guess it isn't possible-_-