reepblue Posted October 14, 2023 Share Posted October 14, 2023 I'm trying to make an editor extension that'll create new files from the editor. I'm working on a "Create New Material" function, but I get an error with the Save command saying it expects usedata type and not a string, although I feel like this code is correct. local extension = {} function CreateNewMaterial() local file = RequestFile("Select Material Location", "", "Ultra Engine Material File (*.mat):mat", 0, true) if file ~= nil then local mat = CreateMaterial() if mat ~= nil then mat:SetColor(1,1,1,1) local shaderfamily = LoadShaderFamily("Shaders/PBR.fam") if shaderfamily then mat:SetShaderFamily(shaderfamily) shaderfamily = nil end mat:Save(file); end end end function extension.hook(event, extension) if event.id == EVENT_WIDGETACTION then if event.source == extension.menuitem then CreateNewMaterial() end end end -------------------------------------------------------------------- -- Add menu item -------------------------------------------------------------------- local menu = program.menu:FindChild("Create", false) if menu ~= nil then local submenu = menu:FindChild("Asset", false) if submenu == nil then submenu = CreateMenu("Asset", menu) end extension.menuitem = CreateMenu("Material", submenu) end ListenEvent(EVENT_WIDGETACTION, extension.menuitem, extension.hook, extension) I also tried making a table and saving it, but it didn't work ether. local a = ctable() a["material"] = nil a["material"]["shaderFamily"] = "Shaders/PBR.fam" SaveTable(a, file) What am I doing wrong here? Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Josh Posted October 14, 2023 Share Posted October 14, 2023 I just had the command exposed incorrectly in the Lua binding code. It's fixed in the editor now and the fix is uploaded. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
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.