So I went about it a different way and succeeded. Thank you smallg for trying to assist. I basically brute forced my way into the script. I am sure a gifted scripter can do this more efficiently.
The code for all that need it.
-- Title page script
TITLE_NEW = 1
TITLE_ABOUT = 2
TITLE_QUIT = 3
g_strStyleFolder = ""
g_strBestResolution = ""
g_imgBackdrop = 0
g_sprBackdrop = 0
g_imgButton = {}
g_imgButtonH = {}
g_sprButton = {}
g_posButton = {}
g_imgCursor = 0
g_sprCursor = 0
function title_init()
-- determine style folder we are in
file = io.open("titlesbank\\style.txt", "r")
if file ~= nil then
io.input(file)
g_strStyleFolder = io.read()
io.close(file)
end
-- read graphics page settings
file = io.open("savegames\\graphics.dat", "r")
if file ~= nil then
io.input(file)
iGraphicChoice = tonumber(io.read())
SetGameQuality(iGraphicChoice)
io.close(file)
end
-- read graphics page settings
file = io.open("savegames\\sounds.dat", "r")
if file ~= nil then
io.input(file)
iSoundChoice = tonumber(io.read())
iMusicChoice = tonumber(io.read())
SetGameSoundVolume ( iSoundChoice )
SetGameMusicVolume ( iMusicChoice )
io.close(file)
end
-- choose ideal resolution
BackdropOff()
DrawSpritesLast()
resolutions = require "titlesbank\\resolutions"
g_strBestResolution = resolutions.findclosest()
-- backdrop add random image Modify by myke ************************************************************
math.randomseed( os.time() )
p = math.random(0, 4)
if p==0 then
--image1
g_imgBackdrop = LoadImage("titlesbank\\" .. g_strStyleFolder .. "\\" .. g_strBestResolution .. "\\title.png")
g_sprBackdrop = CreateSprite ( g_imgBackdrop )
SetSpritePosition ( g_sprBackdrop, 0, 0 )
SetSpriteSize ( g_sprBackdrop, 100, 100 )
end
--else return
if p==1 then
--image2
g_imgBackdrop = LoadImage("titlesbank\\" .. g_strStyleFolder .. "\\" .. g_strBestResolution .. "\\title1.png")
g_sprBackdrop = CreateSprite ( g_imgBackdrop )
SetSpritePosition ( g_sprBackdrop, 0, 0 )
SetSpriteSize ( g_sprBackdrop, 100, 100 )
end
--else return
if p==2 then
--image3
g_imgBackdrop = LoadImage("titlesbank\\" .. g_strStyleFolder .. "\\" .. g_strBestResolution .. "\\title2.png")
g_sprBackdrop = CreateSprite ( g_imgBackdrop )
SetSpritePosition ( g_sprBackdrop, 0, 0 )
SetSpriteSize ( g_sprBackdrop, 100, 100 )
end
-- else return
if p==3 then
--image4
g_imgBackdrop = LoadImage("titlesbank\\" .. g_strStyleFolder .. "\\" .. g_strBestResolution .. "\\title3.png")
g_sprBackdrop = CreateSprite ( g_imgBackdrop )
SetSpritePosition ( g_sprBackdrop, 0, 0 )
SetSpriteSize ( g_sprBackdrop, 100, 100 )
end
-- else return
if p==4 then
--image5
g_imgBackdrop = LoadImage("titlesbank\\" .. g_strStyleFolder .. "\\" .. g_strBestResolution .. "\\title4.png")
g_sprBackdrop = CreateSprite ( g_imgBackdrop )
SetSpritePosition ( g_sprBackdrop, 0, 0 )
SetSpriteSize ( g_sprBackdrop, 100, 100 )
end
-- end of Myke edit ***************************************************************************
-- buttons
for i = 1, TITLE_QUIT, 1
do
if i == TITLE_NEW then strButtonName = "start"
elseif i == TITLE_ABOUT then strButtonName = "about"
elseif i == TITLE_QUIT then strButtonName = "quit-game"
else strButtonName = ""
end
g_imgButton[i] = LoadImage("titlesbank\\" .. g_strStyleFolder .. "\\" .. strButtonName .. ".png")
g_imgButtonH[i] = LoadImage("titlesbank\\" .. g_strStyleFolder .. "\\" .. strButtonName .. "-hover.png")
g_sprButton[i] = CreateSprite ( g_imgButton[i] )
SetSpriteOffset ( g_sprButton[i], GetImageWidth(g_imgButton[i])/2, 0 )
g_posButton[i] = 30+(i*10)
SetSpritePosition ( g_sprButton[i], 50, g_posButton[i] )
end
-- cursor
g_imgCursor = LoadImage("titlesbank\\" .. g_strStyleFolder .. "\\cursor.png")
g_sprCursor = CreateSprite ( g_imgCursor )
ActivateMouse()
--DrawSpritesFirst()
end
function title_main()
-- control menus
SetSpritePosition ( g_sprCursor, g_MouseX, g_MouseY )
iHighlightButton = 0
if g_MouseX > 50-(GetImageWidth(g_imgButton[1])/2) and g_MouseX <= 50+(GetImageWidth(g_imgButton[1])/2) then
for i = 1, TITLE_QUIT, 1
do
if g_MouseY > g_posButton[i] and g_MouseY <= g_posButton[i]+GetImageHeight(g_imgButton[i]) then
iHighlightButton = i
end
end
end
for i = 1, TITLE_QUIT, 1
do
if iHighlightButton == i then
SetSpriteImage ( g_sprButton[i], g_imgButtonH[i] )
else
SetSpriteImage ( g_sprButton[i], g_imgButton[i] )
end
end
if g_MouseClick == 1 then
if iHighlightButton==TITLE_NEW then
SwitchPage("")
end
if iHighlightButton==TITLE_ABOUT then
SwitchPage("about")
end
if iHighlightButton==TITLE_QUIT then
QuitGame()
end
end
-- debug (need DrawSpritesFirst())
--Prompt ( "g_MouseClick=" .. g_MouseClick .. " g_strBestResolution=" .. g_strBestResolution )
end
function title_free()
-- free resources
for i = 1, TITLE_QUIT, 1
do
DeleteSprite ( g_sprButton[i] )
DeleteImage ( g_imgButton[i] )
DeleteImage ( g_imgButtonH[i] )
end
DeleteSprite ( g_sprBackdrop )
DeleteImage ( g_imgBackdrop )
DeleteSprite ( g_sprCursor )
DeleteImage ( g_imgCursor )
DeactivateMouse()
end
Remember to back up you title.lua file
You will need title.png,title1.png, title2.png, title3.png, and title4.png images in all your resolution folders of the titlesbank you choose.
NOTE: DO not just replace the title.lua script with this, if you do, then you will not have save and load function buttons.
Copy from the above between the **************** lines and insert into your title.lua script.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit, Screen resolution 1680 x 1050.