| 08-03-2007, 10:35 AM | #1 |
This is my mini-bag system based of of using an ability and local variables handle variables to store items. The level of the ability dictates which "bag" you are in. Right now when I add this, the map crashes on save. Anyone find any errors? (logic or otherwise). JASS:function Trig_JJ_Change_Invent_Actions takes nothing returns nothing local unit caster = GetSpellAbilityUnit() local integer counter = 1 local integer itemamount local string currentbag local string switch2bag if ( GetSpellAbilityId() == 'A616') then if ( GetUnitAbilityLevel(caster,'A616') == 1) then call SetUnitAbilityLevel(caster,'A616',2) set currentbag = "a" set switch2bag = "b" else call SetUnitAbilityLevel(caster,'A616',1) set currentbag = "b" set switch2bag = "a" endif loop exitwhen (GetItemTypeId(UnitItemInSlotBJ(caster,counter)) == null) set counter = counter + 1 endloop set itemamount = counter - 1 call SetHandleInt(caster, currentbag + "itemamount", itemamount) if (itemamount != 0) then set counter = 1 loop exitwhen(counter > itemamount) call SetHandleInt(caster, currentbag + "slot" + I2S(counter), caster) endloop endif set counter = 1 loop exitwhen (counter > 6) call UnitRemoveItemFromSlot(caster,counter) endloop if (GetHandleInt(caster, switch2bag + "itemamount") != 0) then set counter = 1 loop exitwhen(counter > GetHandleInt(caster, switch2bag + "itemamount") call UnitAddItemById(caster,GetHandleInt(caster, switch2bag + "slot" + I2S(counter))) endloop endif endif set caster = null endfunction //=========================================================================== function InitTrig_JJ_Change_Invent takes nothing returns nothing set gg_trg_JJ_Change_Invent = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_JJ_Change_Invent, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddAction( gg_trg_JJ_Change_Invent, function Trig_JJ_Change_Invent_Actions ) endfunction |
| 08-03-2007, 10:56 AM | #2 |
Un-initialized varaibles, probably. Try doing this: JASS:local string currentbag = "" local string switch2bag = "" JASS:call SetHandleInt(caster, currentbag + "slot" + I2S(counter), caster) |
