• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Find the lowest value

Status
Not open for further replies.
Level 5
Joined
Dec 18, 2007
Messages
205
i think you have to check whether every value is smaller than the other ones.
so it will be a huge 'if then else' function
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
set them in an array variable
(Array[1] = Value1, Array[2] = Value2... etc)
JASS:
local integer Lowest = 100000000000000000000000000 // Make this BIGGER than the biggest value
local integer MaxIndex = 5 // Your amount of values
local integer Index = 1
loop
    exitwhen Index > MaxIndex
    if Array{Index} < Lowest then
        set Lowest = Array{Index}
    endif
    set Index = Index + 1
endloop

({Index} = [Index]
Because JASS tags are fucked up ATM)
 
Level 8
Joined
Aug 4, 2006
Messages
357
just corrected a few small things on Yixx's post. remember that arrays start with the index 0, and the amount of values in the array is not the same as the biggest index (usually amount of values = biggest index+1 unless you store stuff in random indexes)
JASS:
local integer Lowest = Array{0} //this is more efficient and i think that number you put in is greater than the biggest integer allowed
local integer NumValues = 5 // Your amount of values
local integer Index = 1
loop
    exitwhen Index >= NumValues
    if Array{Index} < Lowest then
        set Lowest = Array{Index}
    endif
    set Index = Index + 1
endloop
({Index} = [Index]
 
Level 19
Joined
Oct 29, 2007
Messages
1,184
Uhm ... I still pretty much suck at jass. What would I have to do if I want to use that detection system after these actions? : >

  • Actions
    • Custom script: local integer a
    • Custom script: local rect r
    • Custom script: set r = Rect ( 0, 0, 0, 0 )
    • Custom script: set a = 2048
    • Set tmp_loc = (Position of Player[(Player number of (Triggering player))])
    • Custom script: call SetRect ( r, GetLocationX(udg_tmp_loc) - (a * 0.5), GetLocationY(udg_tmp_loc) - (a * 0.5), GetLocationX(udg_tmp_loc) + (a * 0.5), GetLocationY(udg_tmp_loc) + (a * 0.5) )
    • Set tmp_group[1] = (Units in tmp_region matching ((Owner of (Picked unit)) Not equal to Player 5 (Yellow)))
    • Set tmp_integer = 0
    • Unit Group - Pick every unit in tmp_group[1] and do (Actions)
      • Loop - Actions
        • Set tmp_real_array[tmp_integer] = (Distance between (Position of Player[(Player number of (Triggering player))]) and (Position of (Picked unit)))
        • Set tmp_integer = (tmp_integer + 1)
tmp_real_array are the values I want to check.

I want to detect which units is closest to player which is a unit.
 
Status
Not open for further replies.
Top