• 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.

custom scripts

Status
Not open for further replies.
Level 7
Joined
Jan 29, 2010
Messages
213
Hi all. I have some questions here, I about array in custom scripts.
I want to RemoveLocation witch variable point has an array, how does custom script has to look?

Here's an example without array:
  • Custom script: call RemoveLocation (udg_p)
I need something more like this:
  • Custom script: call RemoveLocation (udg_p[(Player number of (Triggering player))])
I didin't found anything like this.
 
Level 7
Joined
Jan 29, 2010
Messages
213
Just pass the value of the array variable to a single variable. There is really no point giving you that one specific line and you do not know what the next function looks like. Arrays are denoted by <var>[<index>] in jass, so you can also enter a variable as index.

If my trigger is used by 2 players at one moment and it removes wrong location? so I need some examples how to make it without any leaks :/

Id like to get some examples of working custom scripts with array, like this:
  • Custom script: call RemoveLocation (udg_p[1])
  • Custom script: call RemoveLocation (udg_p[<1>])
 
Level 7
Joined
Jan 29, 2010
Messages
213
set variable = player number of ...
Custom script: call RemoveLocation(udg_p[udg_variable])

You might as well post the whole trigger, it may turn out that you don't even need an array.

I don't need by now an array, but I wan't to now my self how does array has to look on custom cripts. If I doing actions like this:
  • Actions
    • Set p[(Player number of (Triggering player))] = ((Triggering player) start location)
    • Unit - Create 1 Footman for (Triggering player) at p[(Player number of (Triggering player))] facing Default building facing degrees
    • Custom script: call RemoveLocation (udg_p[<...>])
(I like all my triggers to be multiple to make sure they never fails even after 100times reapiting almost at same time)
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
  • Actions
    • Set integerVariable = (Player number of (Triggering player))
    • Set p[integerVariable] = ((Triggering player) start location)
    • Unit - Create 1 Footman for (Triggering player) at p[integerVariable] facing Default building facing degrees
    • Custom script: call RemoveLocation (udg_p[udg_integerVariable])
But for this kind of trigger you shouldn't use an array.
 
  • Custom script: call RemoveLocation ( udg_p[ GetPlayerId( GetTriggerPlayer() ) + 1 ] )
JASS:
//This below is player number function converted from GUI to jass it has this form
GetConvertedPlayerId(GetTriggerPlayer())
//Here you can se how it look like
function GetConvertedPlayerId takes player whichPlayer returns integer
    return GetPlayerId(whichPlayer) + 1
endfunction
//So you can just use
call RemoveLocation (udg_p[GetPlayerId(GetTriggerPlayer()) + 1])

But if you don't know jass even a little of it, then I suggest storing players/units... into variables just like Maker did, line before you use custom script.
 
Status
Not open for further replies.
Top