Community Forum

Change texture in Lua

Forum Overview >> Scripting

CategoryScripting
Created06.07.2014 21:47


Thomas Nagels (Unknown) 06.07.2014 21:49
I wonder if it is possible to change an object's texture within a lua. I am building a led-barrier and I want to add a large number of possible signs and it would be a pain to have to add them all manually... Any tips on how to tackle this?

Tnx,

Thomas

Emil Drefers (Unknown) 07.07.2014 08:38
Hi Thomas,

you can't switch textures by using lua, but you can control a shader by using lua.
The shader would be used to select/toggle/switch parts of a texture to be displayed on your object. Basically the shader would change the UVs of your object.

Best,
Emil

Sebastian Lampe (Unknown) 07.07.2014 13:03
Hi Emil,

could you provide us with an example on how to access a shader via lua? Some functions to use or a code snippet? Or is this topic allready coverd by any tutorial or example mod?

This might be interesting for me as well (see my post on "terrain info": http://gdn.giants-software.com/thread.php?categoryId=3&threadId=1948)

Thanks and best,
Sebastian

Emil Drefers (Unknown) 07.07.2014 17:12
Hi Sebastian,

well, i can't provide you with a snippet of code, but if you dig just a little bit through the default lua scripts on ls-mods.de you'll surely find the command to set shader parameters.
It is also listed in the script documentation here at gdn.

The shader from which you'll propably can get the most inspiration is the uvOffsetShader.xml.
You can find it in the fs2013 installation directory (maps/shaders).

Best,
Emil



Note: Log in to post. Create a new account here.