Jump to content

Forcar um calculo apartir de uma string


Recommended Posts

On 06/03/2022 at 11:54, Diogo FIh said:
Existe alguma funcao para forcar um calculo neste estilo ?
local teste = "123+44/22-33"
iprint(tonumber(teste))

Você pode utilizar o loadstring de Lua para isso. Veja o seguinte exemplo:

local teste = "123+44/22-33"
local final = loadstring('return '..teste)()
print(final) --output: 92

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...