Post: Custom value input - No setText
01-03-2012, 01:41 PM #1
d7w7z
Bounty hunter
(adsbygoogle = window.adsbygoogle || []).push({}); This is my copy of the old mw2 patches that allowed you to pick a custom value for a setting. It uses printlnBold or else it would have to use 10 setText strings to work(0 1 2 3 4 5 6 7 8 9).

If you don't know what this is go to around the 45 second mark in the video. This is what the idea was based off. Mine only uses numbers atm, might add support for characters + numbers.



    
CreateSlider(min,max,def,c1,c2,f) {
self endon("EndSlider");
self.slidec=0; self.skid=[];
for(i=0;i < max.size;i++){if(isD(def[i])) { self.skid[i]=def[i]; } else { self.skid[i]=min[i]; } }
t = SliderPrint(self.skid, c1, c2, false);
self iPrintlnBold(t);
for(;Winky Winky {
self waittill("moveslidemenu", D);
switch(D) {
case "U": self.skid[self.slidec]--; break; case "D": self.skid[self.slidec]++; break;
case "L": self.slidec--; break; case "R": self.slidec++; break;
default: self thread [[f]](SlideReturn()); self notify("EndSlider"); }
self.slidec = SlideVarCheck(self.slidec, min, max);
self iPrintln(SliderPrint(self.skid, c1, c2));
} }

SlideVarCheck(c, min, max) {
s=self.skid[c];
if(c<0) { c=self.skid.size-1; } else if(c>self.skid.size-1) { c=0; }
if(s < min[c]) { s=max[c]; } else if(s > max[c]) { s=0; }
self.skid[c]=s;
return c;
}
SlideReturn() {
t=0;f=0;s=self.skid.size-1;
for(i=0;i<s+1;i++) {
f=self.skid[i];
for(c=0;c<s-i;c++) { f *= 10; }
t+=f; }
return t;
}
SliderPrint(a,hc,uc) {
t=""; c=undefined;
for(i=0;i<a.size;i++) {
if(i==self.slidec) { c=hc; } else { c=uc; }
t+="^" + c + a[i]; }
return t;
}

isD(var) { return isDefined(var); }


The input must be arrays with one number per array. I don't know how to split an int into an array(array has to use ints, NOT strings) but if somelse does, let me know Smile

Example + How to use:
    
SliderTest() {
l=[];d=[];h=[];
l[0]=[B]0[/B]; d[0]=[B]1[/B]; h[0]=[B]9[/B];
l[1]=[B]0[/B]; d[1]=[B]3[/B]; h[1]=[B]9[/B];
l[2]=[B]0[/B]; d[2]=[B]3[/B]; h[2]=[B]9[/B];
l[3]=[B]0[/B]; d[3]=[B]7[/B]; h[3]=[B]9[/B];

//0000 - Min value
//1337 - Starting value
//9999 - Max value

[B]self CreateSlider(l, h, d, 1, 7, ::SetGravity); [/B]
[B]//CreateSlider(min value array, max value array, starting value array - can be undefined, highlighted colour, unhighlighted colour, function)[/B]
}


SetGravity([B]v[/B]) { //Once the number is selected, it sents it as an input to the function, use it to set the value.
self setClientDvar("g_gravity", [B]v[/B]);
self iPrintln("Gravity Set To " + [B]v[/B]);
}



Use these notifys to change the value of the numbers/move left and right.
    
self notify("moveslidemenu", "U"); //Reduce current number
self notify("moveslidemenu", "D"); //Increase current number
self notify("moveslidemenu", "L"); //Move to the number on the left
self notify("moveslidemenu", "R"); //Move to the number on the right
self notify("moveslidemenu", "Select"); //Finish picking value and do function
(adsbygoogle = window.adsbygoogle || []).push({});

The following 2 users say thank you to d7w7z for this useful post:

247Yamato, x_DaftVader_x
01-03-2012, 08:11 PM #11
Taylor
Former Black Knight.
Originally posted by Karoolus View Post
looks good Smile

although i don't like the iPrintlnBold..
wouldn't it be possible to use either "setcursorhint" or "sethintstring" ? i don't think they'll overflow, so should work, no ? Smile


wtf? u get this? lmao
01-03-2012, 08:39 PM #12
d7w7z
Bounty hunter
Originally posted by xYARDSALEx View Post
wtf? u get this? lmao

Its pretty simple, I have just compressed the size a little by putting more than 1 thing per line.

    
CreateSlider(min,max,def,c1,c2,f) {
self endon("EndSlider");
self.slidec=0;
self.skid=[];
for(i=0;i < max.size;i++){if(isD(def[i])) { self.skid[i]=def[i]; } else { self.skid[i]=min[i]; } }
[B]//Makes an array with the numbers from the default array/min array if default array is not found[/B]

t = SliderPrint(self.skid, c1, c2, false);[B] //Make the string with the correct option highlighed[/B]
self iPrintlnBold(t); [B]//Print it..[/B]

for(;Winky Winky {
self waittill("moveslidemenu", D); [B]//Wait to be told to change value[/B]

switch(D) { //Direction to move
case "U": self.skid[self.slidec]--; break;
case "D": self.skid[self.slidec]++; break;
case "L": self.slidec--; break;
case "R": self.slidec++; break;
default: self thread [[f]](SlideReturn()); self notify("EndSlider"); [B]//Get the current value, do the function from the inputs and end this function[/B]
}

self.slidec = SlideVarCheck(self.slidec, min, max); [B]//Check the selection isn't bigger than the array, if so reset to 0 to loop around[/B]
self iPrintln(SliderPrint(self.skid, c1, c2)); [B]//Print the updated verison of the selection[/B]
} }


Helpful?
01-03-2012, 10:03 PM #13
Taylor
Former Black Knight.
Originally posted by d7w7z View Post
Its pretty simple, I have just compressed the size a little by putting more than 1 thing per line.

    
CreateSlider(min,max,def,c1,c2,f) {
self endon("EndSlider");
self.slidec=0;
self.skid=[];
for(i=0;i < max.size;i++){if(isD(def[i])) { self.skid[i]=def[i]; } else { self.skid[i]=min[i]; } }
[B]//Makes an array with the numbers from the default array/min array if default array is not found[/B]

t = SliderPrint(self.skid, c1, c2, false);[B] //Make the string with the correct option highlighed[/B]
self iPrintlnBold(t); [B]//Print it..[/B]

for(;Winky Winky {
self waittill("moveslidemenu", D); [B]//Wait to be told to change value[/B]

switch(D) { //Direction to move
case "U": self.skid[self.slidec]--; break;
case "D": self.skid[self.slidec]++; break;
case "L": self.slidec--; break;
case "R": self.slidec++; break;
default: self thread [[f]](SlideReturn()); self notify("EndSlider"); [B]//Get the current value, do the function from the inputs and end this function[/B]
}

self.slidec = SlideVarCheck(self.slidec, min, max); [B]//Check the selection isn't bigger than the array, if so reset to 0 to loop around[/B]
self iPrintln(SliderPrint(self.skid, c1, c2)); [B]//Print the updated verison of the selection[/B]
} }


Helpful?


I Dunno i read Over It Very Quick
01-04-2012, 03:10 AM #14
Blackstorm
Veni. Vidi. Vici.
Originally posted by xYARDSALEx View Post
wtf? u get this? lmao


It's not very hard to understand, just a bunch of for loops and arrays. I'm use to this ;b
01-04-2012, 08:33 PM #15
Taylor
Former Black Knight.
Originally posted by Blackstorm View Post
It's not very hard to understand, just a bunch of for loops and arrays. I'm use to this ;b


No Shit Thats What All Ur Menu Base Is......
01-04-2012, 08:44 PM #16
Blackstorm
Veni. Vidi. Vici.
Originally posted by xYARDSALEx View Post
No Shit Thats What All Ur Menu Base Is......



Well they're very useful once you know how to use them.
01-04-2012, 08:48 PM #17
Taylor
Former Black Knight.
Originally posted by Blackstorm View Post
Well they're very useful once you know how to use them.


yeah, i shud teach me on skype sometime
01-04-2012, 08:56 PM #18
Blackstorm
Veni. Vidi. Vici.
Originally posted by xYARDSALEx View Post
yeah, i shud teach me on skype sometime


Haha alright :b
01-06-2012, 04:40 AM #19
Blackstorm
Veni. Vidi. Vici.
Originally posted by reScript
Is it true if you say "array" three times in a row you appear out of nowhere? :3


Very true.... how'd you find out :O

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo