GMS 2 GMS2 keyboard_check ord not working (SOLVED)

Discussion in 'Programming' started by SmallShank, Mar 7, 2017.

  1. SmallShank

    SmallShank Guest

    Hello Everyone,

    I'm new to Game Dev and I'm learning code and starting fresh as of yesterday.

    I've been following the tutorials online and I'm stuck with the movement of my object.

    I've watched the video and entered the code and it does work, however, I don't want traditional arrow keys to move my character.

    I want to use WSAD as movement keys and have used the following code:

    if (keyboard_check(ord('D')) x = x + 4;

    I'm getting this compile error:

    Object: obj_player Event: Step at line 1 : invalid token

    If anyone can help explain why the code isn't working I'd be very grateful. I've checked online and read posts and found the ord code and just can't put my finger on it #feelinglikeapropernewb

    Thanks guys!
  2. YellowAfterlife

    YellowAfterlife ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ Forum Staff Moderator

    Apr 21, 2016
    GMS2 does not allow to use single-quoted strings for such - change ord('D') to ord("D") and it'll be fine.
    RujiK and SmallShank like this.
  3. SmallShank

    SmallShank Guest

    Thank you so much for the help. I first off tried your suggestion and it didn't work...then I added 'then' after the keyboard check quotations mark, it worked...then i went back into the code, removed 'then' and it worked fine, as per your suggestion. Maybe it's still a little buggy as in beta :\

    Thanks again buddy :)
  4. Schyler

    Schyler Member

    Sep 13, 2016
    Why wouldn't it ? Hasn't GML always lexed these the same ?
  5. TheouAegis

    TheouAegis Member

    Jul 3, 2016
    Probably had to do with compatibility issues.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice