Jump to content

Getting Editor Material Suffixes


reepblue
 Share

Recommended Posts

I'm trying to create an extension that'll allow quick material generation by right clicking on the image and selecting "Convert Image to DDS". The documentation with String:Right for lua isn't right and I think it's better that the extention should get the suffixes from the editor's config. 

Because of limited documentation on the addon system, how would I do this?

The bad code is commented out for now.

    if event.id == EVENT_WIDGETACTION then
        if event.source == extension.menu[1] then
            if program.assetbrowser.selectedfile then
                if program.assetbrowser.selectedfile.package == nil then                    
                    local imageext = string.lower(ExtractExt(program.assetbrowser.selectedfile.path))                  
                    if imageext == "png" then
                        local file = StripAll(program.assetbrowser.selectedfile.path)
                        --[[
                        -- TODO: Get the conversion suffix from the editor.
                        if string.right(10, file) == "_normalmap" or string.right(7, file) == "_normal" or string.right(4, file) == "_dot3" or string.right(2, file) == "_n" then
                            extension.ToTexture(program.assetbrowser.selectedfile.path, ".dds", TEXTURE_BC5, true)
                        elseif string.right(13, file) == "_displacement" or string.right(7, file) == "_height" or string.right(5, file) == "_disp" or string.right(2, file) == "_h" then
                            extension.ToTexture(program.assetbrowser.selectedfile.path, ".dds", TEXTURE_RED, true)
                        else
                            extension.ToTexture(program.assetbrowser.selectedfile.path, ".dds", TEXTURE_BC7, true)
                        end
                        ]]
                    end
                end
            end
        end

 

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...