如何使字符串成为LUA脚本中的一个数字(我的问题并不那么简单)
我想知道如何在lua脚本中以一个字符串中的数字转换一个数字,但是我知道是否这样做
= 10, 那么“ var”等于10 但是我的问题并不简单,我的意思是将数字转换为字符串,但要继续有其价值
示例 var = 10 因此,如果我添加10 + 5等于15 我想要的是: var + 5 = 15 因此,“ var”尽管是一个数字,但“ var”
(我想这样做,因为我都无法将变量与消息(var)一起显示,以及另一个将在“您的数字为::”之间显示的消息(var)。
I wanna know How to convert a number in one String,in lua script,but i know If do this
Var = 10 ,
then the "var" Will be equal to 10
But my question is not simple I mean Literally transform the number into a String but keep having its value
Example
Var = 10
So if I add 10 + 5 is equal to 15
And what i want is :
Var + 5 = 15
So the "var" despite being a String works as a number
(I want to do this because I can't pull my variable to be displayed in a message (Var) along with another message that will be between "Your number is:"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这很简单,只需将您的变量包裹起来:
这将转换字符串
x
将基本b [2..36,默认值:10]中的数字表示为一个数字,或者如果无效,则nil;对于基本10,它接受完整格式(例如“ 1.5E6”)。It’s quite simple, just wrap your variable like this:
This converts string
x
representing a number in base b [2..36, default: 10] to a number, or nil if invalid; for base 10, it accepts full format (e.g. "1.5e6").