danthedeckie / simpleeval

Simple Safe Sandboxed Extensible Expression Evaluator for Python
Other
449 stars 85 forks source link

how do i set limits #98

Closed NeedNot closed 2 years ago

NeedNot commented 2 years ago

i want to use this to allow users to use their very own formula for my leveling bot so it will save people's formula as a string and then run it. ofc I want to limit it to math.

how would I make it only work with math and make sure it doesn't cause loops or very complex resource-intensive problems that take more than a second to process

TheTechRobo commented 2 years ago

You can overwrite the operators with functions that limit the max input values, just like how it's done internally with the exponent operator.

Not sure how to do it otherwise tho

shahriyardx commented 2 years ago

---------- comment removed by moderator ---------

TheTechRobo commented 2 years ago

Ok, good to know

shahriyardx commented 2 years ago

Not your solution. His idea is dumb. Becuse custom formula for exp is bad.

I can put a formula like old_xp + 99999 and then after getting 99999 xp change formula to old_xp + 10

So I got so many levels while others are lagging behind for no reason. So the rule should be same for all

TheTechRobo commented 2 years ago

I think they mean server owners can change the server's leveling speed.