Author Topic: Dice Roller script?  (Read 12033 times)

Inkpot

  • Newbie
  • *
  • Posts: 7
Dice Roller script?
« on: February 16, 2006, 08:38:44 AM »
Hello everyone,

I'm brand new to IceChat and so far, I'm really liking what I'm seeing. I've searched and searched, but I can't find a dice-rolling script (for use with roleplaying games) anywhere. The only ones I can find are for mIRC. I have no clue how to script, or I'd make one myself. Anyone think they could help me on this?

BTW, nice to meet you all! :)


Inkpot

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Dice Roller script?
« Reply #1 on: February 16, 2006, 06:49:56 PM »
How big is the script that you found for mIRC?
If it isnt too complicated, it may be able to work in IceChat 7, since it has partial mIRC script support now.
If it isnt too large, say less then 50 lines, you can post it here if you wish, if you cant get it to work.
The IceChat God

Inkpot

  • Newbie
  • *
  • Posts: 7
Re: Dice Roller script?
« Reply #2 on: February 17, 2006, 02:40:23 PM »
It looks like it's just too complicated. I tried to get it to work, but I couldn't (which doesn't really mean much, since I'm a complete n00b). I'm really bummed because my primary reason for using IceChat will be for online roleplaying. If I can't figure out a way to get the dice roller working, I'm sunk. :(

If anyone would like to take a look at it themselves, you can find it here: http://richards.sdf1.org/dice/download.html

I'd be eternally grateful for any help anyone could give me on this. Thanks so much.



Inkpot

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Dice Roller script?
« Reply #3 on: February 17, 2006, 03:34:03 PM »
Well, you are right, that does look pretty complicated, and that will not work in IceChat.

Do you have any idea what you require for the dice-rolling script do to?
It might be simple enough to get a script made for IceChat, but some specifics would be needed as to what is required.
The IceChat God

Inkpot

  • Newbie
  • *
  • Posts: 7
Re: Dice Roller script?
« Reply #4 on: February 17, 2006, 03:49:27 PM »
Well, I'm not looking for anything super-fancy (at least I don't THINK so). I would just like a script that would generate random dice rolls on a 4, 6, 8, 10, 12, and 20-sided dice. I would like to be able to add modifiers to those rolls as well. For example:

/roll 1d20+3 would roll a single 20-sided die and add 3 to the result. The output might look something like this: <nick> rolls 1d20+3=14. If possible, I'd also like to be able to set the color of the result (say, to red) so that it stands out from the rest of the text.

So what do you think? Does that sound like something ridiculously difficult to script for IceChat? Beyond the need for this script, I have to say that I'm really loving the program itself. Extremely user-friendly and well put together!! =)


Inkpot

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Dice Roller script?
« Reply #5 on: February 17, 2006, 05:50:54 PM »
Give this a try:
It is not glorious, but anytime sometime types:

"!roll 2d10" in a channel, it will work.
"!roll 1d20+3" works as well

It does not work for yourself, if you need that, that will be a bit of extra work.

Open the script editor in IceChat 5, and copy all the text below, and save it, and give it a try.
If you want to change the color of the message, change the number 4 on the SendCommand line to another
color number, or add more colors. Change the message how it suites you, of course.

Also, the SendCommand line should be all on 1 line, this message may just line wrap it.


Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
Dim NumberofDice     'Total Number of Dice
Dim NumberofSides    'Number of Sides per Dice
Dim Value            'The value of the roll 
Dim Extra            'any extra value to add to value
Dim tempVar          'temporary variable for calculating

'check if the !roll message has been sent
If Left(Message,5) = "!roll" then
 
  'find out how many dice
  tempVar = Mid(Message,7)
  NumberofDice = Left(tempVar,Instr(tempVar,"d")-1)
 
  'find out how many sides
  NumberofSides = Mid(tempVar,Instr(tempVar,"d")+1)

  'check if an extra value number is added (checks for + )
  If Instr(NumberofSides,"+") then 
    Extra = Mid(NumberofSides,Instr(NumberofSides,"+")+1)
    NumberofSides = Left(NumberofSides,Instr(NumberofSides,"+")-1)
  Else
    Extra = 0
  End If   

  'this seeds the random number generator
  Randomize
  For i = 1 to NumberOfDice
    Value = Value + Int(NumberofSides * Rnd) + 1
  Next

  'Add the Extra value here to the total value
  Value = Value + Extra

  'send out the message with Color Number 4 (Red)
  SendCommand "/msg " & Channel & " 4<" & NickName & "> " & NumberofDice & " dice with " & NumberofSides & " sides = " & Value,ServerNumber

End If

End Sub
The IceChat God

Inkpot

  • Newbie
  • *
  • Posts: 7
Re: Dice Roller script?
« Reply #6 on: February 18, 2006, 08:41:43 AM »
Thank you SO much for doing this!! I'm afraid I'll need the script to work for myself as well, though. When I try to use it now, it shows what I'm rolling, but not the result. Any suggestions?


Inkpot

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Dice Roller script?
« Reply #7 on: February 18, 2006, 05:17:23 PM »
Not sure what you mean by when you try and use it, no result. When you try and use it, it should not work at all. the ONTEXT sub does not fire for yourself, only when other people are using the !roll command.
The IceChat God

Inkpot

  • Newbie
  • *
  • Posts: 7
Re: Dice Roller script?
« Reply #8 on: February 18, 2006, 07:53:09 PM »
Right, but I'll need to have it fire for me (the one running the game) as well, because throughout the game I'll need to make various rolls myself, though it'd be best if there was a way to keep my rolls hidden from the players. Right now, what happens is that I type !roll 1d20 and what appears is <Inkpot !roll 1d20> It doesn't show what the actual result of the roll is ie, <Inkpot !roll 1d20=17(or whatever)>.

I'm sorry if I'm not making much sense. As I've said, I'm new to scripting so it's hard for me to put it all into words that'll make sense to someone who really knows what they're doing. :) Again, thank you for all your help!


Inkpot

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Dice Roller script?
« Reply #9 on: February 18, 2006, 08:52:48 PM »
Like I said before, the old script will not work for yourself.
Not sure why your trying then :|

Here is a new script, replace the old one, and it should work fine now. !roll commands for the channel, /roll commands for yourself, which no one else sees. And like previously, !roll commands do NOT work for yourself, they will just come out as regular channel message.

Code: [Select]
Function DiceRoll(Message)     
Dim NumberOfDice     
Dim NumberofSides     
Dim Value     
Dim tempVar     

  'find out how many dice     
  tempVar = Message 
  NumberofDice = Left(tempVar,Instr(tempVar,"d")-1)     

  'find out how many sides     
  NumberofSides = Mid(tempVar,Instr(tempVar,"d")+1)     

  'check if an extra value number is added (checks for + )     
  If Instr(NumberofSides,"+") then       
    Extra = Mid(NumberofSides,Instr(NumberofSides,"+")+1)     
    NumberofSides = Left(NumberofSides,Instr(NumberofSides,"+")-1)     
  Else     
    Extra = 0     
  End If         

  'this seeds the random number generator     
  Randomize     
  For i = 1 to NumberOfDice     
     Value = Value + Int(NumberofSides * Rnd) + 1     
  Next     

  'Add the Extra value here to the total value     
  Value = Value + Extra       

  DiceRoll = NumberofDice & " dice with " & NumberofSides & " sides =" & Value     

End Function     

Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)     
Dim RollMsg     

'check if the !roll message has been sent     
If Left(Message,5) = "!roll" then     
  RollMsg = DiceRoll(Mid(Message,7) ) 
       
  'send out the message with Color Number 4 (Red)     
  SendCommand "/msg " & Channel & " 4<" & NickName & "> " & RollMsg,ServerNumber     

End If     

End Sub     

Function ALIASES(Command,Parameters,ServerNumber)     
Select Case Command     
   Case "/roll"     
      ALIASES=True 'we have a match     
      Dim RollMsg 
      RollMsg = DiceRoll(Parameters) 
      SendCommand "/echo -a ->> Your Roll is " & RollMsg, ServerNumber 
End Select     
     
End Function     
The IceChat God