Forum Mod Bakery Docs

P3D LUA interface [CustomFiles / Mod Resource request]

Please login to contribute to the conversation.
I accidently posted this early woops :p

A small request which would be awesome, would be to have some sort of way to interact and edit p3ds with some custom interface.

for example you could do things like

Shaders = GetChunks("0x11000") --Shaders

for i = 1,#Shaders do
    if Shaders[i].Name == "metal" then
        Shaders[i].Param("LIT").Value = 1
    end
end

Im not sure how hard that would be but would make things a lot easier
Whilst that may or not be added (entirely up to Lucas), Appel has (with some modifications from myself and Lucas) created a sort of library for it (Current version on the dev branch of rando)

It's used similarly to how your code works, for example it would be:
SHADER_CHUNK = "\000\016\001\000"
for ChunkPos, ChunkLen in FindSubchunks(P3DFile, SHADER_CHUNK) do
    local name = GetP3DString(P3DFile, ChunkPos + 12)
    if name == "metal" then
        --Code to edit
    end
end
A more robust example using more optimised edit methods is the most recent P3D editing function I made BrightenModel

EDIT: Just to add, this obviously isn't a perfect solution as it requires learning the chunk structure yourself for the chunks you're trying to modify, but it's the best option we have at this time.
I feel this thread should be posted here, as it is basically a direct reply.