Zeilenanzahl von Strings auswerten und weiterverarbeiten

  • GM 6

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Zeilenanzahl von Strings auswerten und weiterverarbeiten

    Hallo ihr Lieben,

    ich habe nen kleines Problem. Vielleicht fehlt mir nur der richtige Ansatz. Ich bastel gerade an einer Textengine, die nicht nur automatischen Zeilenumbruch, sondern auch eine bestimmte Maximalzahl an Zeilen haben soll(in meinem Fall 4). Ist diese erreicht soll der text der schon geschrieben wurde ersetzt werden durch den Rest der noch übrigbleibt, solange bis alles abgearbeiten wurde.

    Den normalen Zeilenumbruch habe ich mit draw_text_ext gelöst, allerdings das mit der Zeilenzahl, hab ich gerade Schwierigkeiten.

    Ich habe mich schon Seitenweise belesen wie man das machen könnte, aber nix davon gefällt mir so richtig, bzw. funktioniert nicht.

    Nunja hier das Script soweit:
    scr_typer:

    GML-Quellcode

    1. //argument0 = text to type
    2. //argument1 = draw textbar true/false
    3. //argument2 = initiate text true/false
    4. //argument3 = text color
    5. //argument4 = name - who is talking?
    6. //NOTE: no autoswitch to new after box is full
    7. coll = argument3
    8. draw_set_color(coll)
    9. draw_set_font(fnt_normal);
    10. draw_set_halign(fa_left);
    11. draw_set_valign(fa_top);
    12. global.conversation = true;//conversation started
    13. global.text = argument0;//text to type
    14. global.name = argument4;//name - who is talking?
    15. //initialize Text
    16. if argument2 = true// first time loading this text = initialize it
    17. {
    18. char = 0//set position of letter to first letter(character)
    19. text_complete = false//set text_complete to false ... not ready with typing
    20. }
    21. ////////////////////////////////////////////////////////////////////////
    22. //use the text - NO HEIGHT-WRAP!!!!
    23. if text_complete = false// if still typing
    24. {
    25. txt = string_copy(global.text,0,char+1);//copy the given text to txt
    26. char +=1//count up the letters
    27. if string_length(txt) = string_length(global.text)//if u have typed all
    28. {
    29. //draw sprite mouse click!!!!!!!!!!!!! - WORKS 100%
    30. draw_sprite(spr_mouse_click,1,492,room_height-84)//mouse_click symbol - animated needed!?!
    31. //important!!!!!!!!
    32. text_complete = true;//give out u are ready with typing
    33. char = 0;// reset to start-position - not needed??? - only for height wrap????
    34. }
    35. }
    36. //use the text end
    37. ////////////////////////////////////////////////////////////////////////
    38. //speed it up
    39. if mouse_check_button_pressed(mb_left) = true //if mouse pressed left
    40. {
    41. text_complete = true //you are done
    42. char = string_length(global.text) //end the text
    43. txt = global.text //set the string to the text
    44. io_clear(); //stop generating events(clear mouse+keyboard)
    45. //draw sprite mouse click!!!!!!!!!!!!! - WORKS 100%
    46. draw_sprite(spr_mouse_click,1,492,room_height-84)//mouse_click symbol - animated needed!?!
    47. //important!!!!!
    48. }
    49. //speed it up end
    50. ////////////////////////////////////////////////////////////////////////
    51. //draw this
    52. //if argument1 = true//if draw textbar = true --- senseless!!!
    53. {
    54. draw_sprite(spr_textbar,0,0,room_height-100);//draw textbar
    55. draw_sprite(spr_name_box,0,0,room_height-134);//draw name box
    56. draw_text(7,room_height-130,global.name)//draw name - who is talking
    57. draw_text_ext(7,room_height-95,txt,-1,475);//and the text - autowrap included - height wrap needed
    58. }
    59. //draw this end
    60. screen_refresh();//refresh - needed!!!!
    61. ////////////////////////////////////////////////////////////////////////
    62. //Last Part
    63. if text_complete = false
    64. {
    65. if global.music = "ON"
    66. {
    67. sound_play(sound0);//typing sound
    68. }
    69. sleep(30);//wait for 30 ms -> type-speed!!!!!
    70. scr_typer(global.text,true,false,coll,global.name);//redo all without need to re-initialize because u have done already
    71. }
    72. else// u are ready with typing
    73. {
    74. global.conversation = false;//give out u are ready with conversation
    75. sound_stop(sound0);//be quiet!!!!
    76. mouse_wait();//wait until any mouse button is pressed
    77. screen_refresh();//refresh
    78. screen_redraw();//redraw - delete spr_mouse-clicker!!! - important!!!
    79. io_clear();//clear all keyboard and mouse states
    80. }
    Alles anzeigen


    Ich hoffe englische Erklärungen stören nicht, ich mag english einfach :P
    Aufrufen tu ich das dann über :
    von wo auch immer:

    GML-Quellcode

    1. scr_message("text","name")
    2. scr_message("anderer text","anderer name")

    usw.

    scr_message:

    GML-Quellcode

    1. scr_typer(argument0,true,true,c_white,argument1);


    Ich hoffe ich hab mich verständlich ausgedrückt, und jemand kann mir da weiterhelfen.

    Greetz
    Es gibt viel zu tun, packen wir´s an !!!
    Für Rechtschreibfehler sind die verantwortlich, die sie entdecken :P.