Set-N-Delete: name2float
Set the prim text (aka floating text or hover text) to the value of the object's Name field. There are two versions, one really simple and another with a slightly fancier effect.
Simple
Just grab the name and set it:
- name2float-simple.lua
-- name2float - Set float text from object name -- self-deleting local function main() -- Set the floating text ll.SetText(ll.GetObjectName(), vector.create(1, 1, 1), 1.0); -- and delete it ll.RemoveInventory(ll.GetScriptName()); end main()
Fancy
- name2float-fancy.lua
-- name2float - Set float text from object name -- 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.GetObjectName() end -- do it with Lua string manipulation ll.SetText(FLOAT_TEXT:gsub("~", "\n"), color, alpha) -- and delete it ll.RemoveInventory(ll.GetScriptName()) end main()