Why isn’t this system working?

What's problem you are encountering?
In my project Snap! Build Your Own Blocks the shaders don’t automatically update and only update when you set an effect, despite the code for refreshing them and the one for changing the graphic effect doing the same thing
What have you tried that didn't work?
Many many tests and I’m not sure what’s going wrong, i tried placing the block that does work correctly and refresh for a frame in the loop and it doesn’t work. I wanted to try and do it all myself but I’m at a complete loss as to what’s going on here

Here’s some screenshots I’m not sure how helpful this is

If you are still confused reading the help menus of the blocks in the project will tell you what you need to know about them

It’s a shame too, I wanted to drop this out of nowhere and have it be done and I was very close

Your CAN block reports True if the variable exists, but you use it where you seem to be wanting to test if the variable has the value True.

And you seem to have a variable named "shader" and another variable named "Shader" so that's as far as I can get into reading your code.

P.S. Also, please get out of the habit of using the PRIMITIVE block instead of using the library you're meant to use.

also, let me reiterate and emphasize that if you find yourself wanting to use the "make variables" library or primitives it's an indicator that you're thinking about it the wrong way. This is a simple rule: Need to make a variable programmatically? You don't understand what you're doing, think again!

I’ve sometimes had a problem similar to this
I run a project and some code refuses to run

The very nature of programming :slight_smile:

there’s nothing stopping it though
it just doesn’t run

the block sees if they exist and if they dont it creates them, the 2 shader variables are just a side effect of input names but it doesnt do anything to rename it

Why are you using the create variables primitives for settibg a variable? You can just use the set variable block, which is much better than using a grey extension block that serves no purpose other than to confuse new users looking at your code. I'm assuming you think using the extension blocks themselves gives a lot more performance, well it doesn't. It makes no difference if they're in a library, and you use the library blocks instead. The primitive set variable block is also probably faster than the extension function, all because it doesn't need to look up a function in a giant list. Of course this is talking in microseconds, but it still shows that the extension blocks aren't faster than the primitive blocks.

every little optimisation counts, the goal is to get this to run at 60 fps

and plus not having to use other libraries was a goal of mine for this, lets get back on topic

Still, the extension block is no faster than the primitive set variable block.


As Brian and Jens say -that's not a good goal.

can we get back on topic please? reguardless of wether or not im using the primitives or the library blocks it doesnt fix whatever is going on here

To put it another way, the style of your code doesn't lend itself to other Snappers interest in trying to work out why your code doesn't work.

We don't know how the primitive blocks work with their often obscure parameters.

Suggestion, alter it to work with standard libraries and just declare your variables at global, sprite or script level

ignore the variables being created they arent important

They ARE important as a source of your problem

The scope must be spelled exactly as "sprite"
Stage_pic script pic (2)

The "Can()" is somehow faulty. This one works
Stage_pic script pic (3)

whelp uh sorry about that i was very wrong
it seemed to be something with the repeat until because the contion would always return false even when set to true

well they are correct about the "Sprite" vs "sprite" issue. I tested it out, and using the capitalized text just creates a global variable. You wouldn't have to run into this specific issue if you just used the library blocks, or even better you created the variables manually, and didn't bother with adding or deleting variables via code (which also makes it slower because you have to check if the variable exists, if the variable already exists, you don't need to check).