Hello,
I'm still learning and now I'm stuck with this python function.. I'm not sure, how to debug it..
This code:
Code
- if item.ITEM_TYPE_PET == itemType:
- if itemSubType == item.PET_LEVELABLE:
- level = metinSlot[1]
- if level > 0:
- curPoint = metinSlot[2]
- if level >= 120:
- maxPoint = 2500000000
- else:
- maxPoint = constInfo.exp_table[level]
- curPoint = min(curPoint, maxPoint)
- curPoint = max(curPoint, 0)
- maxPoint = max(maxPoint, 0)
- self.AppendTextLine("Lv. %d"%level,self.SPECIAL_POSITIVE_COLOR)
- age_text = [localeInfo.PET_GUI_YOUNG, localeInfo.PET_GUI_WILD, localeInfo.PET_GUI_BRAVE, localeInfo.PET_GUI_HERO]
- self.AppendTextLine("%s : %s"%(localeInfo.PET_GUI_AGE,age_text[metinSlot[3]]),self.SPECIAL_POSITIVE_COLOR)
- self.AppendTextLine("%s : %.2f%%" % (localeInfo.TASKBAR_EXP, float(curPoint) / max(1, float(maxPoint)) * 100),self.SPECIAL_POSITIVE_COLOR)
- self.AppendSpace(5)
- #pet_bonus_types=[item.APPLY_MAX_HP,item.APPLY_ATTBONUS_MONSTER,item.APPLY_CRITICAL_PCT]
- #pet_bonus_value=[4000,20,10]
- for j in xrange(3):
- ptr = metinSlot[5+j]
- if ptr == 20:
- bonus_value = constInfo.pet_bonus_value[j]
- else:
- bonus_value = float(float(constInfo.pet_bonus_value[j])/constInfo.PET_BONUS_MAX_LEVEL) * ptr
- text = self.__GetAffectString(constInfo.pet_bonus_types[j],int(bonus_value))
- if text != None:
- text = text.replace(":","")
- index = text.find("+")
- if index == -1:
- index = text.find("%")
- if index == -1:
- index =0
- if not index <= 0:
- new_text = text[:index]
- new_text += " (Lv %d - %s)"%(ptr,text[index:])
- self.AppendTextLine(new_text,self.TYRANIS_TOOLTIP_COLOR)
- else:
- new_text = text
- new_text += " (Lv %d - +%d)"%(ptr,int(bonus_value))
- self.AppendTextLine(new_text,self.TYRANIS_TOOLTIP_COLOR)
- self.AppendSpace(5)
- for j in xrange(len(attrSlot)):
- if attrSlot[j][0] == 0 or attrSlot[j][0] == 99:
- continue
- self.AppendTextLine(constInfo.pet_skill_data[attrSlot[j][0]][0]+"(Lv"+str(attrSlot[j][1])+")",self.SPECIAL_TITLE_COLOR)
- self.AppendSpace(5)
- self.AppendTextLine(localeInfo.LEFT_TIME+ ": "+localeInfo.SecondToDHM(metinSlot[0]-app.GetGlobalTimeStamp()),self.SPECIAL_POSITIVE_COLOR)
Is giving me error:
Code
- 1117 01:18:04032 :: Traceback (most recent call last):
- 1117 01:18:04032 :: File "ui.py", line 2778, in OnOverInItem
- 1117 01:18:04032 :: File "ui.py", line 89, in __call__
- 1117 01:18:04032 :: File "ui.py", line 80, in __call__
- 1117 01:18:04032 :: File "uiInventory.py", line 1519, in OverInItem
- 1117 01:18:04032 :: File "uiInventory.py", line 1758, in ShowToolTip
- 1117 01:18:04032 :: File "uiToolTip.py", line 840, in SetInventoryItem
- 1117 01:18:04032 :: File "uiToolTip.py", line 1845, in AddItemData
- 1117 01:18:04032 :: IndexError
- 1117 01:18:04032 :: :
- 1117 01:18:04032 :: list index out of range
- 1117 01:18:04032 ::
I have tried to print out the index of:
Code
- for j in xrange(3):
- if 5 + j < len(metinSlot):
- ptr = metinSlot[5 + j]
- if j < len(constInfo.pet_bonus_value):
- if ptr == 20:
- bonus_value = constInfo.pet_bonus_value[j]
- else:
- if constInfo.PET_BONUS_MAX_LEVEL != 0:
- bonus_value = float(constInfo.pet_bonus_value[j]) / constInfo.PET_BONUS_MAX_LEVEL * ptr
- else:
- bonus_value = 0
- else:
- net.SendChatPacket("error: index j is out of range for pet_bonus_value")
- else:
- net.SendChatPacket("error: index 5 + j is out of range for metinSlot")
But I'm unable to work with it.. could anyone help me out to the right direction please?
Thanks!