Jump to content


Photo

Draw String


  • Please log in to reply
4 replies to this topic

#1 IAmFumbles

IAmFumbles

    GMC Member

  • New Member
  • 3 posts

Posted 27 August 2011 - 11:34 AM

What I'm trying to do is get a string to draw when i click the key "T" of which the id is "20"
I have the code inside the draw function and it draws although its not drawing when I click T.

if keyboard_check(20)
    {
    return draw_text_color(16, 16, "Fly", c_red, c_red, c_red, c_red, c_red)
    }
    else
    {
    return draw_text_color(16, 16, "Fly", c_green, c_green, c_green, c_green, c_green)
    }
It comes up "Fly" in green when I start the game and doesn't do anything when I click T, What have I done wrong?

- Using GML Pro 8.0
  • 0

#2 LOS.A

LOS.A

    GMC Member

  • GMC Member
  • 597 posts
  • Version:GM8

Posted 27 August 2011 - 12:09 PM

The ASCII ID of 'T' is 84, not 20. 20 is the paragraph sign.
ord() returns the ASCII index of the first character of the string within, so just write:
if keyboard_check(ord('T')) //The T must be big
    //Execute

Edit: Look up 'String handling functions' in the manual.

Edited by LOS.A, 27 August 2011 - 12:09 PM.

  • 0

#3 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 19935 posts
  • Version:GM:Studio

Posted 27 August 2011 - 12:11 PM

Quite right LOS.A. Also, return is not used like that. I would remove that too and just leave the draw_text_color()...
  • 0

#4 IAmFumbles

IAmFumbles

    GMC Member

  • New Member
  • 3 posts

Posted 27 August 2011 - 12:19 PM

Quite right LOS.A. Also, return is not used like that. I would remove that too and just leave the draw_text_color()...

Oh I've been modding minecraft in java and I thought it was gonna be kind of the same, thanks guys! :P
  • 0

#5 Shadowrend

Shadowrend

    Master of Shadows

  • GMC Member
  • 2783 posts
  • Version:GM8

Posted 27 August 2011 - 01:20 PM

Minecraft uses java. GM uses GML. Those are two different. If every language was the same, then why does java and gml exist? We'd use an universal one.

Logic my friend. Or at least using brain.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users