Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Guess I'll comment my script some too... Start up of the program
- print("Welcome to mah calc!")
- print("This calculator cna only do + and - ...")
- function HandleCommand() -- functions must be declared before they are called, so moving functions up
- print("Please input a number!")
- local f = io.read()
- print("Please insert command.")
- local x = io.read()
- print("Please insert second number")
- local g = io.read()
- DoMath(f, x, g)
- end
- function DoMath(one, two, three)
- -- This will be called on startup. You want it to be called when you have handled a command. Moved to a function.
- if two == "+" then
- print("Your Input:" .. tostring( tonumber(one) + tonumber(three) )) -- you need to convert to numbers
- elseif two == "-" then
- print("Your answer is:" .. tostring( tonumber(one) - tonumber(three) ))
- elseif one == "-1" then
- print("Secret code found. Deploying nukes.")
- running = false
- end
- end
- local running = true
- while running do
- HandleCommand()
- end
Advertisement
Add Comment
Please, Sign In to add comment