• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Visual (SOLVED) How to put "or" argument into Drag and Drop text boxes?

C

Colorized

Guest
I have this "if key pressed" block that has a W input in it. How do I make it say, for example, W or space?
 
That doesn't do the same thing.
ord("W") is 87
vk_space is 32
Therefore, ord("W") || vk_space = 87 || 32 = 1
Basically, you're checking a key that doesn't exist on keyboards. Code isn't English; you can't treat it as such. You'll have to do what FrostyCat says and separate the expressions:
Code:
keyboard_check_pressed(ord("W")) || keyboard_check_pressed(vk_space)
 
Where are you getting the vk_anykey from?
Because
Code:
if keyboard_check(ord("W") || vk_space)
is exactly the same as typing
Code:
if keyboard_check(vk_anykey)
When you type "ord("W") || vk_space", you aren't polling both the W and Space keys. You're checking if either ord("W") or vk_space are true. In GM, all numbers >= 0.5 are equivalent to true, or 1. Both ord("W") and vk_space are larger than 0.5, so (ord("W") || vk_space) always returns true. True is equivalent to 1. Guess which GM keyword is equivalent to 1? vk_anykey.

EDIT: See this tutorial if you have any further questions about using ||: https://forum.yoyogames.com/index.php?threads/how-not-to-use-and.12871/
 
Top