Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I use priority in arrays?

Asked by
Mystdar 352 Moderation Voter
9 years ago

How do I use priority in arrays, say I wanted something to be more likely to happen than something else could I weight it or would I have to do this:

Enemies = {"Bandits", "Bandits", "Bandits", "Bandits", "Bandits", "Bandits", "Bandits", "Bandits", "Bandits",
           "Advanced Bandits", "Advanced Bandits", "Advanced Bandits",
           "Outlaws", "Outlaws", "Outlaws",
           "Murderers", "Murderers",
           "Assassins"}
while wait(0.5) do
    a = Enemies[math.random(1, 18)]
    print (a)
end

So here there is a: (1/2)% chance of a Bandit

(1/6)% chance of an Advanced Bandit

(1/6)% chance of an Outlaw

(1/9)% chance of a Murderer

(1/18)% chance of an Assassin

0
That is weighting a table, by putting it in multiple times. You just answered your own question q.q LunaScripter 80 — 9y
0
Oh boy, another murder game... EzraNehemiah_TF2 3552 — 9y
0
I was asking if there weas a more efficient method Mystdar 352 — 9y

Answer this question