How do I add a new jass trigger to an existing .j?

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

darkxion
Member
Posts: 57
Joined: April 26th, 2007, 7:53 pm

How do I add a new jass trigger to an existing .j?

Post by darkxion »

OK, so let's say I create a new trigger, and convert it to custom text. How can I add this trigger to an existing .j? I tried adding the trigger to a random spot in the .j, the map ran fine when I loaded it, but the trigger wouldn't work. Any help would be great, thanks.

Code: Select all

function Trig_Untitled_Trigger_001_Conditions takes nothing returns boolean
    if ( not ( GetItemOfTypeFromUnitBJ(GetTriggerUnit(), 'I00E') == GetManipulatedItem() ) ) then
        return false
    endif
    return true
endfunction

function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    call SetItemDroppableBJ( GetManipulatedItem(), true )
    call UnitRemoveItemSwapped( GetManipulatedItem(), GetTriggerUnit() )
    call UnitAddItemByIdSwapped( 'I00E', GetTriggerUnit() )
endfunction
User avatar
Xantan
Honorary wc3edit.net Traitor
Posts: 2507
Joined: February 1st, 2007, 4:11 pm
Location: NEVADA

Re: How do I add a new jass trigger to an existing .j?

Post by Xantan »

Need to call it in function main.

Need to list it in globals.

[globals]
trigger gg_untitled_gay_gui_trigger_001 = null


[functions]
Init Trig_gg_untitled_gay_gui_trigger_001()


thats the noob way.
darkxion
Member
Posts: 57
Joined: April 26th, 2007, 7:53 pm

Re: How do I add a new jass trigger to an existing .j?

Post by darkxion »

Firstly, owch (even though I am a noob). Secondly, thanks =P
User avatar
Xantan
Honorary wc3edit.net Traitor
Posts: 2507
Joined: February 1st, 2007, 4:11 pm
Location: NEVADA

Re: How do I add a new jass trigger to an existing .j?

Post by Xantan »

lol, np. let me know if you need any help.
darkxion
Member
Posts: 57
Joined: April 26th, 2007, 7:53 pm

Re: How do I add a new jass trigger to an existing .j?

Post by darkxion »

Well actually I had either posted wrong or just forgot the last part the first time, this is actually the entire trigger.

Spoiler:
function Trg_greed_Conditions takes nothing returns boolean
if ( not ( GetItemOfTypeFromUnitBJ(GetTriggerUnit(), 'I00E') == GetManipulatedItem() ) ) then
return false
endif
return true
endfunction

function Trig_greed_Actions takes nothing returns nothing
call SetItemDroppableBJ( GetManipulatedItem(), true )
call UnitRemoveItemSwapped( GetManipulatedItem(), GetTriggerUnit() )
call UnitAddItemByIdSwapped( 'I00E', GetTriggerUnit() )
endfunction

//===========================================================================
function InitTrig_greed takes nothing returns nothing
set gg_trg_greed = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_greed, EVENT_PLAYER_UNIT_USE_ITEM )
call TriggerAddCondition( gg_trg_greed, Condition( function Trig_greed_Conditions ) )
call TriggerAddAction( gg_trg_greed, function Trig_greed_Actions )
endfunction


I added

Code: Select all

trigger gg_trig_greed=null
to the globals, and added

Code: Select all

function InitTrig_greed takes nothing returns nothing
    set gg_trg_greed = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_greed, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddCondition( gg_trg_greed, Condition( function Trig_greed_Conditions ) )
    call TriggerAddAction( gg_trg_greed, function Trig_greed_Actions )
endfunction
in the functions

Than added the

Code: Select all

function Trig_greed_Conditions takes nothing returns boolean
    if ( not ( GetItemOfTypeFromUnitBJ(GetTriggerUnit(), 'I00E') == GetManipulatedItem() ) ) then
        return false
    endif
    return true
endfunction

function Trig_greed_Actions takes nothing returns nothing
    call SetItemDroppableBJ( GetManipulatedItem(), true )
    call UnitRemoveItemSwapped( GetManipulatedItem(), GetTriggerUnit() )
    call UnitAddItemByIdSwapped( 'I00E', GetTriggerUnit() )
endfunction
part in, and when I saved and did a syntax check, I got 2 errors.
Line 488: Undefined function.
Line 489: Undefined function.

Line 488 being

Code: Select all

call TriggerRegisterAnyUnitEventBJ( gg_trg_greed, EVENT_PLAYER_UNIT_USE_ITEM )

Line 489 being

Code: Select all

call TriggerAddCondition( gg_trg_greed, Condition( function Trig_greed_Conditions ) )


This is probably something simple, to someone with even a little skill with JASS =S
User avatar
trb92
Senior Member
Posts: 132
Joined: February 20th, 2007, 8:40 pm
Title: Random Noob
Location: Canada!!!

Re: How do I add a new jass trigger to an existing .j?

Post by trb92 »

Code: Select all

trigger gg_trig_greed=null

Should be

Code: Select all

trigger gg_trg_greed=null

In the globals, since gg_trg_greed is what your using later, not gg_trig_greed.
If you knew a woman who was pregnant, who had 8 kids already,
three who were deaf, two who were blind, one mentally retarded, and she had syphilis; would you recommend that she have an abortion?

Answer:
Spoiler:
If you said yes, you just killed Beethoven...
darkxion
Member
Posts: 57
Joined: April 26th, 2007, 7:53 pm

Re: How do I add a new jass trigger to an existing .j?

Post by darkxion »

trb92 wrote:

Code: Select all

trigger gg_trig_greed=null

Should be

Code: Select all

trigger gg_trg_greed=null

In the globals, since gg_trg_greed is what your using later, not gg_trig_greed.


Tried that too.

I think I need to "call" something, somewhere.
User avatar
JJ2197
Legendary Genius
Posts: 1311
Joined: August 8th, 2007, 8:10 am
Title: Legendary Genius²
Location: St. George Utah

Does anyone read these?

Post by JJ2197 »

Try this....

Code: Select all

function Trig_greed_Conditions takes nothing returns boolean
    if ( not ( GetItemOfTypeFromUnitBJ(GetTriggerUnit(), 'I00E') == GetManipulatedItem() ) ) then
        return false
    endif
    return true
endfunction
function Trig_greed_Actions takes nothing returns nothing
    call SetItemDroppableBJ( GetManipulatedItem(), true )
    call UnitRemoveItemSwapped( GetManipulatedItem(), GetTriggerUnit() )
    call UnitAddItemByIdSwapped( 'I00E', GetTriggerUnit() )
endfunction
function InitTrig_greed takes nothing returns nothing
    local trigger gg_trg_greed=null
    set gg_trg_greed = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_greed, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddCondition( gg_trg_greed, Condition( function Trig_greed_Conditions ) )
    call TriggerAddAction( gg_trg_greed, function Trig_greed_Actions )
endfunction
Computer Specs:
Motherboard: GA-990FXA-UD3
CPU: FX-8350 @ 4.0GHz
PSU: Corsair CX500
RAM: G.Skill Ripjaws X 8GB @ 1866
GPU: Radeon HD 4870 1GB
HDD: OCZ Vertex series 30GB SSD
Case: Antec 900
Monitor: Toshiba 32"
OS: Windows 7 Ultimate
darkxion
Member
Posts: 57
Joined: April 26th, 2007, 7:53 pm

Re: How do I add a new jass trigger to an existing .j?

Post by darkxion »

With that, do I need to add trigger gg_greed=null in the globals?
User avatar
JJ2197
Legendary Genius
Posts: 1311
Joined: August 8th, 2007, 8:10 am
Title: Legendary Genius²
Location: St. George Utah

Re: How do I add a new jass trigger to an existing .j?

Post by JJ2197 »

No, It's right in the functions as a local... though if you have the trigger in another function though (which I would imagine no) then yes you would want to put in globals...

And when you got the error I would assume you meant these were the errors...

Code: Select all

call TriggerAddCondition( gg_trg_greed, Condition( function Trig_greed_Conditions ) )
call TriggerAddAction( gg_trg_greed, function Trig_greed_Actions )
Computer Specs:
Motherboard: GA-990FXA-UD3
CPU: FX-8350 @ 4.0GHz
PSU: Corsair CX500
RAM: G.Skill Ripjaws X 8GB @ 1866
GPU: Radeon HD 4870 1GB
HDD: OCZ Vertex series 30GB SSD
Case: Antec 900
Monitor: Toshiba 32"
OS: Windows 7 Ultimate