Hello & Welcome to our community. Is this your first visit? Register
Follow us on
Follow us on Facebook Follow us on Twitter Watch us on YouTube


MMOCoin

Likes Likes:  0
Results 1 to 3 of 3
  1. #1
    Scout

    Join Date
    Jul 2009
    Posts
    20
    Post Thanks / Like
    Rep Power
    16
    Reputation
    40

    [Lua] Math.random Guide


    Register to remove this ad
    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

    A & B = numbers to randomize between
    ex.
    A=1
    B=3

    it gets a random number between 1 and 3 (includes 1 and 3 in the between)


    Math.Random(A,B)

    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
    Code:
    local spruch = Math.Random(1,2)
    now all we have to do is this

    Code:
    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")



    › See More: [Lua] Math.random Guide



  2. Related Threads - Scroll Down after related threads if you are only interested to view replies for above post/thread

  3. #2
    Beginner

    Join Date
    Jul 2009
    Posts
    8
    Post Thanks / Like
    Rep Power
    16
    Reputation
    1
    nice!

  4. #3
    Scout

    Join Date
    Mar 2009
    Posts
    14
    Post Thanks / Like
    Rep Power
    16
    Reputation
    17

    Register to remove this ad
    Lua is case sensitive. It has to be called like so:
    Code:
    rand = math.random(5)
    or
    Code:
    rand = math.random(1, 5)

 

 

Visitors found this page by searching for:

Lua math.random

wow lua math random

wow arcemu lua math.random

arcemu lua math random

wow arcemu lua arithmetic

arcemu lua math

lua math.randomised

math.random guide

arcemu math.random

arcemu lua if math.random

lua math.random not random

wow math.random

lua not random

SEO Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -5. The time now is 02:39 AM.
Powered by vBulletin® Copyright ©2000-2024, Jelsoft Enterprises Ltd.
See More links by ForumSetup.net. Feedback Buttons provided by Advanced Post Thanks / Like (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
vBulletin Licensed to: MMOPro.org