1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The reforging of the races is complete. Come see the 14th Techtree Contest Results.
    Dismiss Notice
  4. It's time to choose your horse in the race - the 32nd Modeling Contest Poll is up!
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Solved] A minor problem

Discussion in 'Triggers & Scripts' started by CrueIIntentions, Apr 28, 2011.

  1. CrueIIntentions

    CrueIIntentions

    Joined:
    Jun 7, 2008
    Messages:
    440
    Resources:
    0
    Resources:
    0
    I have this script:
    JASS

    Code (vJASS):

    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.
     
  2. Raven0

    Raven0

    Joined:
    Oct 16, 2010
    Messages:
    878
    Resources:
    2
    Maps:
    2
    Resources:
    2
    pretty sure item slot indexes start at 0 and end at 5
     
  3. CrueIIntentions

    CrueIIntentions

    Joined:
    Jun 7, 2008
    Messages:
    440
    Resources:
    0
    Resources:
    0
    okay, that helps me with that part. But I still can only get one stackable item in slot 6 when inventory is full. Any ideas?


    +rep for the help ty
     
  4. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    if you have full inventory, you won't be able to pick up anymore items using that trigger...

    and I don't understand this:

    When item slots are full, I can only put one on the open slot

    -->if slots are full, how can you still have an open slot?
     
  5. dardas

    dardas

    Joined:
    Sep 12, 2008
    Messages:
    649
    Resources:
    0
    Resources:
    0
    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 ^^
     
  6. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    ahhh... basically to do that, you need to make every item have a power-up/tome version so that you can pick them up, then add the real item via triggers...
     
  7. CrueIIntentions

    CrueIIntentions

    Joined:
    Jun 7, 2008
    Messages:
    440
    Resources:
    0
    Resources:
    0
    How would you create the condition though, in case you didnt have the item?
     
  8. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    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)
     
  9. CrueIIntentions

    CrueIIntentions

    Joined:
    Jun 7, 2008
    Messages:
    440
    Resources:
    0
    Resources:
    0
    would this prove true even for purchasing items?
     
  10. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    yup, as long as all items that you could pick-up or buy are powerups...