mIRC Home    About    Download    Register    News    Help

Topic Options
#240833 - 01/03/13 09:05 PM wierd bug, with dialogs and stuff
dominic_eddy Offline
Babel fish

Registered: 26/12/10
Posts: 89
Code:
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
Quote:
Bot (C)
Bot2

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.

Top
#240835 - 02/03/13 12:14 AM Re: wierd bug, with dialogs and stuff [Re: dominic_eddy]
Deega Offline
Vogon poet

Registered: 30/10/12
Posts: 164
You should check /help /did wink
'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'

Code:
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
    }
  }
}

Top
#240839 - 02/03/13 10:46 AM Re: wierd bug, with dialogs and stuff [Re: Deega]
dominic_eddy Offline
Babel fish

Registered: 26/12/10
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.

Top
#240840 - 02/03/13 11:12 AM Re: wierd bug, with dialogs and stuff [Re: dominic_eddy]
Deega Offline
Vogon poet

Registered: 30/10/12
Posts: 164
Ok Now you got that, here's a little more optimizing for you smile

You can use filter here with the -o switch
Code:
on *:dialog:MainMenu:init:*: {
  filter -fo loaded.txt MainMenu 10 *

Then loop through the listbox with $did()
Code:
  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. wink

Top
#240863 - 03/03/13 06:12 PM Re: wierd bug, with dialogs and stuff [Re: Deega]
dominic_eddy Offline
Babel fish

Registered: 26/12/10
Posts: 89
thanks deega smile
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

Code:
on ^*:notice:*:*: {
  if ($nick == %master) {
    if ($1 == disconnect) {
      haltdef 
      quit Bot Disconnected
      close -t $me
    }
  }
}

Top
#240865 - 03/03/13 08:05 PM Re: wierd bug, with dialogs and stuff [Re: dominic_eddy]
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
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,.) }

Top
#240890 - 04/03/13 06:32 PM Re: wierd bug, with dialogs and stuff [Re: sparta]
dominic_eddy Offline
Babel fish

Registered: 26/12/10
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. shocked? yet $me is the bot since thats the one recieveing the notice.

Top
#240895 - 04/03/13 11:04 PM Re: wierd bug, with dialogs and stuff [Re: dominic_eddy]
Deega Offline
Vogon poet

Registered: 30/10/12
Posts: 164
Try this instead of /close
window -c @ $+ $window(status window).wid

Top
#240925 - 06/03/13 08:26 AM Re: wierd bug, with dialogs and stuff [Re: Deega]
dominic_eddy Offline
Babel fish

Registered: 26/12/10
Posts: 89
thanks! smile il try it out

Top