![]() |
Strings and Arrays >.<
ok, I need some help, Strings and Arrays are, I find, the hardest to script...
What are they used for, and can someone give me a good well explained example of them being used... also, what are those "this.something" commands for? |
Re: Strings and Arrays >.<
Strings are letters, you cant use math here...
Arrays, you can use more numbers, example: a={1,2,3...} if 5 is in a, do... this.thing... It just has the number when you are online, when you reconnect you will lose this number.. example: this.a=1; if (this.a==1){do...} this flag just can be loaded in this npc. If a different npc has the same line, this.a=1; they are 2 differents numbers... if you have 2 npcs in the same level, and you want that they are the same, you can use "level.thing" |
umm... I don't get it anyway, your just confused me even more
|
well, lets see
strings can be alphanumeric such as stringname=1,stringies,34kald you can replace parts of the string with replacestring stringname,index,newstring; lets say you want to replace the word 'stringies' in the above string, so, you find the index, in this case, 1, you would do replacestring stringname,1,newstringies you can access parts of the string with #I(stringname,index); lets say you want to make a npc say the 34kald in stringname so, message #I(stringname,2); you can addstring extra strings to stringname with the addstring stringname,text; lets say you want to add the string bluebellicecreamX2 to stringname, you would do addstring stringname,bluebellicecreamX2; afterwards stringname=1,stringies,34kald would now be stringname=1,stringies,34kald,bluebellicecreamX2 well, more on strings and arrays tomorrow |
Ugh. Explaining arrays to Brandon was tough. Let me see:
Arrays are basically 1 variable that can hold multiple values. In Graal, arrays are 1 dimensional. Let's take a look at an array: this.myarray={5,2,6,2,3}; This.myarray holds 6 independant values. You retrieve a value by putting the index of the value inside brackets [ ] after the variable: this.myarray[2] returns the number 6. The letter 5 is index 0, 2 is index 1, 6 is index 2, ect, ect. People normally use arrays to organize lots of similar data. Here is great use of arrays and keydowns: NPC Code: This will return the state of all 11 keydowns in a nice little variable called this.keys. You can then check if certain keys are down inside your code by checking a value in the array. If the D key was down, this.keys[4] will return 1. I hope this helps. From my experience, I learned that teaching arrays is hard. |
second edition
to set a string you would use the command setstring stringname,strings; lets say you want to set the string stringname with the value of 1, stringies, and 34kald, then you would do: setstring stringname,1,stringies,34kald :o Arrays Plain arrays are only numeric you can initialize arrays two ways: setarray arrayname,length; arrayname={values,...} you can change array variables many ways, but the most common (for me) is with arrayname[index]=newvalue; so lets say you want a array of 4 different values and then set them to the current npcs hearts/mp/ap/direction, you would do the following; setarray this.myvars,4; this.myvars[0]=hearts; // Index 0 will be NPCs heart count this.myvars[1]=mp; // Index 1 will be NPCs MP amount this.myvars[2]=ap; // Index 2 will be NPCs AP amount this.myvars[3]=dir; // Index 3 will be NPCs direction you read values from arrays with arrayname[index], lets say you want the NPC to display his mp,direction,ap, and heart count, so you would: message MP: #v(this.myvars[1]) Direction: #v(this.myvars[3]) AP: #v(this.myvars[2]) Hearts: #v(this.myvars[0]); there are some other "commands" that help you find the length or arrays and stuff such as that arraylen(arrayname); // For arrays sarraylen(arrayname); // For string arrays so, if you want to get the length of this.myvars from above, you would do this.arraylength=arraylen(this.myvars); this.arraylength is now equal to 4 if you want to find out the length of the above string, 'stringname', you would do howlong=sarraylen(stringname); no 'howlong' is equal 3 |
Ok guys, that helpped me, somewhat... Thankz to my genuis scripter Screen Name, BocoC, and Kaimestu for correcting there posts :rolleyes:
|
Ok better description of string arrays...i think...
NPC Code: hope it helped...i am worried i switched a few values, i think that #I is like this...#I(index,array)...:-/ if so, sorry, look in commands.rtf for any clarification. Also u can e-mail me if u wish, [email protected]...i can send you some sample scripts... *phew* exhausted :megaeek: |
thankz, that helpped alot
|
Quote:
Alias's and Mispellings of Kamietsu |
I dont understand anything and i think ill never...
I guess i should stick to gfxs and level making |
its not that hard really, you just have to pratice
|
I didn't really under stand it either, I just printed it off... then recorded it on to my recorder thingey, an playered it all ngiht... Now I can like say everything off by heart ;)
|
Quote:
|
oh brother :rolleyes:
|
All times are GMT +2. The time now is 01:32 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.