编辑雨量计皮肤的lua文件“你需要夹克” 在此代码的标题中获取错误
--[[ Given the current temperature, return the appropriate
string for the main string meter ]]
local function getMainString( temp )
local negation = (temp > Settings.Ss_Limit) and " don't" or ""
local summerwear = (temp < Settings.Ss_Limit) and (temp > Settings.Vest_Limit) and "shirt and shorts"
local innerwear = (temp < Settings.Vest_Limit) and (temp > Settings.Jacket_Limit) and "vest"
local southerwear = (temp < Settings.Jacket_Limit) and (temp > Settings.Coat_Limit) and "jacket"
local outerwear = (temp < Settings.Coat_Limit) and "coat"
return string.format("You%s need a %s", negation, (summerwear or innerwear or southerwear or outerwear))
end
应该根据温度给出正确的衣服。我尝试了不同的温度变化位置,我唯一得到错误的时候是温度超过Ss_limit。我没有太多的编码经验,所以提前谢谢你
答案 0 :(得分:0)
当temp
大于Settings.Ss_Limit
或等于Settings.*_Limit
中的任何一个时,summerwear
,innerwear
,southerwear
和{{ 1}}将是coatwear
。这使false
成为(summerwear or innerwear or southerwear or outerwear)
(布尔值)而不是导致错误的字符串。
可能的解决方法:
false
答案 1 :(得分:0)
您需要手动将布尔类型评估为字符串。
尝试一下,
string.format("You%s need a %s", negation, tostring(clothwear or summerwear or innerwear or southerwear or outerwear))