Table of Contents

Set-N-Delete: desc2float

Set the prim text (aka floating text or hover text) to the value of the object's Description field. There are two versions, one really simple and another with a slightly fancier effect.

Simple

Just grab the description and set it:

desc2float-simple.lua
-- desc2float - Set float text from object description
-- self-deleting
 
local function main()
    -- Set the floating text
    ll.SetText(ll.GetObjectDesc(), vector.create(1, 1, 1), 1.0);
 
    -- and delete it
    ll.RemoveInventory(ll.GetScriptName());
end
 
main()

Fancy

desc2float-fancy.lua
-- desc2float - Set float text from object description
-- self-deleting
 
-- Set to the desired float text, or leave empty to use the object description
-- Use '~' to insert a newline
local FLOAT_TEXT = ""
 
local color = vector.create(1, 1, 1)
local alpha = 1.0
 
local function main()
    if FLOAT_TEXT == "" then
        -- get description
        FLOAT_TEXT = ll.GetObjectDesc()
    end
 
    -- do it with Lua string manipulation
    ll.SetText(FLOAT_TEXT:gsub("~", "\n"), color, alpha)
 
    -- and delete it
    ll.RemoveInventory(ll.GetScriptName())
end
 
main()

LSL