Here's a very basic script using sprites and cursor as a difficulty menu for your game, it's very basic, only changing the players current hitpoints and the number of lives they have, i'm not 100% how well it will transfer across levels as i haven't tested it yet, but i'm pretty sure that jumping to a new level will retain the lives and health, so you should only need to use it in your first level.
Just open up the zip attached and drag the scriptbank folder into your gameguru\files folder, it will put everything where it needs to go.
Then in the editor, place a barrel, make it static = no, and always active = yes, and add difficulty_menu.lua (you will find it in scriptbank\dmenu)
You can see it working on the beginning of my video below:
Here's the code:
--sprite size
local bgbox_spr_sizex = 20
local bgbox_spr_sizey = 50
local bgbox2_spr_sizex = 100
local bgbox2_spr_sizey = 100
function difficulty_menu_init(e)
d_menu=0
cursor_im=LoadImage ( "scriptbank\\images\\dmenu\\cursor.png" )
bgbox_sprite = LoadImage("scriptbank\\images\\dmenu\\bgbox.png")
bgbox_icon = CreateSprite(bgbox_sprite)
SetSpriteSize (bgbox_icon,bgbox_spr_sizex,bgbox_spr_sizey)
SetSpriteDepth (bgbox_sprite, 100)
SetSpritePosition(bgbox_icon, 200, 200)
bgbox2_sprite = LoadImage("scriptbank\\images\\dmenu\\bgbox.png")
bgbox2_icon = CreateSprite(bgbox2_sprite)
SetSpriteSize (bgbox2_icon,bgbox2_spr_sizex,bgbox2_spr_sizey)
SetSpriteDepth (bgbox2_sprite, 50)
SetSpritePosition(bgbox2_icon, 200, 200)
end
function difficulty_menu_main(e)
PlayerDist = GetPlayerDistance(e)
--if PlayerDist < 1000 and d_menu==0 then
if d_menu==0 then
d_menu=1
cursor_sp=CreateSprite ( cursor_im )
FreezePlayer()
ActivateMouse()
end
if d_menu==1 then
TextCenterOnXColor(50,30,4,"Difficulty",200,0,0)
PasteSpritePosition(bgbox_icon,40,25)
PasteSpritePosition(bgbox2_icon,0,0)
SetSpritePosition ( cursor_sp , g_MouseX , g_MouseY )
TextCenterOnX(50,40,6,"Easy")
TextCenterOnX(50,50,6,"Normal")
TextCenterOnX(50,60,6,"Hard")
end
if g_MouseX>49 and g_MouseX<61 then
if g_MouseY>39 and g_MouseY<46 then
if g_MouseClick==1 and d_menu==1 then
DeleteSprite(cursor_sp)
UnFreezePlayer()
DeactivateMouse()
SetPlayerHealth(300)
SetPlayerLives(0)
PromptDuration("You have selected Easy Difficulty: 300 Health, 99 Lives",6000)
d_menu=2
g_player_hp_max = 300
end
end
end
if g_MouseX>49 and g_MouseX<61 then
if g_MouseY>49 and g_MouseY<56 then
if g_MouseClick==1 and d_menu==1 then
DeleteSprite(cursor_sp)
UnFreezePlayer()
DeactivateMouse()
SetPlayerHealth(200)
SetPlayerLives(3)
PromptDuration("You have selected Normal Difficulty: 200 Health, 3 Lives",6000)
d_menu=2
g_player_hp_max = 200
end
end
end
if g_MouseX>49 and g_MouseX<61 then
if g_MouseY>59 and g_MouseY<66 then
if g_MouseClick==1 and d_menu==1 then
DeleteSprite(cursor_sp)
UnFreezePlayer()
DeactivateMouse()
SetPlayerHealth(100)
SetPlayerLives(1)
PromptDuration("You have selected Hard Difficulty: 100 Health, 1 Life",6000)
d_menu=2
g_player_hp_max = 100
end
end
end
end
Note:
I forgot to mention, it doesn't adjust the max health, just the current health, so if you set your health in your player marker to 100 and choose easy you will get 300/100 displayed, i haven't been able to work out how to change the max health as the player starter marker overrides the script.
There is a variable referenced in there called g_player_max_health or something like that, it won't actually do anything for you because it's a variable i use in my health pack scripts to stop health packs healing over the max health (i forgot to take it out when i posted it).
You're probably better off making your own health HUD and displaying just current health or making a % based health bar so it doesn't look odd.
i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.