Here you go.
Note: i've used variables for the size, and position of the sprite and the text, along with variables for the text colour. I prefer doing it this way because then it's easier to make changes when you need to.
--sprite size
local bgbox_spr_sizex = 40
local bgbox_spr_sizey = 30
--sprite location
local bgbox_spr_locx = 30
local bgbox_spr_locy = 25
--text location
local text_size = 4
--text location
local text_locx = 30
local text_locy = 25
--text colour
local text_red = 200
local text_green = 0
local text_blue = 0
function textsprite_init(e)
bgbox_sprite = LoadImage("scriptbank\\images\\textspritetest\\bg.png")
bgbox_icon = CreateSprite(bgbox_sprite)
SetSpriteSize (bgbox_icon,bgbox_spr_sizex,bgbox_spr_sizey)
SetSpriteDepth (bgbox_sprite, 100) -- this sends the sprite to the back of the screen
SetSpritePosition(bgbox_icon, 200, 200) -- this sets the initial position of the sprite off screen (needed for pasting sprites, DO NOT CHANGE)
end
function textsprite_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 100 then
TextCenterOnXColor(text_locx,text_locy,text_size,"This text is on top",text_red,text_green,text_blue)
PasteSpritePosition(bgbox_icon,bgbox_spr_locx,bgbox_spr_locy) -- this shows the sprite on the screen behind the text at the variable location
end
end
i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
i3 , Intel integrated graphics, 6GB memory, 512GB Generic SATAIII Win8.1.
Intel Celeron (duel Core), Radeon integrated graphics, 4GB memory, 180gB Generic SATAII, WinVista.
Q6600, Intel integrated graphics, 8GB memory, 512GB Generic SATAII, Win7.