
Results 1 to 6 of 6
Threaded View
-
27-07-08, 01:27 AM #1
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 this is what makes the script have as many options.
Code:local Choice=math.random(1, 3) <--
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
Code:elseif Choice==3 then
Code:local Choice=math.random(1, 6)
Hope this helps!
- BrantX