|
|
|
Joined: Dec 2010
Posts: 89
Babel fish
|
OP
Babel fish
Joined: Dec 2010
Posts: 89 |
on *:dialog:MainMenu:init:*: {
if ($read(loaded.txt) != $null) {
set %countloaded 1
while ($read(loaded.txt, %countloaded) != $null) {
set %botname $read(loaded.txt, %countloaded)
did -a MainMenu 10 %botname
if ($readini(bots.ini,%botname,connected) == connected) { did -ri MainMenu 10 %countloaded %botname (C) }
inc %countloaded
}
halt
}
}
Okay, well, as you can see from this code... I'm trying to make it loop through a text file, reading all names, and then reads out their name into a dialog list, and it also checks bots.ini to check to see if they are connected, and by default it writes only their name, but if it sees that connected=connected it will delete that, and write the botname again with (C) on end to indicate the bot is connected. I tested it, when the first bot said connected=connected and second bot in list said connected=not connected, it worked as expected, came out with But if it up, like make it so only bot2 is connected, it doesn't appear with anything in dialog? same with if I make them both connected. If Their both not connected, it also pops up as expected by not having any (C)'s. How can I fix this? Also, if you could think of a way of my script being better organised, please help, since did -ri MainMenu seems a lil silly, since it's just removing what it just added, didn't know how else to get (C) on to end.
|
|
|
|
Joined: Oct 2012
Posts: 164
Vogon poet
|
Vogon poet
Joined: Oct 2012
Posts: 164 |
You should check /help /did ' did -r' Clears all text from the ID, not just that line. ' did -o' Overwrites the specified line. This script should be using '/var' and not '/set' on *:dialog:MainMenu:init:*: {
if ($read(loaded.txt) != $null) {
var %countloaded = 1
while ($read(loaded.txt,%countloaded)) {
var %botname = $v1
if ($readini(bots.ini,%botname,connected) == connected) { did -a MainMenu 10 %botname (C) }
else { did -a MainMenu 10 %botname }
inc %countloaded
}
}
}
|
|
|
|
Joined: Dec 2010
Posts: 89
Babel fish
|
OP
Babel fish
Joined: Dec 2010
Posts: 89 |
I did read it, otherwise I wouldn't of been able to do any of that lol, and I misread -r damn, i thought it meant it would clear the Nth line, silly me. Thanks for your help.
|
|
|
|
Joined: Oct 2012
Posts: 164
Vogon poet
|
Vogon poet
Joined: Oct 2012
Posts: 164 |
Ok Now you got that, here's a little more optimizing for you You can use filter here with the -o switch on *:dialog:MainMenu:init:*: {
filter -fo loaded.txt MainMenu 10 * Then loop through the listbox with $did() var %i = 1
while ($did(MainMenu,10,%i)) {
var %a = $v1
if ($readini(bots.ini,%a,connected) == connected) { did -o MainMenu 10 %i %a (C) }
inc %i
}
} Consider using a hash table for this, especially the 'is connected' part.
|
|
|
|
Joined: Dec 2010
Posts: 89
Babel fish
|
OP
Babel fish
Joined: Dec 2010
Posts: 89 |
thanks deega I'm such a noob :P hehe oh, one more thing, do you know how /close works? I know it simple, but im too stupid to understand what it means D: i want to make a bot disconnect when i notice it, since i don't know how else i would do it :P and when i do on notice, /close -t $me it closes the status window of me, who sent the notice, not the bot which recieved it :S what? lol
on ^*:notice:*:*: {
if ($nick == %master) {
if ($1 == disconnect) {
haltdef
quit Bot Disconnected
close -t $me
}
}
}
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
What is it you want to close? mirc? in that case it's exit, the dialog dialog -x dialog-name dialog-name . and query window is close -m $nick
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Dec 2010
Posts: 89
Babel fish
|
OP
Babel fish
Joined: Dec 2010
Posts: 89 |
I want to close the status window of a bot when i notice it. for my bot maker i have designed it so when you click a button on a dialog for the bot to connect, it will /server -m [server] -i [nick] and it will open up another status window, with the bot. When i want it to disconnect, i will click a disconnect button on the dialog, and it will send a notice to the bot saying 'disconnect'. the bot will read that and /quit, but i think put /close -t $me and it closes the users status window instead of the bots. ? yet $me is the bot since thats the one recieveing the notice.
|
|
|
|
Joined: Oct 2012
Posts: 164
Vogon poet
|
Vogon poet
Joined: Oct 2012
Posts: 164 |
Try this instead of /close window -c @ $+ $window(status window).wid
|
|
|
|
Joined: Dec 2010
Posts: 89
Babel fish
|
OP
Babel fish
Joined: Dec 2010
Posts: 89 |
thanks! il try it out
|
|
|
|
|
|
|
|