1
2
3
4
5
6
7
8
9
10
11
12
13
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