IceChat Forums

IceChat 7 => IceChat 7 Scripts => Topic started by: Kylen on May 27, 2010, 02:26:58 AM

Title: Dicebot Script
Post by: Kylen on May 27, 2010, 02:26:58 AM
Firstly, I'm brand new to IRC scripting, but not exactly to programming, though I myself am not really good at it.

I found this while looking for a dicebot script for IceChat, and it turns out it was in the IceChat 5 area, and was wondering if it would still work, and/or if someone could possibly help me get a dice rolling program done (d10/d100 system)

Thanks for any replies I get, or any help I recieve. Here's the old script I was ABOUT to try using:

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      

Edit: Also, how to get scripts to bloody WORK in IceChat...does it require a /load or something?
Title: Re: Dicebot Script
Post by: Snerf on May 27, 2010, 07:24:20 AM
You can use IceChat 5 Style scripts in IceChat 7 just fine.

You just need to put the actual script file in its correct Folder.

Open the IceChat Editor, go to the File Menu, and choose Explore Scripts Folder.
This is where the script file must sit.

Once you have copied it to that folder, you can then go to the Scripts Tab in the IceChat Editor,and from the File Menu, choose to Load the file.

If you have a script w/o a file, go to the IceChat Editor, to the Scripts tab. Since you are using an IceChat 5 type script, use the File, Save As menu item, and choose for the File Type, IceChat 5 Script (*.ice) , and give it a file name.