Simple syntax problem

Blitz3D Forums/Blitz3D Beginners Area/Simple syntax problem

Skel(Posted 2003) [#1]
Can someone help me out with this:

If KeyDown(203) And Not (KeyDown(200) Or KeyDown(208)) Then

I'm trying to say "if the player is pressing left without pressing up or down at the same time". I've tried a bunch of combinations - Blitz don't like it :(


darklordz(Posted 2003) [#2]
try...
If Not Keydown(200)
	If Keydown(203) Or Keydown(208)
		;Blaaat....
	EndIf
EndIf



Skel(Posted 2003) [#3]
Yep, got it with:

If Not KeyDown(200) Or KeyDown(208) Then
If KeyDown(203) Then

Thanks for that. Apologies for the silly post - it's late where I am and the mind starts to numb...


Koriolis(Posted 2003) [#4]
You could have just added some parenthesis:
If KeyDown(203) And (Not (KeyDown(200) Or KeyDown(208))) Then 



Tricky(Posted 2003) [#5]
Koriolis formula should work, in my opinion.. using ( and ) can prevent you a lot of trouble... In most cases you can better use them if unneeded then leave them out and risk that they are needed...

My opinion... Always use them in complex formulas if you're not sure...


Skel(Posted 2003) [#6]
Makes sense - thanks for the tips. Got it back to one line with the code from Koriolis...