| 05-13-2009, 12:38 PM | #1 |
Hi, you see me desperat I got an error in this method, and I can't find this error. JASS:method RefreshHand takes nothing returns nothing local integer i = 0 call BJDebugMsg("ok Anfang Refresh, " + I2S(.Hand.Parts)+ " items da") loop exitwhen i == 5 call RemoveItem(.Inventar[i]) set .Inventar[i] = null set i = i+1 endloop call BJDebugMsg("nach erster Loop") set i = (.InvSeite*5) - 5 //anfang aktueller inventar seite loop exitwhen i == .InvSeite*5 //ende aktueller inventar seite if(i < .Hand.Parts) then set .Inventar[i] = UnitAddItemById(.Unit, .Hand.at(i)) endif set i = i+1 endloop call BJDebugMsg("Ende func") endmethod First, what happens: I got the first DebugMsg as much as i got Items in my Inventar, after that, the both others come in turn. After that the inventar is empty or it's filled with one and the same item 6 times. And the List, i got running (.Hand) is empty. This method is part of astruct, i use for my symbolising my hero. If u need some other Informations, pls ask for it. PS: It's for shure that the error does not occur outside the method, cause i call a debug message bevor and after the method, and those 2 Messages build a cover arround that Chaos, that the method produces. I also tried first to drop the item, but no effect, same problem. I hope u can help. Uzaku |
| 05-13-2009, 01:14 PM | #2 |
So what exactly is it supposed to do? Replace the unit's inventory with a previously stored array of items? You might want to look into this little system by Vexorian: http://www.wc3c.net/showthread.php?t=74278 So you don't have to completely rewrite it from scratch... If you still want to make your own system though: First you don't need this line: set .Inventar[i] = null Struct members don't need to be nulled and the variable will automatically return null once the item is removed. If the wrong items get added or none at all you should probably take a look at the .Hand.at method as that one determines the items added. PS: I'm so digging your Denglisch... awesome. |
| 05-13-2009, 01:35 PM | #3 |
I hope u mean the Denglish in the Source and not, the Posting xD This map will be a YU-GI-OH Game. And because you can have more then 6 Cards on ur hand, i need more then 6 Inventory palces. And this method is calles everytime, when there is a change in the Hand, so, the inventar get Updated. I allready took a look at Vexorians system, its big, too big for me, and i simply like to write this myself. The problem here is that it doesnt make a sence. JASS:call BJDebugMsg("ok Anfang Refresh, " + I2S(.Hand.Parts)+ " items da") loop exitwhen i == 5 call RemoveItem(.Inventar[i]) set .Inventar[i] = null set i = i+1 endloop And here is the List::at method: JASS:method at takes integer where returns integer return LL_GetListItem(.MainList, where) endmethod PS: Cause u know it's Denglish, u must know German, so I must ask: Warum bist du wegen meinem Denglish am graben?? |
