- Joined
- Mar 27, 2012
- Messages
- 3,232
I would like to make some quality-of-life changes to how I write vJASS, but I don't know where to start.
Ideally the process would take place when external script files have already been imported. It doesn't matter if vJASS to JASS conversion has been done at that point.
Example pseudocode(a weighted random number generator):
How would I made something like this? I am somewhat familiar with python, so I can make some simpler scripts if I know how to apply them.
Ideally the process would take place when external script files have already been imported. It doesn't matter if vJASS to JASS conversion has been done at that point.
Example pseudocode(a weighted random number generator):
JASS:
Weight[1] = 5
Weight[2] = 3
Weight[3] = 6
Weights = 3
WeightSum = 0//Variable declaration without writing the type or scope.
for i in 1 to Weights//A loop that runs a set amount of times
WeightSum = WeightSum + Weight[i]
r = Random(1,WeightSum)//Variable declarations as before
x = 1
i = 1
loop
if i > Weights then
break//The typical "exitwhen true" line.
x =+ Weight[i]//Adds the number to x, meaning that the line translates to "set x = x + Weight[i]"
if r < x then
break
i++//Translates to set i = i + 1
endloop
How would I made something like this? I am somewhat familiar with python, so I can make some simpler scripts if I know how to apply them.