Page 1 of 1

how to set a variable type as number?

Posted: Sat Mar 18, 2023 5:43 am
by caiyaozheng
when i use trigger Regex, i intend to get variable by doing the following:

regex(****(\d+)**)
dodge_current=matches[2]

if (\d+)=200, this can set the variable "dodge_current" to 200.

however the type of dodge_current is a string, so when i try to write an if syntax:

if dodge_current<300 then
end

---------not working.

only when i go to Variables and manually change type to number, then working.

QUESTION: how can i define "dodge_current" as a number, when the first time i use dodge_current=matches[2]?

thanks!

Re: how to set a variable type as number?

Posted: Sat Mar 18, 2023 2:14 pm
by demonnic
dodge_current = tonumber(matches[2])

Re: how to set a variable type as number?

Posted: Fri May 19, 2023 12:37 am
by caiyaozheng
thanks!