How Local Choice=Math.random Works
This guide was made by Me!
First lets view a LUA Peice from LUA++'s SVN. Brutallus for instance is a Local Choice=Math.random Boss.
Here is a peice of it.
Code:
function Brut_OnKilledTarget (pUnit, Event)
local Choice=math.random(1, 3)
if Choice==1 then
pUnit:SendChatMessage(14, 0, "Perish, insect!")
pUnit:PlaySoundToSet(12464)
elseif Choice==2 then
pUnit:SendChatMessage(14, 0, "You are meat!")
pUnit:PlaySoundToSet(12465)
elseif Choice==3 then
pUnit:SendChatMessage(14, 0, "Too easy!")
pUnit:PlaySoundToSet(12466)
end
end
Alright, so now you just need to re-write that on Notepad from scrath alot to get the feel of it. So now we have the script and feel of it. Lets continue to add and decrease options"elseif choice's".
Alright this is what makes the script have as many options.
Code:
local Choice=math.random(1, 3) <--
You cannot change the 1 or it will not load all the others.
You can change the 3 to make as many adds as possible.
Example
Code:
function Test_OnEnterCombat(pUnit, Event)
local Choice=math.random(1, 6)
if Choice==1 then
pUnit:SendChatMessage(14, 0, "WHY AM I YELLING?")
elseif Choice==2 then
pUnit:SendChatMessage(12, 0, "I would like to talk now.")
elseif Choice==3 then
pUnit:SendChatMessage(14, 0, "TALKING IS FOR LOSERS!!!")
elseif Choice==4 then
pUnit:SendChatMessage(14, 0, "TALKING IS FOR LOSERS!!!")
elseif Choice==5 then
pUnit:SendChatMessage(14, 0, "TALKING IS FOR LOSERS!!!")
elseif Choice==6 then
pUnit:SendChatMessage(14, 0, "TALKING IS FOR LOSERS!!!")
end
end
All you need to change is
Code:
elseif Choice==3 then
and
Code:
local Choice=math.random(1, 6)
As high as you want.
Hope this helps!
- BrantX