generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Calculator Help

Previous Thread :: Next Thread 
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
22 Mar 2013 06:37 PM
Oh, ty... New knowledge everyday. I will archive it in my library of ways to conquer the world, in my crystal-growing dark, magical-tree-filled empire of skeletons, Viking ships, towers reaching the dark clouds of... darkness... and whatsoever.


But, since tonumber will either return a number or nil, won't it then be unnecessary to add the other "not"? Since it will just require more computing powah... J:>


- As, oboioboi, turned off party settings.
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
22 Mar 2013 06:39 PM
If you only include one not then it will return the OPPOSITE of the truth. It is essential that you invert the value enough so that it is equivalent to its original value.

ElectricBlaze • Programmer • Wiki Writer | http://wiki.roblox.com/index.php/User:ElectricBlaze
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
22 Mar 2013 06:42 PM
So this detects if its only a number?
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
22 Mar 2013 06:43 PM
It detects if it CAN be a number, so either 5 or "5" both qualify.

if not not tonumber(valuehere) then

And again, make sure you include both nots.

ElectricBlaze • Programmer • Wiki Writer | http://wiki.roblox.com/index.php/User:ElectricBlaze
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
22 Mar 2013 06:45 PM
Waitwhat.

We do agree that:
2 is a number.
Æ is not a number.
Right?

Since tonumber("2") will still return a value that's not considered false (ok, nil).


Ok, so the extra wait will simply turn nil to false, and all other value to true. To explain it in short terms.

I don't see why it should be the opposite though.


- As, 00:45 will give us a time. But if that time is not the GMT, then we need some functions.
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
22 Mar 2013 06:46 PM
So after I put not not and stuff do I put ~= nil?
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
22 Mar 2013 06:48 PM
Me head spins from the randomness.
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
22 Mar 2013 06:49 PM
~= nil is... self-explanatory.

All data types in Roblox can be converted to either true or false (if we take the big... frog-glasses or whatever you use on).

nil --> false
false --> false
true --> true
2 --> true
"a" --> true
"" --> true
{} --> true
ect.


- As, I will not bow for the frog queen. Not if you hunted me down.
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
22 Mar 2013 06:51 PM
It seems that I must use tables. My head hurts to much from trying to understands tonumber()
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
22 Mar 2013 07:00 PM
I won't allow you to do such. It will become more inefficient if you use tables. More computing powah.

I shall fix ur script vari soon, so don't leave!




- As, leave and my toe will eat you.
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
22 Mar 2013 07:04 PM
-----------------------------------------------------------------------------------------------

function Calculate()
local t = script.Parent
local c = t.Num1.Text
local g = t.Num2.Text
local cal = t.Answer
if not (tonumber(c) and tonumber(g)) then
cal.Text = "Invalid Equation"
return
end
local add = c + g
local sub = c - g
local mul = c * g
local div = c / g
local var = t.Variable.Text
if var == "+" then
cal.Text = "Answer is "..tostring(add)
elseif var == "-" then
cal.Text = "Answer is "..tostring(sub)
elseif var == "*" then
cal.Text = "Answer is"..tostring(mul)
elseif var == "x" then
cal.Text = "Answer is "..tostring(mul)
elseif var == "/" then
cal.Text = "Answer is "..tostring(div)
else
cal.Text = "Invalid Equation"
end
end

local e = script.Parent
e.Num1.Changed:connect(Calculate)
e.Num2.Changed:connect(Calculate)
e.Variable.Changed:connect(Calculate)
e.Answer.Changed:connect(Calculate)

-----------------------------------------------------------------------------------------------


- As, I am me. But I must say, I want to ride on a cloud like blaze... rod?
Report Abuse
chaoticregandpledge is not online. chaoticregandpledge
Joined: 04 Dec 2009
Total Posts: 2894
22 Mar 2013 07:04 PM
Dear god please just use this http://www.roblox.com/Calculator-item?id=87945335
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
22 Mar 2013 07:07 PM
Nu, I'm maeking mai own calculator. :3
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
22 Mar 2013 07:10 PM
I must nao analyze As8D's script randomly. And learn return.
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
22 Mar 2013 07:10 PM
@chaotic;
Can we type lua code into it? I see math library functions >_>


@everyone;

Instead of making calculators, help me make an API for chemistry and physics :O
Dat'z mawch moar intereztin!k

Wee vil ohm rublakz phawzikz wid ur neew AiPiiAiii!!!!



- As, whatz ai jawzt zait.
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
22 Mar 2013 07:16 PM
http://wiki.roblox.com/index.php/Return#Using_Return
http://wiki.roblox.com/index.php/Operators
http://wiki.roblox.com/index.php/Number
http://wiki.roblox.com/index.php/Function_Dump/Core_Functions#tonumber


Just a few links for you to roar with.
- As, we are bears. We are polar bears? No, I'd rather be a grizzly bear. I guess.
Report Abuse
chaoticregandpledge is not online. chaoticregandpledge
Joined: 04 Dec 2009
Total Posts: 2894
22 Mar 2013 07:46 PM
@As8D

Yes, but you're very limited. It only allows like, print and stoof.
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
22 Mar 2013 07:50 PM
I'm only 12, I dunno wut an API is.
Report Abuse
Previous Thread :: Next Thread 
Page 2 of 2Go to page: 1, [2] Prev
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image