代码必须是一个浮点数,所以如何将其转换为整数

时间:2013-11-05 05:14:49

标签: python type-conversion

import sys

def setup(core, actor, buff):
    core.skillModService.addSkillMod(actor, 'expertise_damage_all', 10)
    core.skillModService.addSkillMod(actor, 'expertise_action_all', 10)
    core.skillModService.addSkillMod(actor, 'movement_resist_snare', 100)
    core.skillModService.addSkillMod(actor, 'movement', 0.5)
    return

def removeBuff(core, actor, buff):
    core.skillModService.deductSkillMod(actor, 'expertise_damage_all', 10)
    core.skillModService.deductSkillMod(actor, 'expertise_action_all', 10)
    core.skillModService.deductSkillMod(actor, 'movement_resist_snare', 100)
    core.skillModService.deductSkillMod(actor, 'movement', 1)
    return

我收到了一个错误:

File "scripts/buffs/of_charge_1.py", line 7, in setup
    core.skillModService.addSkillMod(actor, 'movement', 0.5)
TypeError: addSkillMod(): 3rd arg can't be coerced to int

在主代码Java中,我将它设置为浮点数,否则它将无法工作,所以我在这里尝试将其设置为整数但我仍然坚持我应该做的事情,使它成为一个整数

2 个答案:

答案 0 :(得分:0)

不只是......

a = 0.5
print int(a)
>>> 0

答案 1 :(得分:0)

你可以尝试施放它。

core.skillModService.addSkillMod(actor, 'movement', int(0.5))