![]() |
arrays
i dun know nothing about arrays yet i read npc programming bud tough i dont understand and i dun even know where arrays are good for ,can some teach me in this:megaeek:
|
http://razza.org/tormented/php/variables.php
I believe I have something bout regular variable arrays, but not string arrays ... |
quite simple
a array is like a lot of variables all in one variable u can set variables like this: arrayname={0,0,0} or setarrary arrayname,3; each would produce the array, arrayname={0,0,0} and u can use variables out of the array by using indexes, like this lets say there is a array 'nums' and it is equal to {3,5,7} say2 #v(arrayname[index]); so if the index was 2 it would show 7 u must remember that the indexes start with 0, not 1 so nums[0] - 3 nums[1] - 5 nums[2] - 7 also, if you want to set a value in a array, just do this: arrayname[index]=whatevervarialbe; |
also, there are string arrays, there are specific commands for them:
(from newfeatures2001.txt) addstring list,text; insertstring list,index,text; replacestring list,index,text; removestring list,text; deletestring list,index; sarraylen(list) lindexof(list,text) #I(list,index) |
he first needs to learn the basics of arrays, then string arrays should come in
|
Quote:
|
would someone mind explaining string arrays to me (accesing them, settings them, etc.) and hopefully if I learn em i'll write ai little tutorial for them ...
|
mmm.. ok i understand it. bud what will an array be good for i know its a noobish question:( i mean what will it come in handy for.
|
Re: arrays
Quote:
ballsx={1,2} //arrays ballsy={1,2} //arrays ballsx[1]= 12; ballsy[1]= 10; ballsx[2]= 13; ballsy[2]= 9; or u can use it in any other place where you have 1 name but more numbers for it... |
oo now is see thanks everyone:D
:( and some bad news another noobish question NPC Code:how do i loop this so it keeps repeating |
Quote:
if (created||timeout){ putleaps 3,24,23; sleep 5; timeout=.05; } |
thanks
|
i have never tried this, but would it work??
NPC Code: shouldnt that make the npc repeat ?? |
Quote:
|
Quote:
NPC Code: |
Quote:
|
Quote:
:D |
i know that callnpc isnt immediate
and i do agree that timeouts rule |
question agian is it possible to run to npc at a time in one and the same npc editor screen.So i mean that the scripts do there stuff at the same time.
|
.....sorry is it possible to fuse 2 diffirent npc' s in one npc.Bud tough they would run at the same time.Can understand me now.:)
|
bud wouldnt this do first the x than the y.
let me explain i need to make a pw system and i need to fuse a putleaps with a rain script clear so far?Now i wanna make sure the diong 2 things at 1 time like putting the leaps and raining. so the wont do putting leaps first and after that rainging uderstand me |
NPC Code:raining script<--after this i put ;putleaps 5,34,12; wouldnt it start raining and put the laps after the end of the raining script.so it will stop raining and than start putting laps |
Quote:
|
thanks dude
|
Arrays.
Ok, I am goona bust this out supreme style...but I wanted to ask,, I have never used the callnpc command, so could someone tell me about it? Anyway, heres a supreme explanation of arrays. ;)
Arrays are basically values that contain other values, like a long string of numbers (unless unsing string arrays), that can be called and changed, it is one of the best ways I know of to keep organized. Also there are so many great values to arrays, you will end up using them in practiallcy every script. So what I will first define is the different ways to create your arrays. The first way is to actually use the setarray name,size; command. NPC Code: The second way of setting arrays is through curly brackets. NPC Code: The next thing I will discuss is getting and setting values of arrays. Ok, there are so many ways of actually setting the values, the first I will explain is the simple one. NPC Code: Something to always remember is that arrays start on the value 0 not 1, so the first value in the array is 0 and the last it the arraysize-1. The previous way of setting the array value is best for when setting only one or two values, the next way I will show you is a way for setting arrays when multiple values are needed NPC Code: This will set this.rainx with 10 values with 1 as each, this is a good way when having specific values that will be consistant thruout the script. The next thing I will explain is how to use a for loop to generate random values for an array using the arraylen() variable. If you call arraylen(this.rainx) on the previous example, it will return 10, because it measures how many values are in the array. So using this you could measure the size of an array with undefined values set with setarray; as in this example. NPC Code: The next thing I will explain is how to call array values, as in this example. NPC Code: So this correctly reads the value and sets the player's chat to the random value. The next thing I will exaplin is how to read values and act on them. NPC Code: Another very little known fact, is that the value is set as it goes, so in this example, all values will be set correctly. NPC Code: This can be used very often when writing code that depends on other values. Also you can include conditions in arrays like so (if you don't know what a condition is, it can be an if statement or a block like this num = (a==0 ? 1 : 0) what this does is, if a equals 0 than num equals 1 otherwise it equals 0). NPC Code: I need to go now, so that is all I will explain for now, maybe later later. I hope that was useful. |
thanks thats really usefull you should make a tutorial
|
NPC Code://Rain Array by -=GodSpeed=- for example how would i fuse this with this NPC Code: i want them to work at the same time so rain with the putleaps.Some how i still cant get it to work. |
NPC Code: poor god speed, using his script. this should work... |
Quote:
|
aaaaaaaaaaahhhh flipping read example jeez i not meant to use it for my self or something i wanted to post a example caus i didnt feel like posting my own rain thunder time day night script
|
i feel so omg dumb i should knew that you where begining to say "o my he stole a script" or something
so agian IM NOT STEALING ANYTHING FROM ANYONE {EXAMPLE} :megaeek: |
well after asking three times i got sick of people not understanding me (thats my fault this is my second year english )
so i tought why dont post an EXAMPLE and make my self clear that way. |
1 Attachment(s)
Quote:
[EDIT] The colors got a little messed when I converted it from a bmp to a gif but here's the limit of my talent with gfx =o [/EDIT] |
Quote:
Sorry Kai, I was just trying to help... |
| All times are GMT +2. The time now is 05:07 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.