Message box script
A script for a text screen in for instance an RPG. Very easy to use. Will display an image of the person wo is talking. The script is also capable of handling large amounts of text.
Message box script |
//////////////// Message box script ////////////////////
// // Copyright Simon Donkers 27-1-2005 // www.simondonkers.com - gmmentor@simondonkers.com // // argument0 is the text to draw // argument1 is the sprite of the speaker // argument2 is the color of the text // ///////////////////////////////////////////////////// string:= argument0; brush_color:= c_gray; //background color of the menu box font_color:= argument2; //text color font_size:= 18; //text size if sprite_get_height(argument1)<string_height_ext(argument0, -1, view_width[0]-sprite_get_width(argument1)-50) and string_height_ext(argument0,-1, view_width[0]-sprite_get_width(argument1)-50) < view_height[0]-40 then { height:= string_height_ext(argument0,-1, view_width[0]-sprite_get_width(argument1)-50); } if sprite_get_height(argument1) >string_height_ext(argument0, -1,view_width[0] - sprite_get_width(argument1) - 50) then { height:= sprite_get_height(argument1); } if string_height_ext(argument0,-1, view_width[0] - sprite_get_width(argument1) - 50) >view_height[0] -40 then { height:= view_height[0]-40; } while argument0!= '' { string:= argument0; //if message is smaller then the screen if string_height_ext(argument0, -1, view_width[0] - sprite_get_width(argument1) - 50) < view_height[0]-40 then { string:= argument0; argument0:= ''; } else { i:= string_length(argument0); while string_height_ext(string, -1, view_width[0] - sprite_get_width(argument1) - 50) > view_height[0]-40 { string:= string_copy(string,0,i-1); i-= 1; } while string_char_at(string,string_length(string))!= ' ' { string:= string_copy(string, 0, string_length(string) - 1); } argument0:= string_copy(argument0, string_length(string) + 1, string_length(argument0) - string_length(string)); } draw_rectangle(10, view_height[0] -30 -height, view_width[0]-10, view_height[0]- 10); draw_sprite(argument1,-1, 20,view_height[0] -20-height); font_align:= fa_left; draw_text_ext(sprite_get_width(argument1) + 30,view_height[0]- 20-height,string, -1,view_width[0]-sprite_get_width(argument1)-50); screen_refresh(); io_clear(); keyboard_wait(); } |