reepblue Posted February 3, 2024 Posted February 3, 2024 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 Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon!
Josh Posted February 9, 2024 Posted February 9, 2024 There is no string class in the table of contents. That page is not listed anywhere. You want the Lua string library: https://www.lua.org/pil/20.html 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without.
Recommended Posts
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.