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
 

Re: World's shortest Lua calculator?

Previous Thread :: Next Thread 
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
24 Feb 2014 11:15 PM
Could be shorter, but I made it loop :P

function f(str) loadstring(([[a = %s]]):format(str))() return a end function get() local x = io.read() tostring(x) print(f(x)) get() end get()
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
24 Feb 2014 11:21 PM
repeat print(loadstring('return ' .. io.read())()) until false
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
24 Feb 2014 11:23 PM
it errors about io..what is io?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
24 Feb 2014 11:24 PM
This is standard Lua, not Rbx.Lua.
io is a library(?) used to retrieve input and spit output from command line or file system.
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
25 Feb 2014 05:56 PM
Well, I turned it into this:

repeat loadstring(([[print(%s)]]):format(io.read()))() until false
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
25 Feb 2014 06:20 PM
@island

If you have an iPod/iPhone/iPad get the app TouchLua, io.read() is a way of getting input, example;

print("Calculator, input number 1;")
n1 = io.read()
n1 = tonumber(n1) --Not sure if this is nessecary if they input a number, but who cares.
print("Input number 2;")
n2 = io.read()
n2 = tonumber(n2) --Not sure if this is nessecary if they input a number, but who cares.
print("Operator +, -, /, *")
Op = io.read()
if Op == "+" then
ans = n1 + n2
elseif Op == "-" then
ans = n1 - n2
elseif Op == "/" then
ans = n1 / n2
elseif Op == "*" then
ans = n1 * n2
end
print(ans)

--Yes I know this is inefficient, Your calculator works better I'd say.
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
25 Feb 2014 06:26 PM
if you make until false into until nil it becomes 2 characters shorter.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
25 Feb 2014 06:35 PM
Here's a short calculator, type this into command line;

print(n1 operator n2)

Example;

print(5 + 6)


Do I get extra points for stating the obvious!?!? Lol
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
25 Feb 2014 09:53 PM
lol,its rather easy..
ive used roblox for calculator b4
print (1+685478954/576)
lol
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
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