• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] First Line Errors O.o

Status
Not open for further replies.
Level 4
Joined
Jun 8, 2007
Messages
97
JASS:
function Trig_Sounds takes item, (GetItemTypeId(GetManipulatedItem())) returns nothing
if (GetItemTypeId(GetManipulatedItem())) == 'I009' then
    call StopMusic( false )
    call PlaySound( "gg_snd_Poppin_Drums_1" )
    call VolumeGroupSetVolume( SOUND_VOLUMEGROUP_MUSIC, 100 )
elseif (GetItemTypeId(GetManipulatedItem())) == 'I00E' then
    call StopMusic( false )
    call PlaySound( "gg_snd_Poppin_Drums_2" )
    call VolumeGroupSetVolume( SOUND_VOLUMEGROUP_MUSIC, 100 )
elseif (GetItemTypeId(GetManipulatedItem())) == 'I008' then
    call StopMusic( false )
    call PlaySound( "gg_snd_Poppin_Drums_3" )
    call VolumeGroupSetVolume( SOUND_VOLUMEGROUP_MUSIC, 100 )
elseif (GetItemTypeId(GetManipulatedItem())) == 'I00F' then
    call StopMusic( false )
    call PlaySound( "gg_snd_Poppin_Drums_4" )
    call VolumeGroupSetVolume( SOUND_VOLUMEGROUP_MUSIC, 100 )
elseif (GetItemTypeId(GetManipulatedItem())) == 'I004' then
    call StopMusic( false )
    call PlaySound( "gg_snd_Rockin'_Drums_1" )
    call VolumeGroupSetVolume( SOUND_VOLUMEGROUP_MUSIC, 100 )
elseif (GetItemTypeId(GetManipulatedItem())) == 'I00G' then
    call StopMusic( false )
    call PlaySound( "gg_snd_Rockin'_Drums_2" )
    call VolumeGroupSetVolume( SOUND_VOLUMEGROUP_MUSIC, 100 )
elseif (GetItemTypeId(GetManipulatedItem())) == 'I00D' then
    call StopMusic( false )
    call PlaySound( "gg_snd_Rockin'_Drums_3" )
    call VolumeGroupSetVolume( SOUND_VOLUMEGROUP_MUSIC, 100 )
elseif (GetItemTypeId(GetManipulatedItem())) == 'I00C' then
    call StopMusic( false )
    call PlaySound( "gg_snd_Rockin'_Drums_4" )
    call VolumeGroupSetVolume( SOUND_VOLUMEGROUP_MUSIC, 100 )
elseif (GetItemTypeId(GetManipulatedItem())) == 'I000' then
    call StopMusic( false )
    call PlaySound( "gg_snd_Funky_Drums_1" )
    call VolumeGroupSetVolume( SOUND_VOLUMEGROUP_MUSIC, 100 )
elseif (GetItemTypeId(GetManipulatedItem())) == 'I001' then
    call StopMusic( false )
    call PlaySound( "gg_snd_Funky_Drums_2" )
    call VolumeGroupSetVolume( SOUND_VOLUMEGROUP_MUSIC, 100 )
elseif (GetItemTypeId(GetManipulatedItem())) == 'I002' then
    call StopMusic( false )
    call PlaySound( "gg_snd_Funky_Drums_3" )
    call VolumeGroupSetVolume( SOUND_VOLUMEGROUP_MUSIC, 100 )
elseif (GetItemTypeId(GetManipulatedItem())) == 'I003' then
    call StopMusic( false )
    call PlaySound( "gg_snd_Funky_Drums_4" )
    call VolumeGroupSetVolume( SOUND_VOLUMEGROUP_MUSIC, 100 )
elseif (GetItemTypeId(GetManipulatedItem())) == 'I007' then
    call StopMusic( false )
    call PlaySound( "gg_snd_Latino_Drums_1" )
    call VolumeGroupSetVolume( SOUND_VOLUMEGROUP_MUSIC, 100 )
elseif (GetItemTypeId(GetManipulatedItem())) == 'I00A' then
    call StopMusic( false )
    call PlaySound( "gg_snd_Latino_Drums_2" )
    call VolumeGroupSetVolume( SOUND_VOLUMEGROUP_MUSIC, 100 )
elseif (GetItemTypeId(GetManipulatedItem())) == 'I005' then
    call StopMusic( false )
    call PlaySound( "gg_snd_Latino_Drums_3" )
    call VolumeGroupSetVolume( SOUND_VOLUMEGROUP_MUSIC, 100 )
elseif (GetItemTypeId(GetManipulatedItem())) == 'I006' then
    call StopMusic( false )
    call PlaySound( "gg_snd_Latino_Drums_4" )
    call VolumeGroupSetVolume( SOUND_VOLUMEGROUP_MUSIC, 100 )
elseif (GetItemTypeId(GetManipulatedItem())) == 'I00B' then
    call StopMusic( false )
    call PlaySound( "gg_snd_Drum_Arrangement_1" )
    call VolumeGroupSetVolume( SOUND_VOLUMEGROUP_MUSIC, 100 )
else
call DoNothing()
endif
endfunction

//===========================================================================
function InitTrig_Sounds takes nothing returns nothing
    set gg_trg_Sounds = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Sounds, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddAction( gg_trg_Sounds, function Trig_Sounds )
endfunction

Did i use the trigger take thing correct?

WE gives errors for the first line, i want to fix that before anything else :)
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
The first line... it should be 'takes item <varName>, <type> <varName>

Not

'takes item, <code>'

Takes/Returns are only for functions you'll call externally. Basically, they're what go between the brackets when you call it via 'call myFunc(<myparams>)

Also, get rid of

'else
call DoNothing()'

it's absolutely useless.

Also, move StopMusic in front of the if-statement, since the same thing happens every time.

And move VolumeGroupSetVolume after the end of the if-statement.
 
Level 4
Joined
Jun 8, 2007
Messages
97
New Code

Okay, say i call a function that returns an integer, how do i use that returned integer?

I'm trying to use it in an array, or local variable, or something >.< Here's the new code im trying

JASS:
function integerreturn takes nothing returns integer
if ( GetItemTypeId(GetManipulatedItem() ) ) == 'I000' then
return 1
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I001' then
return 2
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I002' then
return 3
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I003' then
return 4
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I007' then
return 5
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I00A' then
return 6
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I005' then
return 7
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I006' then
return 8
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I009' then
return 9
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I00E' then
return 10
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I008' then
return 11
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I00F' then
return 12
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I004' then
return 13
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I00G' then
return 14
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I00D' then
return 16
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I00C' then
return 17
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I00B' then
return 18
endif
return 0
endfunction

function Sounds takes nothing returns nothing
    local integer RandomSoundsArrayIndex = function integerreturn
call ClearMapMusicBJ()
call StopSoundBJ( GetLastPlayedSound(), false )
call StopMusicBJ( false )
call PlaySoundBJ( udg_RandomSounds[RandomSoundsArrayIndex] )
endfunction

function InitTrig_Sounds takes nothing returns nothing
    set gg_trg_Sounds = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_ounds, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddAction( gg_trg_Sounds, function Trig_Sounds )
endfunction

I don't get how to use the first function in the second function, i guess i was never taught that :p, and now i can't seem to figure it out, first line in the second function doesn't work, i know XD
 
Last edited:
Level 4
Joined
Jun 8, 2007
Messages
97
And what happens with the returned integer value?

edit; okay, i got it, here's the updated code

JASS:
function integerreturn takes nothing returns integer
if ( GetItemTypeId(GetManipulatedItem() ) ) == 'I000' then
return 1
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I001' then
return 2
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I002' then
return 3
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I003' then
return 4
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I007' then
return 5
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I00A' then
return 6
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I005' then
return 7
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I006' then
return 8
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I009' then
return 9
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I00E' then
return 10
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I008' then
return 11
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I00F' then
return 12
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I004' then
return 13
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I00G' then
return 14
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I00D' then
return 16
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I00C' then
return 17
elseif ( GetItemTypeId(GetManipulatedItem() ) ) == 'I00B' then
return 18
endif
return 0
endfunction

function Sounds takes nothing returns nothing
    local integer i = integerreturn() 
call ClearMapMusic()
call StopSound( GetLastPlayedSound(), false, false )
call StopMusic( false )
call PlaySoundBJ( udg_RandomSounds[i] )
endfunction

function InitTrig_Sounds takes nothing returns nothing
    set gg_trg_Sounds = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Sounds, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddAction( gg_trg_Sounds, function Sounds )
endfunction
 
Last edited:
Status
Not open for further replies.
Top