Uhr

  • Hi Leute!
    Ich habe eine Uhr mit GameMaker erstellt.

    Ich hab das ins Draw-Event so gemacht:

    GML-Quellcode

    1. {
    2. var weekday;
    3. weekday = current_weekday;
    4. if (weekday = 1)
    5. {
    6. draw_text(32,32,current_year + ":" + current_month + ":" + current_day + ", Sonntag")
    7. }
    8. if (weekday = 2)
    9. {
    10. draw_text(32,32,current_year + ":" + current_month + ":" + current_day + ", Montag")
    11. }
    12. if (weekday = 3)
    13. {
    14. draw_text(32,32,current_year + ":" + current_month + ":" + current_day + ", Dienstag")
    15. }
    16. if (weekday = 4)
    17. {
    18. draw_text(32,32,current_year + ":" + current_month + ":" + current_day + ", Mittwoch")
    19. }
    20. if (weekday = 5)
    21. {
    22. draw_text(32,32,current_year + ":" + current_month + ":" + current_day + ", Donnerstag")
    23. }
    24. if (weekday = 6)
    25. {
    26. draw_text(32,32,current_year + ":" + current_month + ":" + current_day + ", Freitag")
    27. }
    28. if (weekday = 7)
    29. {
    30. draw_text(32,32,current_year + ":" + current_month + ":" + current_day + ", Samstag")
    31. }
    32. draw_text(32,112,current_hour + ":" + current_minute + ":" + current_second)
    33. }
    Alles anzeigen



    Jetzt wird aber folgende Fehlermeldung angezeigt:


    ERROR in
    action number 1
    of Draw Event
    for object object0:

    Error in code at line 19:
    draw_text(32,32,current_year + ":" + current_month + ":" + current_day + ", Mittwoch")

    at position 37: Wrong type of arguments to +.


    Was ist falsch?
    Hab ich zu oft das +-Zeichen verwendet oder was ist falsch?

    Bin hilflos!!! ?( :?:

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von Tobi ()

  • Ganz logisch:
    current_year und co. sind Zahlen!
    Du musst also string(current_year) usw. schreiben ^^

    Es gibt Strings (Texte) und Reals (Zahlen) im GM (zum Glück nicht mehr 8o ).
    Wenn du also einen Text zeichnen willst, musst du deine Zahlen mit string() erst zu Text machen.

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von copyboy ()

  • Danke funktioniert!

    GML-Quellcode

    1. {
    2. var weekday;
    3. weekday = current_weekday;
    4. if (weekday = 1)
    5. {
    6. draw_text(32,32,string(current_year) + ":" + string(current_month) + ":" + string(current_day) + ", Sonntag")
    7. }
    8. if (weekday = 2)
    9. {
    10. draw_text(32,32,string(current_year) + ":" + string(current_month) + ":" + string(current_day) + ", Montag")
    11. }
    12. if (weekday = 3)
    13. {
    14. draw_text(32,32,string(current_year) + ":" + string(current_month) + ":" + string(current_day) + ", Dienstag")
    15. }
    16. if (weekday = 4)
    17. {
    18. draw_text(32,32,string(current_year) + ":" + string(current_month) + ":" + string(current_day) + ", Mittwoch")
    19. }
    20. if (weekday = 5)
    21. {
    22. draw_text(32,32,string(current_year) + ":" + string(current_month) + ":" + string(current_day) + ", Donnerstag")
    23. }
    24. if (weekday = 6)
    25. {
    26. draw_text(32,32,string(current_year) + ":" + string(current_month) + ":" + string(current_day) + ", Freitag")
    27. }
    28. if (weekday = 7)
    29. {
    30. draw_text(32,32,string(current_year) + ":" + string(current_month) + ":" + string(current_day) + ", Samstag")
    31. }
    32. draw_text(32,112,string(current_hour) + ":" + string(current_minute) + ":" + string(current_second))
    33. }
    Alles anzeigen
  • Uh... optimierter Code ftw...

    Versuch das ganze bitte mit einem Script übersichtlicher zu machen.
    (Das hat dann auch den Vorteil, dass du eventuelle Erweiterungen nur EIN MAL verbessern musst.)

    GML-Quellcode

    1. //Script Name: scr_clock
    2. draw_text(32,32,string(current_year) + ":" + string(current_month) + ":" + string(current_day) + string(argument0));

    GML-Quellcode

    1. if (weekday = bla)
    2. {
    3. scr_clock(/*Wochentag*/);
    Hier werden sie geholfen:
    [Regeln] [GML] [Hilfe] [Suche] [Posten] [Duden.de]
    [Wenn das alles nicht mehr hilft] [Dunning-Kruger]


    "Die Vernunft sollte Autorität definieren; nicht umgekehrt!"
    "Selber denken regt das Gehirn an."
    - Niffel f.k.a. Kilik
  • Benutzer online 1

    1 Besucher