how to set a variable type as number?

Post Reply
caiyaozheng
Posts: 15
Joined: Sat Mar 18, 2023 5:34 am

how to set a variable type as number?

Post 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!

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: how to set a variable type as number?

Post by demonnic »

dodge_current = tonumber(matches[2])

caiyaozheng
Posts: 15
Joined: Sat Mar 18, 2023 5:34 am

Re: how to set a variable type as number?

Post by caiyaozheng »

thanks!

Post Reply