Duplicate variable definition


(Nate ) #1

Hey guys! It is me again!

So I have been wondering how I should go about doing this properly… basically I have a doctor entity which I made for my game. And I wanted to mess around with another aspect to my game which will probably be some kind of pick up item, like coins, gems etc.

This code I currently have works but it throws a yellow message when I debug saying “col:13 Warning: Duplicate variable definition.”

However, it acts just like I need it to act… I am wondering if I went about executing the code correctly, here is my code in the World.as file which basically just creates 5 doctor entities and allows me to walk into each one and have them recycle from the stage.

for (var i: int = 0; i < 5; i++)
		{
			

		doc = new theDoc;
		add(doc);//adds Doc!
		
		doc.x = 420 * i;
		doc.y = 240;
		
		}

Please let me know what you guys think! Thanks


(Nate ) #2

Nevermind! It is clear to me that I have been programming (or trying to program) for too long today! The error I was getting was referring to the for loop directly below this one… also in the same update function using i as a variable as well… -.- FACE PALM… time to go outside for a little while… mods may delete this if they would like… unless they or someone else has input for doing this smoother… THANK YOU


(Jacob Albano) #3

Nothing in that snippet shows any code that should cause that warning. Ultimately, though, it’s just a warning, and if the code runs correctly you can probably ignore it.

Edit: Ah, you posted before I finished.


(Ultima2876) #4

I usually fix these just to de-clutter the warnings window, but yeah they’re generally not a problem at all.