This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
mibac138's profile picture

[Question] Math

Started by mibac138, 13 February 2014 - 11:52 AM
mibac138 #1
Posted 13 February 2014 - 12:52 PM
Hello!

Is there a posibility to do math calculations in a string ? (ex. tArgs[1] = 12-2*2)
LBPHacker #2
Posted 13 February 2014 - 01:01 PM
It depends on what you call a string. In that example of yours
tArgs[1] = 12-2*2
there are no strings at all. Give us a less foggy explanation of what you are trying to do.
mibac138 #3
Posted 13 February 2014 - 01:25 PM
Do something like a calculator - u give input (ex. "12-2*2") and it counts how much it is.
Lyqyd #4
Posted 13 February 2014 - 01:32 PM
Yep, it's possible. The simplest way is to use loadstring. That will allow any executable Lua code to be run though, so it's probably a bad idea to use it if security matters in the least. There was another thread on this very recently that had some good information. Check that out as well.