I am making a custom menu for a custom dungeon, duh lol. Well the system works and all, except the cancel button jumps around a lot from one menu to the next when it shouldnt.

This menu works great when it starts out. Yep its perfect!!! Then when you hit start it takes you to the image below.

Now this also works perfectly, and cancel takes you back to the above title screen, then things get messed up.
After you return to the title screen exit takes you BACK to...image below...wtf

Then cancel takes you back to title screen as it should, it can do this for some time before it FINALLY EXITS the game... o.0 none of the other menus have this problem that I have seen yet, so here is all the code, which might be a lot and could be partially copy and paste, but wth who cares it works right? Well most of it works.
Code: Select all
function front_door_draw(bmp, mx, my)
dsb_bitmap_draw(gfx.title, bmp, 0, 0, false)
end
function start_menu_draw(bmp, mx, my)
dsb_bitmap_draw(gfx.start_menu, bmp, 0, 0, false)
end
function chara_build_draw(bmp, mx, my)
dsb_bitmap_draw(gfx.select_menu, bmp, 0, 0, false)
end
function front_door_click(x, y, b)
if (b == 1) then
if (x > 20 and x < 157) then
if (y > 248 and y < 287) then
dsb_sound(snd.click)
local v = dsb_fullscreen(start_menu_draw, start_menu_click, nil, true)
return v
end
end
if (x > 20 and x < 231) then
if (y > 305 and y < 344) then
if (gt_savegames > 0) then
dsb_sound(snd.click)
return 1
end
end
end
--exit button
if (x > 20 and x < 112) then
if (y > 359 and y < 397) then
dsb_sound(snd.click)
return 2
end
end
end
end
function start_menu_click(x, y, b)
if (b == 1) then
if (x > 58 and x < 313) then
if (y > 123 and y < 183) then
dsb_sound(snd.click)
local v = dsb_fullscreen(chara_build_draw, chara_build_click, nil, true)
return v
end
end
if (y > 207 and y < 270) then
dsb_sound(snd.click)
return 0
end
--cancel button
if (y > 290 and y < 356) then
dsb_sound(snd.click)
local v = dsb_fullscreen(front_door_draw, front_door_click, nil, true)
return v
end
end
return nil
end
function chara_build_click(x, y, b)
if (b == 1) then
if (x > 97 and x < 167) then
if (y > 115 and y < 179) then
dsb_sound(snd.click)
end
end
if (x > 97 and x < 167) then
if (y > 212 and y < 274) then
dsb_sound(snd.click)
end
end
if (x > 187 and x < 209) then
if (y > 115 and y < 179) then
dsb_sound(snd.click)
end
end
if (x > 187 and x < 209) then
if (y > 211 and y < 275) then
dsb_sound(snd.click)
end
end
--cancel button
if (x > 48 and x < 308) then
if (y > 358 and y < 430) then
dsb_sound(snd.click)
local v = dsb_fullscreen(start_menu_draw, start_menu_click, nil, true)
return v
end
end
end
return nil
end
function front_door(savegames)
gt_doorstate = 0
gt_savegames = savegames
local v = dsb_fullscreen(front_door_draw, front_door_click, nil, true)
if (v == 999) then
gt_door_opening = true
return (dsb_fullscreen(front_door_draw, nil, nil, false))
else
return v
end
end