Conversion from GUI to JASS

n00b1l1ty

Lєgєπd of Mysтicfаlcoи
Reaction score
46
Can anyone convert this basic trigger GUI to simple and regular JASS code.

You know WE's "Convert to Custom Text" is very confusing.



Code:
deneme2
    Events
        Unit - A unit Acquires an item
    Conditions
        ((Item-type of (Item being manipulated)) Equal to Ring of Regeneration) or ((Item-type of (Item being manipulated)) Equal to Robe of the Magi +6)
    Actions
        Game - Display to (Player group((Owner of (Triggering unit)))) the text: You can not.
        Item - Remove (Item being manipulated)
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
JASS:
function Trig_dene2_Conditions takes nothing returns boolean
    return GetItemTypeId(GetManipulatedItem()) == ringId  or GetItemTypeId(GetManipulatedItem()) == robeId
    // replace ringId and robeId with the actual rawcode
endfunction

function Trig_dene2_Actions takes nothing returns nothing
    call DisplayTextToPlayer(GetOwningPlayer(GetTriggerUnit()), 0, 0, "You cannot")
    call RemoveItem(GetManipulatedItem())
endfunction

function InitTrig_dene2 takes nothing returns nothing
    set gg_trg_dene2 = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_dene2, EVENT_PLAYER_UNIT_PICKUP_ITEM)
    call TriggerAddCondition(gg_trg_dene2, Condition( function Trig_dene2_Conditions))
    call TriggerAddAction(gg_trg_dene2, function Trig_dene2_Actions)
endfunction


That should pretty much match your GUI equivalent.

Why do you want it to converted into JASS?
 

n00b1l1ty

Lєgєπd of Mysтicfаlcoи
Reaction score
46
Because I will add more items to the condition. And I'm thinking GUI will be hard to edit more items.

And thank you for helping.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
If you are planning to add more items, loads of them, I suggest you to replace the old condition with this one:

JASS:
function Trig_dene2_Conditions takes nothing returns boolean
    local integer id = GetItemTypeId(GetManipulatedItem())
    local integer n = 0
    loop
        exitwhen (n > udg_MAX_ITEM_COUNT)
        if (id == udg_DISALLOWED_ITEMS[n]) then
            return true
        endif
        set n = n + 1
    endloop
    return false
endfunction


You need to create two variables in the Variable Editor, "MAX_ITEM_COUNT" of integer type and "DISALLOWED_ITEMS" of item-type type, arrayed.

Yes, they both need to be in capital letters, unless you're planning to replace them in the condition itself with your variables.

Just set all the disallowed items into the array and finish the job by setting the "MAX_ITEM_COUNT" variable to the number of items in the array.
 

quraji

zap
Reaction score
144
Wouldn't that code get a syntax error for trying to compare two different types (since the DISALLOWED_ITEMS var is item-type, while id is integer)?

Many "id" types accept integer comparisons/assignments.
 

Strilanc

Veteran Scripter
Reaction score
42
It's actually easier to add item and unit type conditions in GUI, because you see the name instead of the ID.
 

dannyboydude

Ultra Cool Member
Reaction score
33
i guess the last commenter has not even thought about learning jass

well clicking buttons is all ok until you hav to do some realy complex spell and then you releise your buggered

im realy trying to learn jass because gui is sdoing my nut in lol

as someone said in another thread typing is quicker then clicking
 

Flare

Stops copies me!
Reaction score
662
i guess the last commenter has not even thought about learning jass
Rofl - Strilanc is (from what I've seen from his stuff at WC3C) pretty damn good at JASS :p

Anyway, he means you get to see the name of the item i.e.

Code:
Item-type of (Item being manipulated) equal to Ring of Protection +2
(or some other item)
rather than
JASS:
GetItemTypeId (GetManipulatedItem ()) == &#039;I000&#039; //Or whatever your item ID is. I think that&#039;s the function for item ID comparison <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top