Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Random Scripting

Random Scripting

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Aznvt33   (18 posts)  Bio
Date Fri 16 Mar 2007 03:50 PM (UTC)
Message
I wanna do a script where I cast a random staffcast while bashing, except I have no idea how to use the math.random function.

There are 4 different staffcasts:

STAFFCAST DISSOLUTION AT <adventurer/denizen> (magical damage)
STAFFCAST LIGHTNING AT <adventurer/denizen> (electric damage)
STAFFCAST SCINTILLA AT <adventurer/denizen> (fire damage)
STAFFCAST HORRIPILATION AT <adventurer/denizen> (cold damage)

I'm thinking that I should make an alias for each one, and use math.random to assign a number for each alias and Execute ("the proper alias"). How would I do this?
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Fri 16 Mar 2007 04:03 PM (UTC)
Message
You could have a function that does something like this...


function random_cast(target)
  local spells = {
   "dissolution",
   "lightning",
   "scintilla",
   "horripilation",
  }

  local spellNum = math.random(1, #spells)

  return "staffcast " .. spells[spellNum] .. " at " .. target
end


Then whenever you want to cast a random spell, have your alias call this function, passing in the target you want, and send the result to the world.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Aznvt33   (18 posts)  Bio
Date Reply #2 on Fri 16 Mar 2007 07:21 PM (UTC)
Message
Thanks, I figured it out. Works great.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


10,823 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.