| 11-14-2006, 03:10 AM | #1 |
I have a problem with item stacking (charged items) and Vexorian told me to post a new thread about it instead of asking personally :). I got this code, but it gave me 2 errors. I am trying to understand it, but JASS language is a bit different from GUI so it's pretty hard JASS:function ReplaceItem takes nothing returns nothing local unit u = GetTriggerUnit() local item x = GetManipulatedItem() local item xx local integer cx = GetItemCharges(x) local integer d local integer i = 1 if cx > 0 then loop exitwhen i > 6 set xx = UnitItemInSlotBJ(u,i) if x != xx and ix == GetItemTypeId(xx) then set d = GetItemCharges(xx) + cx call SetItemCharges(xx,d) call RemoveItem(x) endif set i = i + 1 endloop endif set u=null set x=null set xx=null endfunction //=========================================================================== function InitTrig_Item_Stacking takes nothing returns nothing local trigger d = CreateTrigger() call TriggerRegisterAnyUnitEventBJ( d, EVENT_PLAYER_UNIT_PICKUP_ITEM ) call TriggerAddAction( d, function ReplaceItem ) set d = null endfunction It kept asking me for 2 things: 1 "expected endloop" and 1 "expected name". Here're screenshots of what it says: http://zenixstudios.com/files/4b8triggererror1.jpg http://zenixstudios.com/files/458triggererror2.jpg FYI I use WE Unlimited, Widgetizer, and Vexorian's Optimizer. Thanks a lot. |
| 11-14-2006, 04:01 AM | #2 |
Well it is better to do this in GUI, check out the resource section recipe sys, made by shadow, it has an item stacking function in GUI. -Av3n |
| 11-14-2006, 04:42 AM | #3 |
You have a variable ix in the second if statement. Fix the typo and it should work. |
| 11-14-2006, 12:55 PM | #4 |
Jazradel is right. JASS:function ReplaceItem takes nothing returns nothing local unit u=GetTriggerUnit() local item x=GetManipulatedItem() local item t local integer c=GetItemCharges(x) local integer y=GetItemTypeId(x) local integer i=0 if (c>0) then loop set t=UnitItemInSlot(u,i) if ( ( x!=t ) and ( y==GetItemTypeId(t) ) ) then call SetItemCharges(t,GetItemCharges(t)+c) call RemoveItem(x) endif set i=i+1 exitwhen (i>5) endloop endif set u=null set x=null set t=null endfunction function InitTrig_Item_Stacking takes nothing returns nothing local trigger d = CreateTrigger() call TriggerRegisterAnyUnitEventBJ( d, EVENT_PLAYER_UNIT_PICKUP_ITEM ) call TriggerAddAction( d, function ReplaceItem ) set d = null endfunction Your only 'real' mistake was a typo. I removed the BJ function. It should work now quite will. @Av3n: It's better try learning jass than always requireing the help of others. And if at the process of learning, some questions appear, I am happy to help the guy to learn it, but if he just wants the finished, ready to use, code, I am not gonna help that guy again, ecept he changes his mind. |
| 11-14-2006, 02:13 PM | #5 |
Thanks so much guys! +reps for everyone. |
