How to change texture and save it?

Hello bge community, this is my first post in a forum, hopefully i’m doing everything right.

So basically i was wondering if anyone knows or have an idea of how to change a texture image source and save it untill it gets changed again. kinda like in Call of Duty with gun camo or in older Need for Speed car vinals (that are not editable).
thank you for any help.

:ba:<<hehe Mr. T

To exchange texture you can either use replace mesh or video texture.

You can save the “change status” as any other status via a custom python controller.

example on storing/restoring


storage["mesh name"] = objectToSaveFrom.meshes[0]
...
objectToLoadTo.replaceMesh(storage["mesh name"])

Thank you for replying,

To exchange texture you can either use replace mesh or video texture.

Yeah i figured that part out. I used a videotexture script, but i have no clue how to save a change.

heres my blend file
tex change.zip (2.07 MB)

take a look at it when you can, thank you for all the help.

https://www.opengl.org/discussion_boards/showthread.php/185739-Store-a-2D-texture-to-file

GLSL

I’m not looking to create a texture to save, i already have the textures needed. I simply want to save which texture is default after selecting it, so when the game is open up again it remains on the last chosen texture.
Sorry, but thx for the help

Too low level there BPR.

What you will do is save a reference to the texture. So if it’s something like a color for camo, you can save the RGB components (using python’s file API, pickle or any number of other options).
If it’s which image is being used, save the file name and write something to load it.

i tried that, i keep getting an error in the consol, im still kinda of a novice in python.
do you have any code suggestions?

The code I posted is GLSL and probably won’t work without some help from someone who knows more,

if your setting the texture in game,

just store that value in a global dictionary ,

then on starting recall that global dictionary

( see save/ load python)

really interesting. i thought you were sending me somewhere to make a texture(in game), but i’m not too experienced to understand it, if you have a sample script by any chance that would be much appreciated. if not its ok, i’ll eventually figure it out. thx allot for pointing me in the right direction.