• 🏆 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!

[JASS] Stacking Charges

Status
Not open for further replies.
I got this from a JASS site and im having trouble. Im new to JASS and when i try to enable the script it says: "Stack Charges needs an intilization function named 'InitTrig_Stack_Charges'." I dont know where it gos or how to get it to work...:sad:

(heres the script):
JASS:
function HasItemtype takes unit whichUnit, item this returns item
   local integer i = 0
   local item whichItem = null
   local integer itemType = GetItemTypeId(this)
   if whichUnit != null then
     loop
       exitwhen i > 6
       set whichItem = UnitItemInSlot(whichUnit, i)
       if GetItemTypeId(whichItem) == itemType and whichItem != this then
          return whichItem
       endif
       set i = i + 1
     endloop
   endif
   return null
endfunction

function StackItem takes unit whichHero, item whichItem returns nothing
   local item stack = HasItemtype(whichHero,whichItem)
   local integer itemCharges = GetItemCharges(stack)
   if stack != null and stack != whichItem and itemCharges > 0 then
       call SetItemCharges( stack, itemCharges+ GetItemCharges(whichItem))
       call RemoveItem( whichItem)
   endif
endfunction
 
Yes, to elaborate more, here is an example:
JASS:
function Trig_TT_Actions takes nothing returns nothing
//Actions//
endfunction

//=============--Line of separation--==============================================================
function InitTrig_TT takes nothing returns nothing//Init function//
    set gg_trg_TT = CreateTrigger(  )//Sets the trigger//
    call TriggerAddAction( gg_trg_TT, function Trig_TT_Actions )//Actions function call thingy//
   //Events//
   //Condition function call thingy//
endfunction
That is where all of the initialization modifications go so that you may register events and call the actions & condition functions etc.
 
Status
Not open for further replies.
Top