需求
Quest_Des=‘Play %s Lucky Cards to get your reward!’
将%s中的内容替换为游戏中的数值,并改变数值颜色
实现
```lua
local txt=“2/10”
local newTxt=string.gsub( Quest_Des,"%%s","<color=#ffff4c>%%s</color>" )
des.text=string.format(newTxt,txt)
1. 使用string.gsub()将字符串中的%s替换为带有颜色标记的%s,注意需要使用%(转义字符)避免函数将%s识别为其他占位符操作。
2. 使用string.format将%s替换为其他数值
3. 附不同颜色编码http://www.doc88.com/p-140611094886.html