1. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  2. The Melee Mapping Contest #4: 2v2 - Results are out! Step by to congratulate the winners!
    Dismiss Notice
  3. We're hosting the 15th Mini-Mapping Contest with YouTuber Abelhawk! The contestants are to create a custom map that uses the hidden content within Warcraft 3 or is inspired by any of the many secrets within the game.
    Dismiss Notice
  4. The 20th iteration of the Terraining Contest is upon us! Join and create exquisite Water Structures for it.
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice

[Trigger] Owner of local unit not detected?

Discussion in 'Triggers & Scripts' started by Fakuspakus, Jan 14, 2019.

Tags:
  1. Fakuspakus

    Fakuspakus

    Joined:
    Dec 25, 2018
    Messages:
    75
    Resources:
    0
    Resources:
    0
    • Custom script: local unit udg_Devour_Caster
    • Set Devour_Caster = (Triggering unit)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (((Owner of Devour_Caster) Equal to Player 1 (Red)) or ((Owner of Devour_Caster) Equal to Player 2 (Blue))) or (((Owner of Devour_Caster) Equal to Player 3 (Teal)) or (((Owner of Devour_Caster) Equal to Player 4 (Purple)) or ((Owner of Devour_Caster) Equal to Player 5 (Yellow))))
      • Then - Actions
      • [...]
    • Custom script: set udg_Devour_Caster= null


    So my problem here is that if I make unit a local, condition is not getting detected.
    If I remove custom script part then condition is met, but I need unit there to be local.
    Any ideas?
     
  2. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,243
    Resources:
    6
    Models:
    1
    Icons:
    1
    Spells:
    3
    JASS:
    1
    Resources:
    6
    Hmm, I suggest using a unique local variable instead of a shadowed global variable.

    The global variable will be assigned, and the local variable will copy the value of the global. After the conditional statement, set the value of the global variable to that of the local variable.

     
  3. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,420
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    it looks okay at first glance. Try adding a line "Game - Display text..." after you set devour caster to display the name of the unit, and also add another message in the Then - Actions and Else - Actions.

    I have a feeling something else is the issue. Post the rest of your trigger if you can.
     
  4. apsyll

    apsyll

    Joined:
    Aug 28, 2015
    Messages:
    184
    Resources:
    1
    Maps:
    1
    Resources:
    1
    The issue is that the trigger checks the if conditions in another function and so don't has access to the local variable of the original function.
    You can work around by creating your own if with custom script as well.
    • Custom script: local unit udg_Devour_Caster = GetTriggerUnit()
    • Custom script: local player udg_Devour_Caster_Player = GetOwningPlayer(udg_Devour_Caster)
    • Custom script: if (udg_Devour_Caster_Player == Player(0) or udg_Devour_Caster_Player == Player(1) or udg_Devour_Caster_Player == Player(2) or udg_Devour_Caster_Player == Player(3) ) then
    • Unit - Explode Devour_Caster
    • Player - Set Devour_Caster_Player Current gold to 750
    • Custom script: endif
    • Custom script: set udg_Devour_Caster = null
    • Custom script: set udg_Devour_Caster_Player = null
     
  5. Fakuspakus

    Fakuspakus

    Joined:
    Dec 25, 2018
    Messages:
    75
    Resources:
    0
    Resources:
    0
    Thanks for help guys.
    This worked like a charm for me. :)