Script.exportTextures() only exports textures when the handler is a single class
Opened this issue · 0 comments
Script.exportTextures()
uses isUsesTextures()
to detect whether a script handler contains a command where textures might be in use. isUsesTextures()
does not detect values of script handlers when those are grouped together into a UsesTextures[]
, () => UsesTextures
or () => UsesTextures[]
. When this happens exportTextures() is not being called on the ScriptCommand instance.
This is okay:
const oldTexture = new Texture({ filename: '[wood]_ALICIAROOM_LAMBRIS02.jpg' })
const newTexture = Texture.fromCustomFile({
filename: 'youre-winner.jpg',
sourcePath: './textures',
})
entity.script?.on('init', new TweakSkin(oldTexture, newTexture))
This isn't:
const oldTexture = new Texture({ filename: '[wood]_ALICIAROOM_LAMBRIS02.jpg' })
const newTexture = Texture.fromCustomFile({
filename: 'youre-winner.jpg',
sourcePath: './textures',
})
entity.script?.on('init', () => new TweakSkin(oldTexture, newTexture))
This also isn't working:
const oldTexture = new Texture({ filename: '[wood]_ALICIAROOM_LAMBRIS02.jpg' })
const newTexture = Texture.fromCustomFile({
filename: 'youre-winner.jpg',
sourcePath: './textures',
})
entity.script?.on('init', () => {
return [
new TweakSkin(oldTexture, newTexture)),
// other commands
]
)
Events are stored as: Record<string, ScriptHandler[]>
and ScriptHandler is ScriptHandlerBase | (() => ScriptHandlerBase)
. ScriptHandlerBase is string | string[] | ScriptCommand | ScriptCommand[]
A ScriptHandler might need to get partially validated when exportTextures is called. Until then if a ScriptCommand uses textures then it has to be added one-by-one to an event.