Need a person to write Simple Array for me

Don’t think im dumb are anything but i need someone to write a simple array for me though all my actionscripting ive never had to do it before and I really dont have the time to learn now. Let me descirbe what has to be done really simple and then ill send you a test dummy to add the code to. The game this is for is almost completed and is one of my best creations yet.
Description:
My game consists of thousands of hit tests that all work together to stop the unit from running though small objects. (mostly alot of trees and walls).
I know nothing about arrays. Heres the simple hit test all you have to do is make the number after T everynumber possible.
if (this, hitTest(_root.world.T+*)) {
okay if you accept this job you will be included in the Credits. The file is attached, when done send it to (with the name you want to be known as under the credits):
[email protected]

oh ya the file is just for you to work with it isnt the game just a tensil to write the code on and send to me. Note the tensil does contain all the movement code so you can test it. Just wanted to clear that up.

how many numbers are there? in the fla there are 2 T integers and 4B integers… do you want B to be included as well?
and btw this isnt just a simple array job either…

Prophet.

yes T is for only trees and B is for the Misc objects like walls and stuff

so are you going to try and write an array for me becuase i am almost done with most of the games major codings then im going to start the maps Story line and i really need that code for my unit.

like i said im almost done with my coding for my Game and need to test out a few other things so someone please just write the code and send me the thing please I want to start testing my games quests and other code as soon as possible. k thanks

keep ya wig on ill give it a whirl but im not sure…
ne others want to hav a crack at it be my guest

Prophet.

PS ill PROBABLY (no promises) be on again tomoro (lookin at the time its actually later today…) at 6pm GMT

Sounds Great like he said Please if anyone else wants give it a try. Thanks agian.

yes i’m still waiting for anyone to try and figure this out had a few views but no real help except Prophet who seems to help alot of people. K someone reply with some help.

thanks i do my best :wink:
altho i gotta admit im a lil 2 busy to giv urs (or that musical rotating ball thingy :S) enough time atm im afraid…

i log on every day (if i can) and help other ppl coz it helps me in cementing the basics and broadening my own experience :slight_smile: id reccomend helping to all those question askers out there! :wink: lol

Prophet.

well any others i would highly like you to look at my FLA and try and write an array for it if you could. Thanks becuase im not getting far working on it myself

Here’s a related question:

I start with a variable called allnumbers:

 for (allnumbers=0; allnum<50; allnum++) {
trace("_root.world.T"+allnum);
}

and the output looks like this:


_root.world.T0
_root.world.T1
_root.world.T2
_root.world.T3 
...
_root.World.T49

How do I use this variable to perform a hit test on multiple instances (_root.world.T1, _root.world.T2…)? I thought that something like this would work:

 if (_root.Unit, hitTest(_root.world.T+allnumbers)) {...}

…but it doesn’t

Ya im confused by this too and ive tryed about every way possible the only way ive been told this can be done is with and array and i dont know anything about them and have gone far without using them and i dont want to learn them just for this reason. If you can’t figure it out just do the long way:

if (_root.Unit, hitTest(_root.World.Tree1) or _root.Unit, hitTest(_root.World.Tree2) or _root.Unit, hitTest(_root.World.Tree3)) { ext… lol

Oh ya someone please Help me on the real priority if you could find the code i know it would help alot of game Actionscripters. Thanks

Add this to the top of the blue dudes AS


onClipEvent(load){
	numTrees = 6;
	checkTrees = function(){
		for(var i = 1; i< numTrees+1; i++){
			if(this, hitTest(_root.world["T"+i])){
				return 1;
			}
		}
	}
}

then Instead of using if(this, hitTest()) blah blah blah for each direction, just replace it with this…


if (checkTrees()) {

Copy the trees and number them T1, T2, T3, T4, T5 etc… so if you use 5 trees, you would have T1-T5 and the numTrees variable would be 5. If you use 6 trees, change the numTrees variable to 6, etc… etc…

Here’s the .fla (had to zip it, too big… sorry).

Oh yeah… no Array required either. I’m not sure what this talk of “B” is, but this should give you some ideas. Maybe make something like this


onClipEvent(load){
	numTrees = 6;
	checkTrees = function(){
		for(var i = 1; i< numTrees+1; i++){
			if(this, hitTest(_root.world["T"+i])){
				return 1;
			}
		}
	}

	numObjects = 4;
	checkObjects = function(){
		for(var i = 1; i< numObjects+1; i++){
			if(this, hitTest(_root.world["B"+i])){
				return 1;
			}
		}
	}

}

and then change the if…


if (checkTrees() && checkObjects()) {

I didn’t test the objects, but I tested the trees…

Thanks
Just one more thing your middle code, if you have both hit tests should be or like this,
if (checkTrees() or checkObjects()) {
thanks again.

yer thas probly y i culdnt think of a simple way of doing this! lol

if((checkTrees() || checkObjects()){
}

sorry i couldnt b of more help tho :frowning:

Prophet.

Can someone please explain what the last line of the function does?


onClipEvent(load){
 numTrees = 6;
 checkTrees = function(){
  for(var i = 1; i< numTrees+1; i++){
   if(this, hitTest(_root.world["T"+i])){
   ** return 1;
**   }
  }
 


Just like the normal hitTest() function, it returns 1 if there there is indeed a “hit” and returns 0 if there isn’ a hit, which is what makes the if(checkTrees()){ work.

note that boolean values true or false can be substituted for 1s and 0s…
hence y the if statement works if there has been a hit - the function has returned true and therefore sets off the if statement :wink:

Prophet.

Thanks, I thought that may have been the case.