If player stands on a Trigger_Use called "Sleep" if press e then he go fade to sleep i mean:
Sleep
Screen fades to black, then it will be black for a 5,10 sec idk, then when screen fades to normal after 5,10 sec the player will have full health.
![cookie](img/cookie.gif)
sleepx,sleepy = 1,1 -- coordinates of the button addhook("usebutton","sleepbut") function sleepbut(id,x,y) 	if x==sleepx and y=sleepy then 		local sleepi=image("gfx/sprites/block.bmp",320,240,2,id) 		imagealpha(sleepi,0) 		tween_alpha(sleepi,1000,1) 		timer(6000,"parse","lua tween_alpha("..sleepi..",1000,0)") --delay of 6 seconds because fading takes up 1 		timer(6000,"parse","sethealth "..id.." "..player(id,"maxhealth")) 		timer(7000,"parse","lua freeimage("..sleepi..")") --delay of 7 seconds because both fades take up 2 	end end
sleepx,sleepy = 1,1 -- coordinates of the button addhook("usebutton","sleepbut") function sleepbut(id,x,y) 	if x==sleepx and y=sleepy then 		local sleepi=image("gfx/sprites/block.bmp",320,240,2,id) 		imagealpha(sleepi,0) 		tween_alpha(sleepi,1000,1) 		timer(6000,"parse","lua tween_alpha("..sleepi..",1000,0)") --delay of 6 seconds because fading takes up 1 		timer(6000,"parse","sethealth "..id.." "..player(id,"maxhealth")) 		timer(7000,"parse","lua freeimage("..sleepi..")") --delay of 7 seconds because both fades take up 2 	end end
addhook("usebutton","sleepbut") function sleepbut(id,x,y) 	if entity(x,y,"name")=="sleep" then 		local sleepi=image("gfx/sprites/block.bmp",320,240,2,id) 		imagealpha(sleepi,0) 		tween_alpha(sleepi,1000,1) 		timer(6000,"parse","lua tween_alpha("..sleepi..",1000,0)") --delay of 6 seconds because fading takes up 1 		timer(6000,"parse","sethealth "..id.." "..player(id,"maxhealth")) 		timer(7000,"parse","lua freeimage("..sleepi..")") --delay of 7 seconds because both fades take up 2 	end end
addhook("usebutton","sleepbut") function sleepbut(id,x,y) 	if entity(x,y,"name")=="sleep" then 		local sleepi=image("gfx/sprites/block.bmp",320,240,2,id) 		imagealpha(sleepi,0) 		tween_alpha(sleepi,1000,1) 		timer(6000,"parse","lua tween_alpha("..sleepi..",1000,0)") --delay of 6 seconds because fading takes up 1 		timer(6000,"parse","sethealth "..id.." "..player(id,"maxhealth")) 		timer(7000,"parse","lua freeimage("..sleepi..")") --delay of 7 seconds because both fades take up 2 	end end
dofile(htdirectory .. 'GoSleep.lua')
--dofile(htdirectory .. 'GoSleep.lua')
addhook("usebutton","sleepbut") function sleepbut(id,x,y) 	if entity(x,y,"name")=="sleep" then 		local sleepi=image("gfx/sprites/block.bmp",320,240,2,id) 		imagealpha(sleepi,0) 		tween_alpha(sleepi,1000,1) 		timer(6000,"parse","lua tween_alpha("..sleepi..",1000,0)") --delay of 6 seconds because fading takes up 1 		timer(6000,"parse","sethealth "..id.." "..player(id,"maxhealth")) 		timer(7000,"parse","lua freeimage("..sleepi..")") --delay of 7 seconds because both fades take up 2 	end end
dofile(htdirectory .. 'GoSleep.lua')
--dofile(htdirectory .. 'GoSleep.lua')
local speed=player(id,"speedmod") imagescale(sleepi,20,15) parse("speedmod "..id.." -100") timer(7000,"parse","speedmod "..id.." "..speed)