stom66 icon

EditableNotecard.lua

stom66 | PRO | 01/09/21 06:15:52 PM UTC (Edited) | 0 ⭐ | 3202 👁️ | Never ⏰ | []
Lua |

2.37 KB

|

None

|

0 👍

/

0 👎

function onLoad(save_data)
    --set the default text to match the object description
    text = self.getDescription()
 
    --update the XML Input field once the asset has finished loading
    Wait.condition(
        function() updateXml() end,
        function() return self.loading_custom == false end
    )
end
 
function updateXml()
    --calculate the vertical offset needed for the InputField
    local size     = self.getBounds().size
    local scale    = self.getScale()
    local z_offset = ((self.getCustomObject().thickness * 100) - (self.getBounds().offset.y * 200)) / -2 -1
 
    --size, in percent, of the image that should be covered by the input field
    local inputSize = 90
 
    --main xml styling
    local xml = {
        {
            tag = "InputField",
            attributes = {
                --edit the style of your input field here
                caretBlinkRate      = 0.85,
                caretColor          = "#323232",
                caretWidth          = 1,
                characterLimit      = 0,
                characterValidation = "None",
                color               = "#00000000", --8-digit hex code, last 2 are alpha. change to ff to see the background
                fontSize            = 45,
                lineType            = "MultiLineNewLine",
                placeholder         = "Click here to edit the text",
                rectAlignment       = "MiddleCenter",
                rotation            = "0 0 180",
                scale               = "0.5 0.5 0.5",
                selectionColor      = "rgba(0.65,0.8,1,0.75)",
                textColor           = "#cccccc",
                --don't edit the following fields, adjust size by changing "inputSize" above
                id                  = "field",
                onEndEdit           = "xml_endEdit",
                text                = text,
                position            = "0 0 "..z_offset,
                width               = size.x * (inputSize * 2) / scale.x,
                preferredWidth      = size.x * (inputSize * 2) / scale.x,
                height              = size.z * (inputSize * 2) / scale.z,
                preferredHeight     = size.z * (inputSize * 2) / scale.z,
            }
        }
    }
    self.UI.setXmlTable(xml)
end
 
function xml_endEdit(player, value, id)
    self.setDescription(value)
end

Comments