Math.Random Command [LUA] menu

User Tag List

Results 1 to 7 of 7
  1. #1
    mager1794's Avatar Member
    Reputation
    356
    Join Date
    Feb 2008
    Posts
    703
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Math.Random Command [LUA]

    Math.Random Command Guide
    by mager1794

    Ok now i know alot of people havn't even heard of this command so here i am to explain it
    using the math.random will stop you from having to make 4 functions for 2 spells...you
    will have only 3 functions... but it sounds alot better if you do alot of them say you
    want it to have a chance to cast fire ball frostbolt or absolutley nothing would be hard
    unless you use math.random

    The Function

    the function for math.random is pretty simple

    Math.Random(1,[Ammount of functions])

    its pretty simple heres a small example o fit

    pUnit:Math.Random(1,2)

    that will enable me to to make a random of 2 spells or chat message or both
    but it would be annoying to use if (Math.Random(1,2) == 1) for every command
    so we declare it as something else like this
    local spruch = Math.Random(1,2)

    now all we have to do is this

    if (spruch == 1) then
    pUnit:SendChatMessage(14, 0, "So do you kind of understand it")

    if you actually pay get explained how to use this command its pretty easy and very useful
    now when scripting a mob you wont be all like should i cast this every 6 secs or 4 secs or
    is that to OP ....Wait ill Randomize it at 5 seconds GENIUS!!!!


    An Example Script
    Code:
    function Arthas_Speak(pUnit, event)
    local spruch = Math.Random(1,2)
    if (spruch == 1) then
    pUnit:SendChatMessage(12, 0, "Hi")
     end
    if (spruch == 2) then
    pUnit:SendChatMessage(14, 0, "Hi")
     end
    end
    
    function Arthas_OnEnterCombat(pUnit, event)
    pUnit:SendChatMessage(12, 0, "Lets Get Randomized")
    pUnit:RegisterEvent("Arthas_Speak",10000, 0)
    end
    
    RegisterUnitEvent(NPCID, 1, "Arthas_OnEnterCombat")
    Lunar Gaming - Reaching For The Stars

    Math.Random Command [LUA]
  2. #2
    Arthas117's Avatar Knight-Champion
    Reputation
    151
    Join Date
    Mar 2007
    Posts
    483
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ...and I taught that (Unit, event, miscunit, misc) scripting is advanced...lol +rep x2

    World best PvP Paladin=Me? GG ;D


  3. #3
    SectorSeven's Avatar Banned
    Reputation
    444
    Join Date
    Oct 2007
    Posts
    1,948
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your a little off... if its between 1 or 2 that doesn't mean its going to be exactly 1 or 2. It can be a decimal...

  4. #4
    Kiyoshi's Avatar Member
    Reputation
    28
    Join Date
    Jun 2008
    Posts
    192
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had it in my head then SectorSeven confused my lol

  5. #5
    Arthas117's Avatar Knight-Champion
    Reputation
    151
    Join Date
    Mar 2007
    Posts
    483
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by SectorSeven View Post
    Your a little off... if its between 1 or 2 that doesn't mean its going to be exactly 1 or 2. It can be a decimal...
    Dont worry, the 1337 king(ME)'s not here to flame you, just wanna tell you that your singing is sick lol xP (for a lua god)

    World best PvP Paladin=Me? GG ;D


  6. #6
    Muruk's Avatar Member
    Reputation
    1
    Join Date
    Mar 2008
    Posts
    45
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    very nice, though i didnt learn it from you, i can see other people could...and as far as the math.random(1,2) the way i see it is it picks a number either 1 or 2, or whatever the 2 numbers youhave...thats just how I learned it, still works fine...

    +rep for Joo

  7. #7
    Ezikielth's Avatar Banned
    Reputation
    43
    Join Date
    Aug 2007
    Posts
    96
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    GJ, but does it work? The comments say that it doesnt :O

Similar Threads

  1. Updated Mega Lua guide {all known commands}
    By runiker in forum WoW EMU Guides & Tutorials
    Replies: 28
    Last Post: 07-30-2008, 10:10 PM
  2. LUA Command help
    By mager1794 in forum World of Warcraft Emulator Servers
    Replies: 0
    Last Post: 07-06-2008, 05:38 PM
  3. [Help][LUA] pUnit:GetHealthPct command
    By Kiyoshi in forum World of Warcraft Emulator Servers
    Replies: 7
    Last Post: 07-03-2008, 01:42 PM
  4. SetSoulLinkedwith LUA Command Guide
    By mager1794 in forum WoW EMU Guides & Tutorials
    Replies: 9
    Last Post: 07-02-2008, 04:16 PM
  5. Lua Wait Command? Script.
    By moongo in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 05-14-2008, 12:52 AM
All times are GMT -5. The time now is 11:10 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search