Denny2399 8 Posted August 9, 2018 Share Posted August 9, 2018 Hello, Can anyone experienced help me out a little with this piece of code? It should consider number of bonuses when adding new, but it doesn't. Maybe the function attrcount is wrongly defined? The define checks if you can add bonus into an item and highlights with red or green. Spoiler def __CanAddItemAttr(self, dstSlotPos): dstItemVNum = player.GetItemIndex(dstSlotPos) if dstItemVNum == 0: return False item.SelectItem(dstItemVNum) if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR): return False attrCount = 0 for i in xrange(player.METIN_SOCKET_MAX_NUM): if player.GetItemAttribute(dstSlotPos, i) != 0: return True if attrCount<4: return False return False Link to comment Share on other sites More sharing options...
Premium ragem0re 155 Posted August 9, 2018 Premium Share Posted August 9, 2018 player.METIN_SOCKET_MAX_NUM think thats not a default constant. does it return ITEM_SOCKET_SLOT_MAX_NUM (3)? Link to comment Share on other sites More sharing options...
Denny2399 8 Posted August 9, 2018 Author Share Posted August 9, 2018 2 hours ago, ragem0re said: player.METIN_SOCKET_MAX_NUM think thats not a default constant. does it return ITEM_SOCKET_SLOT_MAX_NUM (3)? Well I've checked multiple roots with uiinventory script an there is the same code, can't find that constant anywhere too. Where can I find out what it returns? Link to comment Share on other sites More sharing options...
Premium ragem0re 155 Posted August 9, 2018 Premium Share Posted August 9, 2018 check your binary source code UserInterface\PythonPlayerModule.cpp 1 Link to comment Share on other sites More sharing options...
Denny2399 8 Posted August 9, 2018 Author Share Posted August 9, 2018 21 minutes ago, ragem0re said: check your binary source code UserInterface\PythonPlayerModule.cpp Should I use ATTRIBUTE_SLOT_MAX_NUM instead? Link to comment Share on other sites More sharing options...
Premium ragem0re 155 Posted August 9, 2018 Premium Share Posted August 9, 2018 where does the attrCount variable get changed in your code? Link to comment Share on other sites More sharing options...
Denny2399 8 Posted August 9, 2018 Author Share Posted August 9, 2018 11 minutes ago, ragem0re said: where does the attrCount variable get changed in your code? I don't understand python much, but it should be here: Spoiler if attrCount<(number of attributes): return False The variable is only present in the definition Link to comment Share on other sites More sharing options...
Honorable Member xP3NG3Rx 19670 Posted August 9, 2018 Honorable Member Share Posted August 9, 2018 The player.GetItemAttribute([slotWindow=INVENTORY,] slotPos, attrIndex) returns a tuple, don't forget. attrCount = 0 for i in xrange(player.ATTRIBUTE_SLOT_NORM_NUM): if player.GetItemAttribute(dstSlotWindow, dstSlotPos, i)[0] != 0: attrCount += 1 if attrCount < 4: return True return False 1 Link to comment Share on other sites More sharing options...
Denny2399 8 Posted August 9, 2018 Author Share Posted August 9, 2018 58 minutes ago, xP3NG3Rx said: The player.GetItemAttribute([slotWindow=INVENTORY,] slotPos, attrIndex) returns a tuple, don't forget. attrCount = 0 for i in xrange(player.ATTRIBUTE_SLOT_NORM_NUM): if player.GetItemAttribute(dstSlotWindow, dstSlotPos, i)[0] != 0: attrCount += 1 if attrCount < 4: return True return False You made new const for it right? Can you point me to how to do that too please? I would like to make one for normal bonus checking and 6/7 bonus checking. Link to comment Share on other sites More sharing options...
Denny2399 8 Posted August 10, 2018 Author Share Posted August 10, 2018 #up Still can't get it to work. Link to comment Share on other sites More sharing options...
Denny2399 8 Posted August 11, 2018 Author Share Posted August 11, 2018 #up Link to comment Share on other sites More sharing options...
Denny2399 8 Posted August 12, 2018 Author Share Posted August 12, 2018 #up Link to comment Share on other sites More sharing options...
OtherChoice 77 Posted August 13, 2018 Share Posted August 13, 2018 Both ITEM_ATTRIBUTE_SLOT_MAX_NUM and ITEM_SOCKET_SLOT_MAX_NUM are in Userinterface/GameType.h, and can be called as ATTRIBUTE_SLOT_MAX_NUM and METIN_SOCKET_MAX_NUM respectively within python scripts Spoiler enum { ITEM_SOCKET_SLOT_MAX_NUM = 3, ITEM_ATTRIBUTE_SLOT_MAX_NUM = 7, }; However sincerly i can't understand your code: attrCount = 0 //here you inizialize the constant for i in xrange(player.METIN_SOCKET_MAX_NUM): // for i in xrange(3): if player.GetItemAttribute(dstSlotPos, i) != 0: // GetItemAttribute: is this a custom function you made or are you using a incomplete type of the void //CPythonPlayer::GetItemAttribute(TItemPos Cell, DWORD dwAttrSlotIndex, BYTE * pbyType, short * psValue)? if so //it will check against ITEM_ATTRIBUTE_SLOT_MAX_NUM == 7 (it will return true for 5, 6 and 7th bonuses) return True if attrCount<4: //here if attrCount is 3, 2, 1 will return false is this intended? maybe attrCount>3 return False return False Link to comment Share on other sites More sharing options...
Denny2399 8 Posted August 13, 2018 Author Share Posted August 13, 2018 5 hours ago, OtherChoice said: Both ITEM_ATTRIBUTE_SLOT_MAX_NUM and ITEM_SOCKET_SLOT_MAX_NUM are in Userinterface/GameType.h, and can be called as ATTRIBUTE_SLOT_MAX_NUM and METIN_SOCKET_MAX_NUM respectively within python scripts Reveal hidden contents enum { ITEM_SOCKET_SLOT_MAX_NUM = 3, ITEM_ATTRIBUTE_SLOT_MAX_NUM = 7, }; However sincerly i can't understand your code: attrCount = 0 //here you inizialize the constant for i in xrange(player.METIN_SOCKET_MAX_NUM): // for i in xrange(3): if player.GetItemAttribute(dstSlotPos, i) != 0: // GetItemAttribute: is this a custom function you made or are you using a incomplete type of the void //CPythonPlayer::GetItemAttribute(TItemPos Cell, DWORD dwAttrSlotIndex, BYTE * pbyType, short * psValue)? if so //it will check against ITEM_ATTRIBUTE_SLOT_MAX_NUM == 7 (it will return true for 5, 6 and 7th bonuses) return True if attrCount<4: //here if attrCount is 3, 2, 1 will return false is this intended? maybe attrCount>3 return False return False The function was like this when I downloaded the client and so is in every client I tried to look into. It's part of the uiinventory.py where it checks if you can put item to destination item. I didn't edit this script in any way and should be then functional? But it's not. Even though I have a value of true it doesn't seem to work and numbers of attrCount don't change anything. I tried putting there elif with different value and return, still didn't succeed. It behaves like attrCount does nothing. I guess the function is incomplete as you say. Also, there should be true in my opinion as well if attrCount<4: return True else: return False Did not work. Link to comment Share on other sites More sharing options...
Premium ragem0re 155 Posted August 13, 2018 Premium Share Posted August 13, 2018 Please repeat once again, what exactly do you want? Maybe I can try to help with my limited python skills Link to comment Share on other sites More sharing options...
Denny2399 8 Posted August 13, 2018 Author Share Posted August 13, 2018 12 minutes ago, ragem0re said: Please repeat once again, what exactly do you want? Maybe I can try to help with my limited python skills My python skills are limited more than yours I bet Anyway.. I want the python script to check correctly if I can add a bonus into an item. When you hover with bonus over an item it should show green or red color, depending on if you can add it or not. The script is not correct, however, because it doesn't do so. Example: If I have 4 bonuses, it should be red when hovering with normal bonuses over it and green if not, but it's always green. Also when I have 4 bonuses I would like 5th bonus to show green and when you have 5 bonuses to mark it as red If 6/7.. you understand me don't you? Link to comment Share on other sites More sharing options...
OtherChoice 77 Posted August 13, 2018 Share Posted August 13, 2018 40 minutes ago, Denny2399 said: The function was like this when I downloaded the client and so is in every client I tried to look into. It's part of the uiinventory.py where it checks if you can put item to destination item. I didn't edit this script in any way and should be then functional? But it's not. Even though I have a value of true it doesn't seem to work and numbers of attrCount don't change anything. I tried putting there elif with different value and return, still didn't succeed. It behaves like attrCount does nothing. This is the function i have, as you can see the last part is different Spoiler def __CanAddItemAttr(self, dstSlotPos): dstItemVNum = player.GetItemIndex(dstSlotPos) if dstItemVNum == 0: return False item.SelectItem(dstItemVNum) if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR): return False attrCount = 0 for i in xrange(player.METIN_SOCKET_MAX_NUM): if player.GetItemAttribute(dstSlotPos, i) != 0: attrCount += 1 if attrCount<4: return True //THIS RETURNS TRUE if attrcount is 1,2,3 while in yours it will return false return False Link to comment Share on other sites More sharing options...
Premium ragem0re 155 Posted August 13, 2018 Premium Share Posted August 13, 2018 There's a function which colors the background, there you have to add this check(s). But first I need to find this function, maybe it's in the source. 1 Link to comment Share on other sites More sharing options...
OtherChoice 77 Posted August 13, 2018 Share Posted August 13, 2018 To be clear: your function __CanAddItemAttr(self, dstSlotPos) has a wrong false Spoiler if attrCount<4: return False replace with if attrCount<4: return True However this function will return true for bonus 1,2,3,4 and false for 5,6,7 and it is used to check whether you can add a bonus with reinforce item (vnum 71085). What was your goal? having reinforce item higlighting the item? Link to comment Share on other sites More sharing options...
Denny2399 8 Posted August 13, 2018 Author Share Posted August 13, 2018 3 hours ago, OtherChoice said: To be clear: your function __CanAddItemAttr(self, dstSlotPos) has a wrong false Hide contents if attrCount<4: return False replace with if attrCount<4: return True However this function will return true for bonus 1,2,3,4 and false for 5,6,7 and it is used to check whether you can add a bonus with reinforce item (vnum 71085). What was your goal? having reinforce item higlighting the item? I did edit it this way before, then I returned it back how it was:) I knew there has to be true, but even then it doesn't work how it should. I had it exactly the way you have it, but something is probably wrong. Anyway just to be sure I will try it again and report you back in a moment. EDIT: I used your function and the marking is red in every situation, even when I can add the bonus. Might something be wrong in my source? I'm using mainline released. Link to comment Share on other sites More sharing options...
Denny2399 8 Posted August 17, 2018 Author Share Posted August 17, 2018 #up Link to comment Share on other sites More sharing options...
Denny2399 8 Posted August 18, 2018 Author Share Posted August 18, 2018 #UP Link to comment Share on other sites More sharing options...
Denny2399 8 Posted August 22, 2018 Author Share Posted August 22, 2018 #UP Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now