【发布时间】:2013-10-25 04:10:35
【问题描述】:
首先,很抱歉在短时间内提出了两个问题,但我解决了最后一个问题,所以我再次需要帮助。我正在使用 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
谢谢!
【问题讨论】:
-
什么是完整的回溯?你是怎么打印
chance的?请注意,print u"10"和print 10产生完全相同的输出。始终使用repr()(如print repr(chance))来诊断值。
标签: python int jython bukkit operand