首先,很抱歉在短时间内问了两个问题,但我解决了最后一个,所以我需要帮助。我正在用jython/python编写bukkit插件。。。我对python/jython还不太熟悉,我不知道自己在哪里犯了错误,请看下面的代码:
(everything is under class hween(PythonPlugin))
def CandyChance(self):
chance = self.cfg.getString("main.candydropchance") #this works, I tried to print it and result is 10 (which I entered in config before)
chancetotal = chance / 100
@hook.event("block.BlockBreakEvent", "HIGHEST")
def onBlockBreakEvent(event):
#something
chancetotal = pyplugin.CandyChance()
if("Random.nextDouble() <= %s"%chancetotal):
#do something
谢谢!
“它打印10”并不能告诉你它是什么类型的。可能是字符串
"10"
,而不是数字10
——正如您可能从方法名getString
中猜到的那样。你不能把一个字符串除以一个数字。试着做:相关问题 更多 >
编程相关推荐