Cheat Engine
The Official Site of Cheat Engine

Author Message
Nighthawyun
Cheater
Reputation: 0

Joined: 21 Jan 2019
Posts: 27

 Posted: Sat May 25, 2019 9:08 pm    Post subject: how to make calculator with string like "213 + 42 - 124 how? ex) string "899 + 6 - 33" to result "872" and ×, ÷ too
TheyCallMeTim13
Wiki Contributor
Reputation: 25

Joined: 24 Feb 2017
Posts: 733
Location: 'Merica

Posted: Sat May 25, 2019 9:46 pm    Post subject:

 Code: print(loadstring("return " .. "899 + 6 - 33")())

_________________
DaSpamer
Grandmaster Cheater Supreme
Reputation: 30

Joined: 13 Sep 2011
Posts: 1511

Posted: Sat May 25, 2019 10:28 pm    Post subject:

A bit safer way to accomplish this and more dynamic.
 Code: local action = {['+']= function(a,b)return a + b;end;             ['-']= function(a,b)return a - b;end;             ['*']= function(a,b)return a * b;end;             ['/']= function(a,b)return a / b;end;             ['//']=function(a,b)return a// b;end; --> math.floor equivalent             ['%']= function(a,b)return a % b;end;             ['^']= function(a,b)return a ^ b;end;       }; debug.setmetatable(0, {    __call = function(a, op)       if(action[op]) then          return function(b)             return action[op](a,b)          end       else          error("Wrong syntax", 2)       end    end }) function calculate(Param1,Op,Param2,...)    if (tonumber(Param1) and action[Op] and tonumber(Param2)) then       return calculate(((Param1) (Op) (Param2)),...);    end    return Param1; end local a = calculate(1,'+',2) --> 3 local b = calculate(3,'+',1,'*',2,'%',3) --> ((3+1) * 2 ) % 3 --> 2 Operations priority do not apply here!

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy!

http://forum.cheatengine.org/viewtopic.php?t=564919
Corroder
Grandmaster Cheater Supreme
Reputation: 33

Joined: 10 Apr 2015
Posts: 1284

Posted: Sun May 26, 2019 12:10 am    Post subject:

Here is my Calculator made using CE Lua script.
It's 95% finish. Some parts did not finish yet:

1. Radix for hex, oct, bin calculation environment
2. Date calculation / manipulating under 'Date/Time Unit Calculation Menu'
3. Offset and AOB manipulation if possible.

Plan to publish it if the project is done.

EDIT:

 Code: x = "899 + 6 - 33" func = assert(load("return " .. x)) y = func() print(y)  --> 872 x = "100 + 6 / 2" func = assert(load("return " .. x)) y = func() print(y)  --> 103  because 6/2 doing first then + 100 x = "(100 + 6) / 2" func = assert(load("return " .. x)) y = func() print(y)  --> 53  because (100+6) / 2 x = "100 + 6 * 2 - 2 / 2"  --- potensial confusion func = assert(load("return " .. x)) y = func() print(y)  --> 111 note = [[ Remember math logic rules for math operator: highest is PARENTHESES / BRACKET then is EXPONENT / SQUARE ROOT next is MULTIPLICATION / DIVISION lowest is ADDITION / SUBTRACTION So, the correct answer for "100 + 6 * 2 - 2 / 2" is level 1 = 6 x 2 = 12 level 2 = 2 / 2 = 1 level 3 = 100 result = 100 + 12 - 1 = 111 ]]

CRDRLuaCalc.JPG
Description:
 Corroder CE Lua Calculator
Filesize:  42.87 KB
Viewed:  1035 Time(s)

_________________
Stealing Code From Stolen Code...
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT - 6 Hours Page 1 of 1

 Jump to: Select a forum Cheat Engine----------------Cheat EngineCheat Engine MacOSCheat Engine Lua ScriptingCheat Engine ExtensionsCheat Engine TutorialsGeneral GamehackingAuto Assembler tutorialsPointer tutorialsGame specific tutorialsWebbrowser stuff related tutorialsConsole ModdingLUA Tutorials General Discussions----------------General DiscussionsArtComputer TalkRandom spamArt RequestsArt TutorialsWillekeurige RotzooiGuestsHorse Excrement Cheat Requests----------------Single player cheat request Cheat Engine Downloads----------------TablesTrainersAuto Assemble scripts Coding----------------Cheat Engine SourceCETC Server and ClientsDBVMPlugin developmentGeneral programmingBinariesCrackmesGeneral programming+Game Development2D Graphics3D ModelingGameplay designWeb Development Games----------------Flash GamesGaia OnlineStick Arena Hello Kitty Forums----------------Temp
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum