• 🏆 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] The code doesn't run

Status
Not open for further replies.
Level 9
Joined
Sep 5, 2007
Messages
358
Hello!
I'm creating a new item shop system, but for the first tests it just didn't work. It actually didn't ran.
What it does is when a item is bought, it checks if it's the item I want and then stores the id of the item in a 2D array variable, in a slot which belongs to the team of the player.
I placed several debug messages across the code, but it didn't showed a single one. I guess it's another of my invisible bugs.

Here is the code I've made:

JASS:
library ItemShops
globals
    public constant integer iBlazzerId = 'I007'
    
    public integer array boughtItems [10][20]
    public integer array itemsIndex
endglobals

function ItemShops_Conditions takes nothing returns boolean
    call BJDebugMsg( "condition works" )
    return GetUnitTypeId( GetManipulatingUnit( ) ) == 'H002'
endfunction

function ItemShops_Actions takes nothing returns nothing
    local item i = GetManipulatedItem( )
    local integer id = GetItemTypeId( i )
    local integer p = GetPlayerId( GetOwningPlayer( GetTriggerUnit( ) ) )
    call BJDebugMsg( "actions works so far" )
    call RemoveItem( i )
    if id == iBlazzerId then
        call BJDebugMsg( I2S( itemsIndex ) )
        set boughtItems[itemsIndex] = iBlazzerId
        set itemsIndex = itemsIndex + 1
        call BJDebugMsg( I2S( boughtItems[itemsIndex] ) )
        call BJDebugMsg( I2S( itemsIndex ) )
    else
    endif
    
    set i = null
endfunction

//===========================================================================
function Init_ItemShops takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call BJDebugMsg( "Works" )
    call TriggerAddCondition( t, Condition( function ItemShops_Conditions ) )
    call TriggerAddAction( t, function ItemShops_Actions )
endfunction
endlibrary

I also tried to remove the library part and remove the public statements, but it worked out the same.

Thanks in advance!

Wizzy..
 
Status
Not open for further replies.
Top