is there a place where i can find what the error codes mean? it makes debugging rather difficult, because there’s not any good way to know why the code is erroring, only where.
i have a program that dynamically loads images, but is stubborn to change textures, only putting in the console “Failed to set texture data (-5)”.
The source code. Unfortunately we do not have it documented in any other place.
The error comes from a call to SetDynamicTextureData()
:
And the constants are in gui.h
:
It seems like the texture you are using can’t be found, or something like that. Could you share the code you are using?
There’s an example here: Load texture
nevermind, this was caused by a typo in the texture name i was calling. m’s and n’s look a lot alike sometimes…
thank you for the help, though.
here’s the code, if you were still curious (annotated a bit for readability, too)
local tex =image.load(images[programdata.selectedimage].data ) --the data is the contents of the image file.
gui.new_texture("mimg", tex.width, tex.height, tex.type, tex.buffer)
mimg=true --this is used for texture clean-up later, to make sure its there before deleting.
gui.set_texture_data("mimg", tex.width, tex.height, tex.type, tex.buffer) --this is needed for the node to change its texture. deleting and making the texture does not work to swap textures for whatever reason. probably spaghetti code. (also where the typo was)
gui.set_texture(imageobjects["image"], "mimg" )
Sorry to bump in here,
I get an error that isn’t even in gui.h, -3, so must come from somewhere else. So far, I found one in resource.h: RESULT_RESOURCE_NOT_FOUND = -3
I try to load images into a slideshow:
The path is right, clicking on the link in the error message opens the image.
These images are also textures of 3d models. The gui in question is an overlay, the 3d models still behind it. Maybe that’s a reason for the error? In a 2d version with just the gui the code works without problems. Trying to suss it out right now.
sys.load_resource is for loading custom resources .
Have you added your asset as a custom resource?
Of course, I forgot to do this in the 3d project. Thank you very much for the super-speedy answer!