hmm... interpreting complex text command?

Blitz3D Forums/Blitz3D Programming/hmm... interpreting complex text command?

Fuller(Posted 2007) [#1]
I've got a little space fight game i was screwing with and basically what you do is type a command such as:
M S4 behind S3
Where M stands for move and the S3 and 4 is the ship number. That command is the only one i have documented right now and should make ship S4 move behind S3.

My current code doesn't seem to work as it gives me a EntitydoesExist, which i think Is ent2, or it doesnt do anything at all.
Here's the code thanks for help:
Function Interpret(st$)
	
	Select Left$(st$,1)
		Case "M"
			
			If Instr(Lower$(st$),"flank") Or Instr(Lower$(st$),"behind") Or Instr(Lower$(st$),"trail") Then 
				For s.ship=Each ship
					If Instr(Lower$(com$),Lower$(s\sqd$)) And Instr(Lower$(st$),"flank "+s\sqd$)=0 Or Instr(Lower$(st$),"behind "+s\sqd$)=0 Or Instr(Lower$(st$),"trail "+s\sqd$)=0 Then 
						ent1=s\ent
						DebugLog "1: "+ent1
						Exit 
					EndIf
				Next
				For s.ship=Each ship 
					If Instr(Lower$(st$),"flank "+s\sqd$) Or Instr(Lower$(st$),"behind "+s\sqd$) Or Instr(Lower$(st$),"trail "+s\sqd$) Then 
						ent2=s\ent
						DebugLog "2: "+ent2
						Exit 
					EndIf 
				Next
				PositionEntity ent1,EntityX(ent2),EntityY(ent2)-5,EntityZ(ent2)
			EndIf 
	End Select 
End Function 


And if you need it heres the entire thing media and all (its not much)
[url http://www.fileden.com/files/2007/5/29/1124852/shipgame.zip]


big10p(Posted 2007) [#2]
Your problem is the PositionEntity command. ent1 and ent2 are only defined when the If condition/s are satisfied. When the If condition/s aren't satified, ent1 and/or ent2 won't get defined.


Fuller(Posted 2007) [#3]
ok, i need to get to my other computer to test this, i'll see if it works later...