• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] A minor problem

Status
Not open for further replies.
Level 9
Joined
Jun 7, 2008
Messages
440
I have this script:

JASS:
function Trig_Max10_Conditions takes nothing returns boolean
    return GetItemType(GetManipulatedItem()) == ITEM_TYPE_CHARGED
endfunction

function Trig_Max10_Actions takes nothing returns nothing
    local integer index = 1
    local item charge = GetManipulatedItem()
    local unit u = GetTriggerUnit()
    loop
        exitwhen index > 6
        if ( GetItemTypeId( UnitItemInSlot(u, index))) == GetItemTypeId(charge) and UnitItemInSlot(u, index) != charge then
            if ( GetItemCharges(charge) + GetItemCharges(UnitItemInSlot(u, index))) <= 6 then
                if ( GetItemCharges(UnitItemInSlot(u, index)) < 6 ) then
                    call SetItemCharges( UnitItemInSlot(u, index), ( GetItemCharges(UnitItemInSlot(u, index)) + GetItemCharges(charge) ) )
                    call RemoveItem( GetManipulatedItem() )
                endif
            endif
        endif
        set index = index + 1
    endloop
endfunction

I had a couple problems testing this. when I picked up multiple items, item slot 1 only carried 1 charge while the others cariried a full 6.

Problem 2 : When item slots are full, I can only put one on the open slot. I dont understand why. I think perhaps because the inventory is full. But I cannot say. Is there any way I can get around this one?

Thanks in advance.
 
Level 11
Joined
Sep 12, 2008
Messages
657
what he means, that for example, he got 6 inventory slots,
and he tries picking a item which was gonna be stacked into another,
and it doesnt work, since inventory is full, he has to drop to 5 inventory slots,
then pick up item, then get the item he just dropped, so he got 6 again, and so on for every item he want to add to the stack, i guess using tomes is a bad idea, since every item as a tome would be a nightmare ^^
 
if you don't have the item, when you try to add it, it will drop automatically... just be sure that for the stack trigger, you use the event, A unit acquires an item...

I think you're thinking that what I said was stack up the item directly upon pick-up of the tome, which is false, because what you will do is add the item to the unit when you pick up the tome, so now, if the item is charged, it will fire your stacking trigger, so if you already have that kind of item, it would stack, if not, it will occupy a space (if there is any, else it will drop)
 
Status
Not open for further replies.
Top