GameMaker Keep getting a fatal error. I have 2 lines of code, please help.

S

ShadowDrakgon

Guest
Hello! I'm new to game making/coding, can someone tell me whats wrong? I'm trying to get my character to move up/jump and its saying I have an error in line one. Can someone help me?


___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object oPlayer:

Variable oPlayer.W(100002, -2147483648) not set before reading it.
at gml_Object_oPlayer_Step_0 (line 1) - if keyboard_check(ord(W)) {
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_oPlayer_Step_0 (line 1)
 

Joe Ellis

Member
with ord( ) the value in the brackets has to be a string, so just put ord("W"), otherwise it thinks W is a variable
 

rIKmAN

Member
Hello! I'm new to game making/coding, can someone tell me whats wrong? I'm trying to get my character to move up/jump and its saying I have an error in line one. Can someone help me?


___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object oPlayer:

Variable oPlayer.W(100002, -2147483648) not set before reading it.
at gml_Object_oPlayer_Step_0 (line 1) - if keyboard_check(ord(W)) {
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_oPlayer_Step_0 (line 1)
If you are new to gamemaker / coding I recommend you get familiar with the manual, as it will answer 99% of the problems you have as a beginner.

Read it, search it, use it. A lot.

For example the manual page for the ord() function tells you it takes a string which should be 1 character and capitalised, as well as giving a code example of how it should be used in practice for you to look at.

https://docs2.yoyogames.com/source/_build/3_scripting/4_gml_reference/strings/ord.html

Even just quickly comparing your code to the example would show you the error you were making and allow you to fix it quickly.
 
S

ShadowDrakgon

Guest
If you are new to gamemaker / coding I recommend you get familiar with the manual, as it will answer 99% of the problems you have as a beginner.

Read it, search it, use it. A lot.

For example the manual page for the ord() function tells you it takes a string which should be 1 character and capitalised, as well as giving a code example of how it should be used in practice for you to look at.

https://docs2.yoyogames.com/source/_build/3_scripting/4_gml_reference/strings/ord.html

Even just quickly comparing your code to the example would show you the error you were making and allow you to fix it quickly.
Thank you, this is helping a lot!
 
Top