A script that a user of my bot requested.
Works with random lines.
!church
<User> -> !church
<BOT> -> User went to the church and prayed at the altar. User used this command 1 time(s).
Pretty useless. Was fun to make though!
;;use this command to add random lines for your command. (add atleast 1 line or it wont work.
/write church.txt <line>
;;this line to open the file and delete mismatches
/run church.txt
;;Dont forget to save the file after changing.
on $*:text:/^[!.](church)/Si:#:{
;;floodcontrol/delay
if (%flood [ $+ [ $nick ] ] { return }
set -eu3 %flood [ $+ [ $nick ] ] x
;;the random lines command
var %random = $read(church.txt)
;;channel where it doesnt work
if ($chan == #chan) { halt }
;;error message;; Small chance that it takes place
if (%random == $null) { notice $nick An unknown error has accured. }
;;when everything is right it triggers the command
else { inc %church [ $+ [ $nick ] ] 1 | msg # $nick went to the church and %random $+ . $nick used this command %church [ $+ [ $nick ] ] time(s). []4([]2Script by[]10 Bielie $+ []4) | halt }
}
Like napa said, you really need to test your code before submitting it. Anyway, your script can be written as such with a simple if-then-else statement (Yes, one if statement with && operators):
on $*:text:/^[!.](church)/Si:#:{
if ((!%flood [ $+ [ $nick ] ]) && ($chan != #chan) && (!$exists(church.txt))) {
set -eu3 %flood [ $+ [ $nick ] ] x
notice $nick An error occured; I can't find the data located in my directory!
}
else {
inc %church
msg # $nick went to the $regml(1) and $read(church.txt) $+ . $&
$nick has used this command %church $iif(%church > 1,times,time) $+ .
}
}