• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] function parameters

Status
Not open for further replies.
Level 14
Joined
Nov 18, 2007
Messages
1,084
I think functions can have an infinite amount of parameters or at least some really large amount. Is there some kind of special concern?

Is your second question asking if a function can take an array as an argument? It can't be done in vanilla Jass. It can be done in vJass though only with dynamic arrays.
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
Can have a function an argument in form of array of some type?

you could make a global array/hashtable and pass the index at which the data starts to the end index like:(pseudocode)
array[0] = 0
array[1] = 1
....
function blah takes integer start, integer end returns nothing
integer i = start
loop
array = array * 2//example
set i = i + 1
exitwhen i > end
endloop
endfunction

or make some kind of linked list with locations and pass the start location and the end location
 
I need like 10 paramters because not being able to pass the array. However that array is fixed length and not big, basically contains unit types for one race.

And no, I won't use vjass, since some friend will perhaps need poking around in the scripts and I want it perfectly compatible with non newgen editor without any addition. Furthermore, I heard there are problems with campaigns and the map using this will be also in a campaign file.
 
Level 11
Joined
Sep 12, 2008
Messages
657
well.. i made this for my projectile system , to make it more comfortable:

JASS:
function RegisterDataInteger takes integer MissleData, integer Adddata returns nothing
       set MissleIntegerData[MissleData] = Adddata
endfunction

so they do this basicly:

local integer i CreateNewMissle(owner, x, y, angle)
call RegisterDataInteger(i, 10)
then the missle i gets the data he putted it.
i used this to set damage, speed, max distance, duration, arc, etc..
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
I need like 10 paramters because not being able to pass the array. However that array is fixed length and not big, basically contains unit types for one race.

so why are you unable to pass the data from the array?
always tell the whole story
there usually is another way to do things

btw using globals will be faster because wc3 won't create a bunch of local variables every time you call the function
 
Status
Not open for further replies.
Top