1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Ride into the sunset with the 32nd Modeling Contest.
    Dismiss Notice
  4. This adventure has come to an end. Congratulate our heroes in the 16th Mini Mapping Contest Results.
    Dismiss Notice
  5. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  6. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Solved] GUI error made by WE itself

Discussion in 'Triggers & Scripts' started by Marcell, Mar 4, 2018.

  1. Marcell

    Marcell

    Joined:
    Jan 17, 2018
    Messages:
    112
    Resources:
    0
    Resources:
    0
    Hi all,

    I don't understand why GUI gives me an error with a script itself created:

    function Trig_Lay_Mines_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A005' ) ) then
    return false
    endif
    return true
    endfunction

    function Trig_Lay_Mines_Actions takes nothing returns nothing
    set udg_Miner = GetUnitLoc(GetSpellAbilityUnit())
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 5
    loop
    exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
    set udg_Miner2 = OffsetRectBJ(udg_Miner2, GetRandomReal(0, 250.00), GetRandomReal(0, 250.00))
    call CreateNUnitsAtLoc( 1, 'nglm', GetOwningPlayer(GetSpellAbilityUnit()), GetRectCenter(udg_Miner2), bj_UNIT_FACING )
    call RemoveLocation(udg_Miner2)
    set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    endfunction

    The "set bj_forLoopAIndex = bj_forLoopAIndex + 1" is not in my script so it's auto generated by the GUI, but it tells me "Invalid argument type (rect)

    What does this mean?
     
  2. KILLCIDE

    KILLCIDE

    Administrator

    Joined:
    Jul 22, 2015
    Messages:
    3,504
    Resources:
    20
    Models:
    2
    Icons:
    10
    Spells:
    7
    Tutorials:
    1
    Resources:
    20
    It generated because you used a for loop. This is what for loops look like behind the scenes:

    Code (vJASS):

    function ForLoop takes nothing returns nothing
        set bj_forLoopAIndex = 1
        set bj_forLoopAIndexEnd = 10
        loop
            exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
            set bj_forLoopAIndex = bj_forLoopAIndex + 1
        endloop
    endfunction
     


    Regardless, the loop isn't what is causing the error, it's this one:
    set udg_Miner2 = OffsetRectBJ(udg_Miner2, GetRandomReal(0, 250.00), GetRandomReal(0, 250.00))
    . OffsetRect expects the first argument to be a rect, not a location.
     
  3. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,930
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Caused by inconsistent variable type of udg_Miner2. In one place you use it as a rect, and in the other as a location. Rect and location are different types.

    Make sure the GUI variable Miner2 is being used correctly. You might find that in one or more of the actions it is no longer able to be selected.
     
  4. Marcell

    Marcell

    Joined:
    Jan 17, 2018
    Messages:
    112
    Resources:
    0
    Resources:
    0
    Err, I don't understand this French you speak xD. So here's the Trigger, I THINK I know what you mean:
    • Lay Mines
      • Events
        • Unit - A unit Finishes casting an ability
      • Conditions
        • (Ability being cast) Equal to Lay mines
      • Actions
        • Set Miner = (Position of (Casting unit))
        • For each (Integer A) from 1 to 5, do (Actions)
          • Loop - Actions
            • Set Miner2 = (Miner offset by ((Random real number between 0.00 and 250.00), (Random real number between 0.00 and 250.00)))
            • Unit - Create 1 Goblin Land Mine for (Owner of (Casting unit)) at (Center of Miner2) facing Default building facing degrees
            • Custom script: call RemoveLocation(udg_Miner2)


    Is it the random real number used twice?

    EDIT:
    Never mind, I fixed it:
    • Lay Mines
      • Events
        • Unit - A unit Finishes casting an ability
      • Conditions
        • (Ability being cast) Equal to Lay mines
      • Actions
        • Set Miner = (Position of (Casting unit))
        • For each (Integer A) from 1 to 5, do (Actions)
          • Loop - Actions
            • Unit - Create 5 Goblin Land Mine for (Owner of (Casting unit)) at (Miner offset by ((Random real number between 0.00 and 200.00), (Random real number between 0.00 and 200.00))) facing Default building facing degrees
        • Custom script: call RemoveLocation(udg_Miner)
     
    Last edited: Mar 5, 2018
  5. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,930
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Your "fix" leaks 5 locations per execution.
     
  6. Marcell

    Marcell

    Joined:
    Jan 17, 2018
    Messages:
    112
    Resources:
    0
    Resources:
    0
    So my custom script needs to be in the loop or is the "RemoveLocation" incorrect for a point integer?
     
  7. pOke

    pOke

    Joined:
    Mar 24, 2013
    Messages:
    1,104
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Not exactly, you need to save the Miner Offset by .... into a variable and clear it each loop.

    It will look this

    set someLocation
    loop
    set someLocation2 = someLocation offset by X toward Y
    Create Unit at someLocation2
    RemoveLocation(udg_someLocation2)
    endloop
    RemoveLocation(udg_someLocation)

    sorry for formatting,mobile.
     
  8. Hotwer

    Hotwer

    Joined:
    Mar 10, 2013
    Messages:
    370
    Resources:
    0
    Resources:
    0
    • Lay Mines
      • Events
        • Unit - A unit Finishes casting an ability
      • Conditions
        • (Ability being cast) Equal to Lay mines
      • Actions
        • Set Miner = (Position of (Casting unit))
        • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Set Miner2 = (Center of (Miner offset by ((Random real number between 0.00 and 250.00), (Random real number between 0.00 and 250.00))))
          • Unit - Create 1 Goblin Land Mine for (Owner of (Casting unit)) at Miner2) facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_Miner2)
        • Custom script: call RemoveLocation(udg_Miner)


    This is what @Dr Super Good was talking about:
    • Set Miner2 = Miner offset by ((Random real number between 0.00 and 250.00), (Random real number between 0.00 and 250.00)))

    This returns a Rect, therefore why RemoveLocation doesn't work.
    Also you need to remove the first region you saved (udg_Miner)