Thanks in advance,
[indent=3]Shnup :)/>/>[/indent]
(P.S. Thankyou dan200 for the colour api, my game looked boring in black and white)
number = math.floor(number)
You could just simply round the number down. Just use:number = math.floor(number)
Make sure you change 'number' to whatever the input variable is.
that would leave me having to do infinite code, as i would have to go:Can't you check if the number is between a whole number, because if it is, it will have a decimal
if numbermin > 2 and numbermin < 3 then
if numbermin > 1 and numbermin < 2 then
if numbermin > 3 and numbermin < 4 then
etc. I would have to do it infinite times, as they enter what number it is so it can be anything.that would leave me having to do infinite code, as i would have to go:Can't you check if the number is between a whole number, because if it is, it will have a decimalif numbermin > 2 and numbermin < 3 then
if numbermin > 1 and numbermin < 2 then
etc. I would have to do it infinite times, as they enter what number it is so it can be anything.if numbermin > 3 and numbermin < 4 then
I didn't quite think about that before I posted :)/>/>
No, not 'derp'. I have barely ever used math equations in my previous programs. Hell, nearly all of my previous programs have involved a password to get into something. I am new to all this math.(insert thing here) crap. What does it even do anyway? I can't learn anything if i don't know why it does what it does. Oh, and you spelled should wrong.derp?
math.floor(val)==val
sould work :3
math.floor rounds down and basically removes everything in the decimal placeNo, not 'derp'. I have barely ever used math equations in my previous programs. Hell, nearly all of my previous programs have involved a password to get into something. I am new to all this math.(insert thing here) crap. What does it even do anyway? I can't learn anything if i don't know why it does what it does. Oh, and you spelled should wrong.derp?
math.floor(val)==val
sould work :3
As I have said before:math.floor rounds down and basically removes everything in the decimal place
a similar function math.ceil rounds up, so if there are any decimals, it will add up instead
both of these functions are verry usefull
Thanks, but what if I want a message to display when they've entered a certain character.
Oh God…then you need to recode the read function to check for certain chars
put your code somewhere under the os.pullEvent function
*watches toasty move away to a place called the infinite sadness**puts on sad, grayscale face :C*
He's trying to figure out how to check for a decimal place. It's not exactly helpful to tell him to recode it if he doesn't know how.
You could just simply round the number down. Just use:number = math.floor(number)
Make sure you change 'number' to whatever the input variable is.
Thanks, but what if I want a message to display when they've entered a certain character.
input = read()
if string.find(input, "%.") then
print("You entered a period!")
end
You can use string.find().input = read() if string.find(input, "%.") then print("You entered a period!") end
He's trying to figure out how to check for a decimal place. It's not exactly helpful to tell him to recode it if he doesn't know how.You could just simply round the number down. Just use:number = math.floor(number)
Make sure you change 'number' to whatever the input variable is.
Thanks, but what if I want a message to display when they've entered a certain character.
You can use string.find().input = read() if string.find(input, "%.") then print("You entered a period!") end
I have used tonumber() so that it only takes in numbers, not words. But it takes in 8.3 or 1.9 or 5.4 as a number, so tonumber() didn't stop that. i was trying to make it print some text on the screen etc. when you entered in a decimal point inside your input somewhere. This has now be solved and I am requesting a topic lock.To be honest rather than blacklisting any character you should check if tonumber() works on it first - if it is nil then it is not a number. You should then check that if you math.floor() it that it is the same number - if it's not then the number is invalid.