local m = mtimer local S = m.translator -- Build the formspec frame -- -- With this function the size and title of a formspec are set. It also adds -- the default buttons to the formspec. All calculations for the buttons are -- done automatically but directly correlate to the size of the formspec. -- -- All formspecs are by minimum 6 units wide and 2 units high to allow enough -- space for the buttons and the button texts. -- -- @param width The width of the formspec in formspec units -- @param height The height of the formspec in formspec units -- @param title The title for the formspec (a label shown on the formspec) -- @return string the constructed “frame” mtimer.build_frame = function (width, height, title) local formspec_frame = [[ size[+width,+height] label[0,-0.125;+title] container[0,+position] button_exit[+exitpos,0;+bwidth,1;exit;]]..S('Exit')..[[] button[+mainpos,0;+bwidth,1;main_menu;]]..S('Main Menu')..[[] button[+defaultpos,0;+bwidth,1;default;]]..S('Default')..[[] container_end[] ]] local width = width < 6 and 6 or width local height = height < 2 and 2 or height return formspec_frame:gsub('%+%a+', { ['+width'] = width, ['+height'] = height, ['+title'] = minetest.formspec_escape('[mTimer] '..title), ['+position'] = height-0.7, ['+bwidth'] = width/3, ['+exitpos'] = 0, ['+mainpos'] = width/3, ['+defaultpos'] = (width/3)*2 }) end