nanakiwurtz Posted August 27, 2013 Posted August 27, 2013 I think it could be simplified like this: function script F_RandMes { set .@i, getargcount(); return getarg(rand(1,.@i)); }What do you think?
Patskie Posted August 27, 2013 Posted August 27, 2013 It should be : function script F_RandMes { set .@i, getargcount(); return getarg(rand(0,.@i)); } since the first argument will be remove ( number of arguments ) callfunc("F_RandMes",1129,1222,1163,1357,1360,1522,1811,1410);
nanakiwurtz Posted August 27, 2013 Author Posted August 27, 2013 function script F_RandMes { set .@i, getargcount()-1; return getarg(rand(0,.@i)); }
Euphy Posted August 27, 2013 Posted August 27, 2013 You can use pull requests for something like this, you know. Want to give it a shot?
DeadlySilence Posted August 27, 2013 Posted August 27, 2013 Is there any specific reason a variable is initialized for only one use? Wouldn't function script F_RandMes { return getarg(rand(0, (getargcount() - 1))); } be better?
Capuche Posted August 27, 2013 Posted August 27, 2013 Why not, your way is easier to use. Also F_RandMes is only used in F_Hi and F_Bye functions in a clean version, it's not a lot of work (lol) to change them ////////////////////////////////////////////////////////////////////////////////// // *** Function "F_Hi" ////////////////////////////////////////////////////////////////////////////////// //returns random HELLO message function script F_Hi { return callfunc("F_RandMes",5,"Hi!","Hello!","Good day!","How are you?","Hello there."); } ////////////////////////////////////////////////////////////////////////////////// // *** Function "F_Bye" ////////////////////////////////////////////////////////////////////////////////// //returns random BYE message function script F_Bye { return callfunc("F_RandMes",6,"Bye. See you again.","Later.","Goodbye.","Good luck!","Have a nice day!","Byebye!!!"); }
Emistry Posted August 27, 2013 Posted August 27, 2013 even simpler ..?? function script F_RandMes { return getarg( rand( getargcount() ) ); } but i think the name should change too ? since it's not only for "mes" 1
nanakiwurtz Posted August 27, 2013 Author Posted August 27, 2013 Dang... I didn't realize that it only needs a single line... Does making a 'Pull Request' means that I have to make a fork? TBH I don't know how
Patskie Posted August 27, 2013 Posted August 27, 2013 Lol 1 rep for ya @Emistry . Why not make it simply F_Rand or even F_Random :3
Skorm Posted August 29, 2013 Posted August 29, 2013 I think it could be simplified like this: function script F_RandMes { set .@i, getargcount(); return getarg(rand(1,.@i)); }What do you think? Nanakiwurtz, I think this is very cool... You're awesome to request this 1
Recommended Posts