mIRC Home    About    Download    Register    News    Help

Topic Options
#120482 - 18/05/05 05:40 AM To dialog or not to dialog? That is the question.
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
I currently have the following code on my bot for a Truth or Dare room
Code:
 on *:text:!limit*:*:{
  if !$2 {
    .msg $nick To set your limits, type !limit your limits here
    .msg $nick Put your limits in place of your limits here
    .msg $nick For example: !limit scat, animals, kids, golden showers
  }
  else {
    hadd -m TD $+(Limits.,$address) $2-
    .msg $nick Your limits have now been set as $hget(TD,$+(Limits.,$address))
    .msg $nick If you ever want to change your limits, you can do so by using this same command.
    .msg $nick Old limits will be replaced with new ones.
    if $istok(%play_temp,$nick,44) {
      set %play.list $addtok(%play.list,$nick,44)
      set %play_temp $remtok(%play_temp,$nick,1,44)
      describe %td.chan smiles as $nick is added to the players list
    }
  }
}
 


Which works fine, most of the time. However, it's been suggested that I might want to create a dialog where limits that the server sets are already checked and unchangeable, then a list of common limits which can be checked or unchecked, depending on if that is a limit the person wants or not, and finally a box for text entry, where the person can enter other limits that they have that aren't already accounted for previously.
It was suggested that I use DStudio to get started, but I can't make heads or tails of that program.

Would a dialog be able to do all that I've got listed above? If so, could someone please write the code along with descriptive remarks so that I can try to understand the code, before deciding if I want to go with the dialog (presuming it's possible) or keep the status quo.

Top
#120483 - 18/05/05 01:48 PM Re: To dialog or not to dialog? That is the questi
SladeKraven Offline
Planetary brain

Registered: 19/12/02
Posts: 3547
Loc: Kent, England
Ok dude, I wasn't too sure what you meant, but I've attempted to try what I thought you meant, it's using dialogs, and one hash table, I'll add some notes so you know what does what etc..

Code:
[color:green];If the data file exists, we load it into the hash table.[/color]
On *:Start: {
  hmake limits
  if ($isfile(limits.rsb)) {
    hload -o limits limits.rsb
  }
}

[color:green];If the dialog isn't opened, we open it with the /limits command.[/color]
alias limits {
  if (!$dialog(limits)) dialog -dm limits limits
}

[color:green]
;A simple dialog, with 7 controls, two texts, two combos, three buttons. 
;A text control will look like this: text "Text here",ID,x y w h.
[/color]
dialog limits {
  title "Truth or Dare by RusselB (/limits)"
  size -1 -1 166 149
  option dbu
  combo 1, 12 18 49 96, size
  text "Preset limits:", 2, 19 8 36 8, center
  text "Your limits:", 3, 104 8 33 8, center
  combo 4, 96 18 49 96, size
  button "Add", 5, 103 114 17 12
  button "Rem", 6, 120 114 17 12
  button "Save and &Exit", 7, 55 133 40 12
}

[color:green];Here we load in our presets with the /did command, you may change.[/color]
On *:Dialog:limits:init:0: {
  did -a limits 1 These
  did -a limits 1 are
  did -a limits 1 your
  did -a limits 1 presets
  did -a limits 1 edit
  did -a limits 1 at
  did -a limits 1 will. 
  did -a limits 1 :)
  [color:green]
  ;Here we list the number of items in the hash table loop through them all and
  ;write them into the dialog with the /did command as used above.
  [/color]  
  var %items = $hget(limits,0).item
  while (%items) {
    did -a limits 4 $hget(limits,%items).item
    dec %items
  }
}

[color:green]
;Ok, just something I quickly thought of, when you click a preset it adds to the %limits var
;using $addtok() if it' already is a token, it's removed with $remtok().
[/color]
On *:Dialog:limits:sclick:1: {
  if ($istok(%limits,$did(1),44)) %limits = $remtok(%limits,$did(1),44)
  else { %limits = $addtok(%limits,$did(1),44) }
}

[color:green]
;We add our items here, if it's already created it wont write to the dialog, 
;of course it wont re-write to the hash table because items are unique anyways, 
;but you can use as many "same" words as you want in a dialog.
[/color]
On *:Dialog:limits:sclick:5: {
  if ($hfind(limits,$did(4))) { 
    echo *** $did(4) already exists and can't be re-added. 
  }
  else {
    [color:green]
    ;Adds item to hash table if not already added.
    [/color]    
    hadd -m limits $did(4)
    [color:green]    
    ;Adds that item to dialog.  The item called would be $did(4) the 4 means the text in the 4th control.
    [/color]    
    did -a limits 4 $did(4)
    echo -a *** Added $did(4) to your limits.
    [color:green]    
    ;Adds the item as token.
    [/color]    
    %limits = $addtok(%limits,$did(4),44)
  }
}

[color:green]
;Same as above, just deleting...
[/color]
On *:Dialog:limits:sclick:6: {
  if (!$hfind(limits,$did(4))) { 
    echo *** $did(4) was already deleted. 
  }
  else {
    hdel limits $did(4)
    echo -a *** Deleted $did(4) from your limits.
    %limits = $remtok(%limits,$did(4),44)
    did -d limits 4 $didwm(limits,4,$+(*,$did(4),*),0)
  }
}

[color:green]
;When we click save and exit, the dialog closes, it doesn't save at this point.. 
;We use the close dialog event ($devent).
[/color]
On *:Dialog:limits:sclick:7: {
  dialog -x $dname $dname
}

[color:green]
;As referenced above, this is where we save our hash table and load it in as mentioned earlier.
[/color]
On *:Dialog:limits:close:0: {
  hsave -o limits limits.rsb
}


Hope this is what you wanted and/or helped in some way.

-Andy

Top
#120484 - 18/05/05 11:59 PM Re: To dialog or not to dialog? That is the questi
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
Thanks SladeKraven. A few problems though.
1) This is code that is run on a bot, so I need the dialog to show to teh person that issues the command. Personally, I'm thinking that might be the biggest of the problems.
2) When I tested the code, as you have it, using the bot's interface, and I went to add an item, I got the following error
* /hadd: insufficient parameters (line 74, script3.ini)
I copy & pasted your code into a new remote file on the bot, and it just happened to be script3.ini as the default name

There are a few other things that I can think of that I'd like to do, but it's stuff I can probably handle..ie; storing the limits information on a person by person basis in the hash table, as I currently do. If you reference my original posting, you'll see that the information is being stored using
Code:
hadd -m TD $+(Limits.,$address) $2-  

I'd think it would be easy enough to change $2- to the hash table entry as performed in the dialog.

Top
#120485 - 19/05/05 12:07 AM Re: To dialog or not to dialog? That is the questi
SladeKraven Offline
Planetary brain

Registered: 19/12/02
Posts: 3547
Loc: Kent, England
Sorry, what line is 74? The adding and removing works fine for me.

Quote:

so I need the dialog to show to the person that issues the command


Do you mean like an on text event or something? There's no way you can let someone else viw the dialog if that's what you mean, the person running the bot can view the dialog by typing /limits, but other than that participants in the Truth or Dare game itself will not be able to view the dialog, but what you could do is loop through the items in an on text event and display to them all your presets, and 'your limits'.

Top
#120486 - 19/05/05 12:15 AM Re: To dialog or not to dialog? That is the questi
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
OK...I'm going to stop bothering with this as I was told that I could make a dialog that other people could see, but you're telling me I can't. And the whole point of these alterations was to try to make things nicer/easier for the other people in the room.

Regarding line 74, according to the script editor it reads hadd -m limits $did(4)

Top
#120487 - 19/05/05 12:18 AM Re: To dialog or not to dialog? That is the questi
SladeKraven Offline
Planetary brain

Registered: 19/12/02
Posts: 3547
Loc: Kent, England
Nah dude only the bot will be able to view the dialog, not the people actually typing the command. Sorry if you was told otherwise, but it isn't true, the dialog code isn't in their mIRC, it's in the bots hehe. smile

-Andy

Top
#120488 - 19/05/05 12:24 AM Re: To dialog or not to dialog? That is the questi
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
ok...and thanks...too bad, would've been a nice thing to be able to do, especially in a case like mine where people are setting things on or off..oh well...maybe I'll take a look at the stuff for future suggestions, and if it's not already there, add it.

Top
#120489 - 19/05/05 12:30 AM Re: To dialog or not to dialog? That is the questi
SladeKraven Offline
Planetary brain

Registered: 19/12/02
Posts: 3547
Loc: Kent, England
A future suggestion for others to view your dialog? If that's what you mean I'm not too sure how Khaled would attempt such a task, I guess you and the public would have to be in a connection or something along those lines, share codes, preview, run etc. I think that would actually be quite nifty. Again, I think that would be stretching mIRC's capabilities and there'd be a few exploits, especially if they had the ability to modify code (delete others work) etc etc. I think if that could be added (somehow) then Khaled should only let it work for the DCC Trusted Users.

-Andy

Top
#120490 - 19/05/05 12:48 AM Re: To dialog or not to dialog? That is the questi
DaveC Offline
Planetary brain

Registered: 26/09/03
Posts: 4230
It could be done the dialogs would be sent using some private messages system like how dcc sends etc are now, but any action you took on them the dialog (besides maybe closing / moving etc) would just send back a "he did this in the remote dialog you sent" message and the server side would update the dialog, pretty much like web forms (without the remote side scripting), would be a nice feature, as per normal some options to enable or reject dialogs sent, i can see people using it to spam others with dialog ads (like them windows messenger service ads, i hated them, i didnt want to have to turn that service off) so an of switch would be needed for sure.

Something could be done now to make it, but the enduser would need a script installed, and being how they are some would goof it some wouldnt install it, some would think it a hack etc etc.

I went to a channel the other day, it had this nice battle ships game bot running, you could choose either to just play it, or download a verysmall script that helped the bot on traffic it had to send. If you told it u had the script, the bot sent as many lines as it can all in one line and the script just saw them and split them up on some end of line marker. So you saw your 10 by 10 grid instanly, rather than waiting a few seconds for it to be sent as ten lines. I thought thats was a simple but effective server/client script, the script u downloaded was only about 5 lines from memory, but came with a 15 to 20 line explanation of what it was doing for all the paraniod whats his script doing people out there.

Top