|
Joined: Apr 2008
Posts: 51
Babel fish
|
OP
Babel fish
Joined: Apr 2008
Posts: 51 |
Hi everybody. i have a var. %npoint. this is a nick. also a var. %cpoint. this is a number. i have a listbox (AutoList 208)that gets populated with nicks and a number. i.e. john 20 bob 30 jill 20 jane 50 i need to create a loop to search the listbox for %npoint. Then add the %cpoint to the existing number. a push in the right direction would be greatly appreciated. i understand the $calc function, but i am having trouble with setting up the loop. Yes i'm a newbie but i am learning. 
Last edited by kkoser; 21/05/08 06:47 AM.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
This would be a lot easier if you had two list boxes.. one with the name, the other with the number, however, in order to get you the best way of doing this, would you please post the code that actually fills in the listbox?
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
Hi everybody. i have a var. %npoint. this is a nick. also a var. %cpoint. this is a number. i have a listbox (AutoList 208)that gets populated with nicks and a number. i.e. john 20 bob 30 jill 20 jane 50 i need to create a loop to search the listbox for %npoint. Then add the %cpoint to the existing number. a push in the right direction would be greatly appreciated. i understand the $calc function, but i am having trouble with setting up the loop. Yes i'm a newbie but i am learning. $didwm w/ $did textExample:. One of my listbox values are,... kkoser 20 Syntax: $did(dialogname,dialogid,$didwm(dialogname,dialogid,*kkoser*,0)).textthat will pull the data that finds kkoser in the listbox now if I want to change the value raw I would just do Syntax: //did -o dialogname dialogid nth $reptok($did(dialogname,dialogid,$didwm(dialogname,dialogid,*kkoser*,0)).text,20,21,32)That would take 20 has data and change it too 21 now if you are not sure of the nth of the line in your dialog that's why I use $didwm it returns the nth. $didwm(dialogname,dialogid,*word*,0)SO basically that's how you find, and edit in your listbox an entry it's up to use on how your gonna change the value I basically gave you a how to search for data, a how to overwrite data so again all you have to do is just manipulate that data whichever way you want. Why use a loop when you don't need one? 
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Apr 2008
Posts: 51
Babel fish
|
OP
Babel fish
Joined: Apr 2008
Posts: 51 |
when i use, $didwm(AutoList,208,*%npoint*,0) it returns 0 text comes in like this: "Points this game ShadowBot: 56" i use this code to work with it.
on *:TEXT:*Points*:%uno.channel:{
if ( $nick == %uno.botname ) {
did -r AutoList 100
var %cpoint = $strip($gettok($1-,5,32),bc)
var %npoint = $remove($gettok($1-,4,32),:)
did -a AutoList 100 %npoint %cpoint
msg %uno.channel %npoint got %cpoint points that round!!
msg %uno.channel the nickname is $didwm(AutoList,208,*%npoint*,0)
}
}
AutoList 100 is just an editbox. i used a msg to test the $didwm. Am i doing something wrong? RusselB, i do have two listboxes. one on the tab to select players and the other on the main dialog to list the selected players. Below shows the code that i use to do that and to add a zero as the starting number for them. on dclick:
if ( $did == 206 ) { did -a $dname 208 $did($dname,206).seltext 0 | did -d $dname 206 $did($dname,206).sel }
Last edited by kkoser; 21/05/08 03:45 PM.
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
When using a variable within a command make sure that wildcard matches are not directly touching the variable because it does not become evaluated
$didwm(AutoList,208,$+(*,%npoint,*),0)
So apparently the way I look at your little snipplet there your listbox gets filled has NICKNAME POINT that's it right?
so $didwm(AutoList,208,$+(*,%npoint,*),0) will give you the nth while as I stated awhile ago if you want the text field of the match to appear like NICKNAME point from your listbox then you do... $did(autolist,208,$didwm(autolist,208,$+(*,%npoint,*),0)).text
and if you want to replace the information again in your listbox with new info do
did -o $dname 208 $didwm(autolist,208,$+(*,%npoint,*)) $reptok($did(autolist,208,$didwm(autolist,208,$+(*,%npoint,*),0)).text,OLDINFO,NEWINFO,32)
P.S. Is your dialog listbox ID 208 or 100?
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
Ill just use your on text example and show you live
on *:TEXT:*Points*:%uno.channel:{
if ( $nick == %uno.botname ) {
var %cpoint = $strip($gettok($1-,5,32),bc)
var %npoint = $remove($gettok($1-,4,32),:)
var %u = $didwm(autolist,100,$+(*,%npoint,*))
if (!%u) {
did -a AutoList 100 %npoint %cpoint
msg %uno.channel %npoint got %cpoint points that round!!
}
else {
var %v = $did(autolist,100,%u).text
did -o Autolist 100 %u $reptok(%v,$gettok(%v,2,32),%cpoint,32)
msg %uno.channel %npoint got %cpoint points that round!!
}
}
} I made a var called u and stored info IF found into it which would be the nth but if theres no match I made a IF check it will just add to your dialog normally however if %u has a match it will replace old info with new %cpoint value if you want to increment this %cpoint value check in the script youll see how to edit it simply $calc(%cpoint + 1) could increase by one If
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Apr 2008
Posts: 51
Babel fish
|
OP
Babel fish
Joined: Apr 2008
Posts: 51 |
listbox is 208. i tested and it returns the nth... thank you now i will try the whole thing.
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Apr 2008
Posts: 51
Babel fish
|
OP
Babel fish
Joined: Apr 2008
Posts: 51 |
Fantastic!!! now i will add the $calc.
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
Once you learn how to manipulate text in any way,shape or form you desire then the rest becomes easy unless your writting a game or something that is 3d art with on collision mapping but something like a card game is relatively easy to manipulate the incoming text strings
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
|