mIRC Home    About    Download    Register    News    Help

Print Thread
$read command not finding file #265949 19/08/19 06:19 PM
Joined: Feb 2009
Posts: 6
C
Cygnata Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Feb 2009
Posts: 6
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.
Re: $read command not finding file [Re: Cygnata] #265950 19/08/19 07:07 PM
Joined: Feb 2015
Posts: 49
K
kap Offline
Ameglian cow
Offline
Ameglian cow
K
Joined: Feb 2015
Posts: 49
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


irc://irc.mircscripts.net:+6697/chat
Re: $read command not finding file [Re: kap] #265951 19/08/19 07:47 PM
Joined: Feb 2009
Posts: 6
C
Cygnata Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Feb 2009
Posts: 6
Works perfectly, thanks!

Re: $read command not finding file [Re: kap] #265952 19/08/19 08:53 PM
Joined: Jul 2006
Posts: 3,568
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,568
Quote
I could be wrong but as it is, it's probably looking for crit-table.txt in $mircdir.
That's entirely correct.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $read command not finding file [Re: kap] #265953 19/08/19 09:13 PM
Joined: Jan 2004
Posts: 1,187
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,187
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.