• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] GUI error made by WE itself

Status
Not open for further replies.
Level 4
Joined
Jan 17, 2018
Messages
112
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?
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
It generated because you used a for loop. This is what for loops look like behind the scenes:

JASS:
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.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,223
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)
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.
 
Level 4
Joined
Jan 17, 2018
Messages
112
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.

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:
Level 13
Joined
Mar 24, 2013
Messages
1,105
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.
 
Level 7
Joined
Mar 10, 2013
Messages
366
  • 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)
 
Status
Not open for further replies.
Top