Object Problem

Blitz3D Forums/Blitz3D Beginners Area/Object Problem

I've been trying to use "Object" to sort things out, but it isn't working.

What I've done is I've made a function called "InitLevel." This functions sets up the level and has no errors. But when "InitLevel" calls the function "InitLevelGuns," I recive an error "Entity does not exist."

I know the problem, but I just don't know how to fix it because this is the first time I've ever needed to use "Object."

I named all my guns using "EntityName," but I don't know how to utilize this. Please help.

This is the "InitLevelGuns" function:
Function InitLevelGuns()

	;pistol (gun1)
	pistol.weapon = New weapon
	;lazer (gun2)
	lazer.weapon = New weapon
	;dartgun (gun3)
	dartgun.weapon = New weapon
	;XM1014 (gun4)
	rifle.weapon = New weapon
	;HK-MP5
	mp5.weapon = New weapon
	;SAW
	saw.weapon = New weapon
	
	pistol\category = "C90-KL"
	pistol\index = 1
	pistol\offsetx = .60
	pistol\offsety = -.60
	pistol\offsetz = .9
	pistol\entityhandle = LoadMesh("weapons\pistol1\pistol1.x",camera)
	pistol\gotit = False
	pistol\ammo = 16
	pistol\rounds = 10
	pistol\damage = 7
	NameEntity pistol\entityhandle, "pistol"
	
	lazer\category = "LAS-74"
	lazer\index = 2
	lazer\offsetx = .95
	lazer\offsety = -.63
	lazer\offsetz = 1.3
	lazer\entityhandle = LoadMesh("weapons\lazer\lazer.3ds", camera)
	lazer\gotit = False
	lazer\ammo = 100
	lazer\rounds = 50
	lazer\damage = 10
	NameEntity lazer\entityhandle, "lazer"
	
	dartgun\category = "D4-S"dartgun\index = 3
	dartgun\offsetx = .8
	dartgun\offsety = .64
	dartgun\offsetz = 1.8
	dartgun\entityhandle = LoadMesh("weapons\dartgun\dartgun.x", camera)
	dartgun\gotit = False
	dartgun\ammo = 6
	dartgun\rounds = 5
	dartgun\damage = 7
	NameEntity dartgun\entityhandle, "dartgun"
	
	rifle\category = "Benneli XM1014"
	rifle\index = 4
	rifle\offsetx = .60
	rifle\offsety = -.4
	rifle\offsetz = .8
	rifle\entityhandle = LoadMesh("weapons\xm\w_xm1014.3ds", camera)
	rifle\gotit = False
	rifle\ammo = 12
	rifle\rounds = 16
	rifle\damage = 13
	NameEntity rifle\entityhandle, "rifle"
	
	mp5\category = "HK-MP5"
	mp5\index = 5
	mp5\offsetx = .6
	mp5\offsety = -.5
	mp5\offsetz = .6
	mp5\entityhandle = LoadMesh("weapons\raven\w_mp5.3ds", camera)
	mp5\gotit = False
	mp5\ammo = 80
	mp5\rounds = 12
	mp5\damage = 10
	NameEntity mp5\entityhandle, "MP5"
		
	saw\category = "SAW M-2492
	saw\index = 6
	saw\offsetx = .95
	saw\offsety = -.84
	saw\offsetz = 1
	saw\entityhandle = LoadMesh("weapons\saw\saw.3ds", camera)
	saw\gotit = False	
	saw\ammo = 80
	saw\rounds = 24
	saw\damage = 15
	NameEntity saw\entityhandle, "SAW"
	
	;setup
	ScaleEntity pistol\entityhandle, 1, 1, 1
	ScaleEntity lazer\entityhandle, .08, .08, .08
	ScaleEntity rifle\entityhandle, .027, .027, .027
	ScaleEntity mp5\entityhandle, .05, .05, .05
	ScaleEntity saw\entityhandle, .1, .1, .1
	
	TranslateEntity pistol\entityhandle, pistol\offsetx, pistol\offsety, pistol\offsetz
	TranslateEntity lazer\entityhandle, lazer\offsetx, lazer\offsety, lazer\offsetz
	TranslateEntity dartgun\entityhandle, dartgun\offsetx, dartgun\offsety, dartgun\offsetz
	TranslateEntity rifle\entityhandle, rifle\offsetx, rifle\offsety, rifle\offsetz
	TranslateEntity mp5\entityhandle, mp5\offsetx, mp5\offsety, mp5\offsetz
	TranslateEntity saw\entityhandle, saw\offsetx, saw\offsety, saw\offsetz
	
	RotateEntity rifle\entityhandle, 90, 90, 0
	RotateEntity mp5\entityhandle, 90, 90, 0
	RotateEntity saw\entityhandle, 90, 90, 0

	HideEntity rifle\entityhandle
	HideEntity dartgun\entityhandle
	HideEntity lazer\entityhandle
	HideEntity mp5\entityhandle
	HideEntity saw\entityhandle
	
	;hide weapons that we don't have yet
	For w.weapon = Each weapon
		
		If w\gotit = False
			HideEntity w\entityhandle
		EndIf	
	
	Next
	
End Function


Here is "UpdateGun," where the problem is:
Function UpdateGun()
	
	If KeyHit(15)
		gun = gun + 1
		If gun >= 7
			gun = 1
		EndIf
	EndIf
	
	If gun = 1
	;	If pistol\gotit = True
			HideEntity pistol\entityhandle ;<--convert this to "Object"
			HideEntity rifle\entityhandle
			HideEntity mp5\entityhandle
			HideEntity dartgun\entityhandle
			HideEntity saw\entityhandle
			ShowEntity pistol\entityhandle
	;	EndIf
	ElseIf gun = 2
	;	If lazer\gotit = True
			HideEntity pistol\entityhandle
			HideEntity rifle\entityhandle
			HideEntity mp5\entityhandle
			HideEntity dartgun\entityhandle
			HideEntity saw\entityhandle
			ShowEntity lazer\entityhandle
	;	EndIf
	ElseIf gun = 3
	;	If dartgun\gotit = True
			HideEntity lazer\entityhandle
			HideEntity rifle\entityhandle
			HideEntity mp5\entityhandle
			HideEntity pistol\entityhandle
			HideEntity saw\entityhandle
			ShowEntity dartgun\entityhandle
	;	EndIf
	ElseIf gun = 4
	;	If rifle\gotit = True
			HideEntity lazer\entityhandle
			HideEntity pistol\entityhandle
			HideEntity mp5\entityhandle
			HideEntity dartgun\entityhandle
			HideEntity saw\entityhandle
			ShowEntity rifle\entityhandle
	;	EndIf
	ElseIf gun = 5
	;	If mp5\gotit = True 
			HideEntity lazer\entityhandle
			HideEntity rifle\entityhandle
			HideEntity pistol\entityhandle
			HideEntity dartgun\entityhandle
			HideEntity saw\entityhandle
			ShowEntity mp5\entityhandle
	;	EndIf
	ElseIf gun = 6
	;	If saw\gotit = True
			HideEntity lazer\entityhandle
			HideEntity rifle\entityhandle
			HideEntity pistol\entityhandle
			HideEntity dartgun\entityhandle
			HideEntity mp5\entityhandle
			ShowEntity saw\entityhandle
	;	EndIf
	EndIf
	
	;Shoot
	;-----
	If gun=1
	If ammo >= 1
	If MouseHit(1)
		PlaySound shoot
		ammo = ammo - 1
		picked=CameraPick(camera, 400, 300)
		p.hole = New hole
		p\entityhandle = CopyEntity(bullethole)
		p\alpha = 0.9
		p\typething = "pistol"
		PositionEntity p\entityhandle, PickedX(), PickedY(), PickedZ()
		CreateSomeParticles(PickedX(), PickedY(), PickedZ(), 100, 100, 100, 6)
	EndIf
	EndIf
	EndIf
	
	If gun=2
	If ammo >= 1
	If MouseHit(1)
		PlaySound shoot
		ammo = ammo - 1
		picked=CameraPick(camera, 400, 285)
		For i = 1 To 4
		l.laserhole = New laserhole
		l\entityhandle = CopyEntity(laserspark)
		l\alpha = 0.9
		l\typething = "laser"
		PositionEntity l\entityhandle, PickedX(), PickedY(), PickedZ()
		Next
	EndIf
	EndIf
	EndIf
	
	If gun=4
	If ammo >= 1
	If MouseHit(1)
		PlaySound shoot
		ammo = ammo - 1
		For i = 1 To 5
			picked=CameraPick(camera, Rnd(390,410), Rnd(275, 295))
			s.hole = New hole
			s\entityhandle = CopyEntity(bullethole)
			s\alpha = 0.9
			s\typething = "shotgun"
			PositionEntity s\entityhandle, PickedX(), PickedY(), PickedZ()
			CreateSomeParticles(PickedX(), PickedY(), PickedZ(), 100, 100, 100, 6)
		Next
	EndIf
	EndIf
	EndIf
	
	If gun=5
	If ammo >= 1
	If MouseDown(1)
	If MilliSecs() > mp5timer + 160
		PlaySound shoot
		ammo = ammo - 1
		picked=CameraPick(camera, Rnd(390,410), Rnd(275, 295))
		m.hole = New hole
		m\entityhandle = CopyEntity(bullethole)
		m\alpha = 0.9
		m\typething = "mp5"
		PositionEntity m\entityhandle, PickedX(), PickedY(), PickedZ()
		CreateSomeParticles(PickedX(), PickedY(), PickedZ(), 100, 100, 100, 6)
		mp5timer = MilliSecs()
	EndIf 
	EndIf
	EndIf
	EndIf
	
	If gun=6
	If ammo >= 1
	If MouseDown(1)
	If MilliSecs() > sawtimer + 84
		PlaySound shoot
		ammo = ammo - 1
		picked=CameraPick(camera, Rnd(390,410), Rnd(275, 295))
		w.hole = New hole
		w\entityhandle = CopyEntity(bullethole)
		w\alpha = 0.9
		w\typething = "saw"
		PositionEntity w\entityhandle, PickedX(), PickedY(), PickedZ()
		CreateSomeParticles(PickedX(), PickedY(), PickedZ(), 100, 100, 100, 6)
		mp5timer = MilliSecs()
	EndIf 
	EndIf
	EndIf
	EndIf
	
	For b.hole = Each hole
		EntityAlpha b\entityhandle, b\alpha
		b\alpha = b\alpha-0.02
		If b\alpha <= 0
		FreeEntity b\entityhandle
		Delete b
		EndIf
	Next
	
	For k.laserhole = Each laserhole
		EntityAlpha k\entityhandle, k\alpha
		k\alpha = k\alpha-.1
		If k\alpha <= 0
		FreeEntity k\entityhandle
		Delete k
		EndIf
	Next 
	

End Function 


The problem is where you switch guns - where all the "HideEntity"'s and "ShowEntity"'s are.

I need to convert those Hide and ShowEntities to Object, but I don't know how.

(Sorry this is such a long post - I hope I've made it thorough enough :P)

Is it a problem with Globals?

Posting the same topic in two forums is a bad idea:

http://www.blitzbasic.com/Community/posts.php?topic=41777

I posted here, waited a while, and didn't get an answer.