M
m4meteor
Guest
I am trying to do a system that detects the largest string in an array so that I can calculate the width of my menu. (if i have an obvious mistake pls don't bully im new)
It doesn't seem to work as menu_width gives out a value of gui_margin*2 (which is 100).
This code is placed in the create event.
Code:
menu[2] = "New Game"
menu[1] = "Continue"
menu[0] = "Quit"
// Find the largest string in the array to calculate width of menu.
var largest_string = ""
for (var str_n = 0; str_n > array_length_1d(menu); str_n = str_n + 1)
{
if string_length(menu[str_n]) > string_length(largest_string)
{
menu[str_n] = largest_string
}
}
draw_set_font(fnt_menu)
menu_width = string_length(largest_string)+(gui_margin * 2)
This code is placed in the create event.