local smallWordTextCreated = false

function onCreatePost()
    makeLuaText('smallCenterWord', '', 1280, 0, 0)
    setTextAlignment('smallCenterWord', 'center')
    setTextSize('smallCenterWord', 32) -- Smaller size
    setTextFont('smallCenterWord', 'mainfont.ttf') -- Use your custom font here
    setTextColor('smallCenterWord', 'CCCCCC') -- Light gray color
    setTextBorder('smallCenterWord', 2, '000000')
    setObjectCamera('smallCenterWord', 'other') -- UI layer
    setProperty('smallCenterWord.alpha', 0)
    addLuaText('smallCenterWord')
    smallWordTextCreated = true
end

function onEvent(name, value1, value2)
    if name == 'SmallCenterWord' and smallWordTextCreated then
        if value1 == 'on' then
            setTextString('smallCenterWord', value2)
            runTimer('recenterSmallText', 0.01)
            doTweenAlpha('smallWordFadeIn', 'smallCenterWord', 1, 0.3, 'linear')
        elseif value1 == 'off' then
            doTweenAlpha('smallWordFadeOut', 'smallCenterWord', 0, 0.3, 'linear')
        end
    end
end

function onTimerCompleted(tag)
    if tag == 'recenterSmallText' then
        setProperty('smallCenterWord.x', (screenWidth / 2) - (getProperty('smallCenterWord.width') / 2))
        setProperty('smallCenterWord.y', (screenHeight / 2) - (getProperty('smallCenterWord.height') / 2))
    end
end
