Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: Bgoulette on January 24, 2019, 03:28:36 PM
-
Hi all. Is there some trick to getting fe.module_dir to work? Is it even a real thing? I don't see any reference to it in the front-end binding section on github, but I've seen it in other people's code. Is it something I have to assign? If so, what kinds of voodoo are involved? I have a shader in a module folder, but whenever I run my layout, I'm told it can't find the relevant file. If I move the shader file to the layout folder, it works, but in my module script, it's effectively ignored. What am I missing? Thanks for any help!
-
Works for me. Please post a snippet of your code.
-
Thanks for taking a look. I have a module under attract/modules/blurred-art In the module.nut file, I try to instantiate a shader that's in the same folder. I've tried variations of the following without success:
class BlurredArt {
// Stuff
constructor (...) {
shaderA = fe.add_shader( Shader.Fragment, "gauss_kernsigma_o.glsl" ); // Doesn't work
shaderB = fe.add_shader( Shader.Fragment, fe.module_dir + "gauss_kernsigma_o.glsl" ); // Doesn't work
shaderC = fe.add_shader( Shader.Fragment, fe.module_dir + "blurred-art/" + "gauss_kernsigma_o.glsl" ); // Doesn't work
}
}
The shader file is in the same folder (blurred-art) as the module.nut. Any ideas?
-
You should start printing to the console as a way to debug.
If the class is creating the shader, it should be a relative directory. If your trying to use the shader outside your module, you need the module path to be passed to the layout.
-
fwiw, I do print to the console...when I know what I'm looking for! :)
The module is what's creating and applying the shader, so just the shader name (fe.add_shader( Shader.Fragment, "gauss_kernsigma_o.glsl" );) should be all that's required? Yet that doesn't work. The console just tells me it can't find the shader in the layout "root." Which is confusing to me, because it's not supposed to be looking for it there.
The module is a wip. It does what I want (mostly) with the exception of finding the shader. I'm attaching it just for giggles.
-
I looked at the code on my iPhone. It looks like it would work. Are you extending the class in your layout? Store your path as a variable within the module class. Print it within the module class, and within your layout. Let me know what the results of each is.
-
Hi Keil,
Thanks to your suggestions, I discovered what I'd been doing wrong: I had both an older blurred-art.nut stand alone file in my modules folder as well as a blurred-art/ folder containing the relevant files. AM was looking at the first file instead of entering the folder. I must have dragged and dropped in the wrong place. Ugh. Such a simple mistake! Tracing the print output -- and realizing I wasn't getting anything no matter how many changes I made in module.nut -- got me looking in the right place. It's behaving like it should now! I greatly appreciate your advice! 8)
-
No problem. That’s why I suggested print to terminal. I can write a whole class and make a simple mistake because zombies have an open skull sometimes. 😂