iFoxkun Posted November 27, 2011 Posted November 27, 2011 I don't understand the getarg command at all? Anyone o_o Quote
0 Z3R0 Posted November 28, 2011 Posted November 28, 2011 Agreed dont worry my tutorials will cover everything mentioned above Quote
0 Z3R0 Posted November 28, 2011 Posted November 28, 2011 I am on te road for another hour pm ur questions if u want Quote
0 Truly Posted November 27, 2011 Posted November 27, 2011 (edited) Basically getarg Gets the Arguments of some type of calling action. For example: place,50,50,6%TAB%script%TAB%Man%TAB%115,{ mes "[Man]" mes "Gimme a number!"; next; input @number; if (callfunc("OddFunc",@number)) mes "It's Odd!"; close; } function%TAB%script%TAB%OddFunc%TAB%{ if (getarg(0)%2==0) return 0;// it's even return 1;// it's odd } This is the example from the script_commands.txt And basically it will allow you to send multiple sets of data through one line. With this Callfunc, it will call the function "OddFunc" and the first Argument is "@number" which was set 1 line before the callfunc. So the script then jumps to the function for "OddFunc" and uses the 1st Argument, as getarg(0). The 2nd argument would have been getarg(1) and so on and so forth (Same basic principle with arrays). The funtion then will do whatever you want, in this case it will check if its an Even number, if not it will return 1 to where the calling action is And in this case, if(1) is true, so it will mes "It's Odd!" Edited November 27, 2011 by Truly Quote
0 iFoxkun Posted November 27, 2011 Author Posted November 27, 2011 Basically getarg Gets the Arguments of some type of calling action. For example: place,50,50,6%TAB%script%TAB%Man%TAB%115,{ mes "[Man]" mes "Gimme a number!"; next; input @number; if (callfunc("OddFunc",@number)) mes "It's Odd!"; close; } function%TAB%script%TAB%OddFunc%TAB%{ if (getarg(0)%2==0) return 0;// it's even return 1;// it's odd } This is the example from the script_commands.txt And basically it will allow you to send multiple sets of data through one line. With this Callfunc, it will call the function "OddFunc" and the first Argument is "@number" which was set 1 line before the callfunc. So the script then jumps to the function for "OddFunc" and uses the 1st Argument, as getarg(0). The 2nd argument would have been getarg(1) and so on and so forth (Same basic principle with arrays). The funtion then will do whatever you want, in this case it will check if its an Even number, if not it will return 1 to where the calling action is And in this case, if(1) is true, so it will mes "It's Odd!" I did not understand 1 bit xD. That one confuses me Quote
0 Dinze Posted November 27, 2011 Posted November 27, 2011 (edited) As you can see. input @number; if (callfunc("OddFunc",@number)) Now, calling the function "OddFunc" with the argument @number. and then, inside the function "Oddfunc" if (getarg(0)%2==0) for instance, if you input '4'. It will be if ( 4 % 2 == 0) note: % = Modulus operator >http://www.cprogramm...al/modulus.html If the argument(number) is even return 0 else return 1. Edited November 27, 2011 by Genuine Quote
0 xMiland Posted November 27, 2011 Posted November 27, 2011 getarg() is used to get the arguments that you passed during your function call. My example: prontera,50,50,4 script SampleNPCArg 50,{ mes "[Robert Dooke]"; mes "Okay I will pass my first name as the first argument"; mes "and my second name as the second argument."; next; callfunc "samplefunc","Robert","Dooke"; end; } function samplefunc { mes "OMG you have just passed the the man's name !"; mes "Firstname: "+getarg(0)+""; //getarg(0) is the 1st argument that has been passed which is "Robert". mes "Secondname: "+getarg(1)+""; //getarg(1) is the 2nd argument that has been passed which is "Dooke". close; } Quote
0 Truly Posted November 27, 2011 Posted November 27, 2011 Haha well i honestly didnt understand it until a few weeks ago, and that was after learning the for loops, arrays, and some other nifty commands that arnt easy to just pick up. I would suggest to avoid this if you dont understand it, then later when you get better at scripting, take a look at it! Quote
0 iFoxkun Posted November 28, 2011 Author Posted November 28, 2011 Agreed dont worry my tutorials will cover everything mentioned above Yeah, I really don't understand getarg(), on the other hand, I know what "set arrays" does, but how would be use it. Do you have to always get the size of the array? o_o How would I use it. Examples pl0x Quote
0 iFoxkun Posted November 28, 2011 Author Posted November 28, 2011 I am on te road for another hour pm ur questions if u want It's fine, I won't bother you while you're on the road. But try to explain it please after Quote
0 llchrisll Posted November 29, 2011 Posted November 29, 2011 (edited) I know what "set arrays" does, but how would be use it. Do you have to always get the size of the array? o_o How would I use it. Examples pl0x setarray .@test[0],1; The [0] stats the index where the array should be start to be written. An Index can holds up to 128 information, but the last Index is 127 since an array always starts with the index 0. To gain the arraysize, there is the command *getarraysize() also you need to know where the index starts. Example: I have an array which starts with the index 1: setarray .@boxid[1],512,513,514; Now I wanna know the array size: mes getarraysize(.@boxid); // To display it, I'm gonna use "mes" The next would be, if I wanna choose one of the information I have to create an menu. set .@boxm$,""; for (set .@m,0; .@m < getarraysize(.@boxid); set .@m,.@m + 1) set .@boxm$,.@boxm$ + "- "+.@boxid[.@m]+ ( (.@boxid==0)?"":":"); Then we'll have to open the menu. set .@s,select(.@boxm$); Since *select creates an "@" variables called "@menu" which contains the position I chose from the menu. I also saved it into a extra variable in case I would need the an other menu later, so I don't lose the number. If the array would start with an [0] I would have to do add a "- 1" after "(.@boxm$)", so it would like this: set .@s,select(.@boxm$) - 1; Now to confirm it, what I choose: mes "You have chosen: "+.@boxid[.@s]; mes "Is that correct?"; if(select("- Yes:- No") == 2) close; Like you saw I used another select, so the @menu has changed it's content. Then the npc ask us what to do next. mes "What do you want to now?"; if(select("- Edit:- Noting) == 2) close; Now he wants to know the new value for the array. mes "Please type the new value it should have:"; input @new; After I have give him the new value, now he needs to insert it into the array: setarray .@boxid[.@s],@new; So that ends my example. I hope I could be of help, since I'm not good at teaching others D: Regards, Chris Edited November 29, 2011 by llchrisll 1 Quote
Question
iFoxkun
I don't understand the getarg command at all? Anyone o_o
10 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.