Hard Light Productions Forums

Modding, Mission Design, and Coding => The Scripting Workshop => Topic started by: Nightstorm on June 27, 2017, 10:43:21 am

Title: Change texture in game
Post by: Nightstorm on June 27, 2017, 10:43:21 am
Question...I want to have multiple skins for a Viper based on different Battlestars.  So let's say the default skin for a Viper MK7E is the Theseus.  And let's say the default player ship for a mission is a standard Mk7.  The mission is flying off of the Perseus.  I want to be able and switch the MK7E's skin to a Perseus name plate instead of the standard one if the player chooses to fly a 7E.

 Is there a way to accomplish that?  Can this be scripted fairly easily?

Thanks!
Title: Re: Change texture in game
Post by: zookeeper on June 27, 2017, 11:45:45 am
Yes, it should be pretty simple to script. Once you have the rest of the scripting hook logic figured out and you have a ship handle to peruse, the basic texture replacement process is very straightforward:

Code: [Select]
my_new_tex = gr.loadTexture("filename_without_extension")
my_ship_handle.Textures["current_texture_filename_without_extension"] = my_new_tex
Title: Re: Change texture in game
Post by: The E on June 27, 2017, 11:55:45 am
However, doing this through table-based texture replacement and the usual way of creating a "Viper Mk7#Perseus" ships.tbl entry also works and may be easier to use.
Title: Re: Change texture in game
Post by: Nightstorm on June 27, 2017, 12:01:01 pm
If I understood correctly, I can make a copy of the existing ship in the table or a tbm and just change the name to #shipname?  Would I then still have to use "change-ship-class"?  Or is it controlled by some other means by having for example MKVII#Perseus vs MKVII#Theseus?
Title: Re: Change texture in game
Post by: Nightstorm on June 27, 2017, 12:04:03 pm
Yes, it should be pretty simple to script. Once you have the rest of the scripting hook logic figured out and you have a ship handle to peruse, the basic texture replacement process is very straightforward:

Code: [Select]
my_new_tex = gr.loadTexture("filename_without_extension")
my_ship_handle.Textures["current_texture_filename_without_extension"] = my_new_tex

Presuming the player ship will always be "Red 1" what I'm looking for it to do is check if the ship class is "x" and if it is change the textures to "x".  Where x is not the default texture for the ship.