mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2009
Posts: 7
C
Cygnata Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Feb 2009
Posts: 7
I own the Skeleton_in_the_Closet dicebot, based off the Dem Bones/Bone Devil code. One of the commands in the file tells the bot to search a crit table and randomly display a message from the file. However, no matter where I place the file, he's not seeing it! He's been offline for a couple years, but it worked fine before.

Relevant code:

; nifty little critical strike table; reads numbered lines from text based on d100 result.
on *:text:!crit*:#: {
set %crit.roll $rand(1,100)
msg $chan ( $+ $nick $+ ) $read(crit-table.txt, %crit.roll) }
unset %crit.roll
}

Where should I be moving crit-table.txt to so he'll actually see it?

Last edited by Cygnata; 19/08/19 08:04 PM.
Joined: Feb 2015
Posts: 138
kap Offline
Vogon poet
Offline
Vogon poet
Joined: Feb 2015
Posts: 138
Hi

If you move the file crit-table.txt to the same directory the script file is in and change $read(crit-table.txt, %crit.roll) to $read($scriptdircrit-table.txt, %crit.roll) does it then work?

I could be wrong but as it is, it's probably looking for crit-table.txt in $mircdir.

hth


GNU Terry Pratchett - Looking for a mIRC help channel -> Check #mircscripting @ irc.swiftirc.net
Joined: Feb 2009
Posts: 7
C
Cygnata Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Feb 2009
Posts: 7
Works perfectly, thanks!

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Quote
I could be wrong but as it is, it's probably looking for crit-table.txt in $mircdir.
That's entirely correct.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Just a reminder that $read() has default behaviors that may not be intuitive, requiring it be a good idea for most users to use the nt switches

$read($scriptdircrit-table.txt, %crit.roll)
becomes
$read($scriptdircrit-table.txt,nt, %crit.roll)

Without the 'n' switch, it tries to evaluate identifiers found in the text line, and in some cases you can get some nasty surprises from this
Without the 't' switch, it looks at line#1 of the text file, and if it's a positive number, it uses that as the number of lines in the text file, even if line#1 has a much smaller number. The above syntax for $read shows a random line from the file, but if line#1 contains 10, then you get a random line from the next 10 lines, regardless how many lines there really are.

Last edited by Khaled; 20/08/19 01:28 PM.

Link Copied to Clipboard