Specificaly, I want a definitor block that runs some inner code, runs the hat block script, then continues to run inner code until done. I can’t find a way to do this because the block automatically stops running after using the report block.
maybe you can use the launch block before the report block
thats different
if the initial code is CODE A and the code after the hat block code is CODE B
using the launch block on CODE B will run CODE B at the same time as the hat block code
i want to run CODE A, then run the hat block script, and after thats done, run CODE B
what do you want to achieve exactly, give us a real example so we can figure out
It's sort of a strange thing to want to do... the usual idea of a procedure is that it does whatever it does all at once, and is then finished. So I second @loucheman's request for a real example.
Having said that, I think probably you can use continuations. I tried
but it didn't work, so someone who's better at this than I am should try.
Here's one way of doing it
However this will always run, regardless of whether the hat block is a condition hat or not. You can do this to mimic the regular hat block behaviour.
This can be useful when you want to write some script that runs some code, like cleanup code, after running a script. Here's an example of what you could do with it.
Should you do something like this in this way? Probably not, but it's a usecase. We can do something like this with c-blocks much easier, and also have a bit more control for when it runs and whatever setup script we run beforehand, such as positioning the sprit, so it's still not really practical to use a hat block.
Good work! I'm kinda sad that you had to use metaprogramming rather than just continuations, though. I guess a custom-hat script doesn't have the same context a regular procedure would?
I actually looked into it again, and snap does indeed run the script when you run it with the hat block, but the problem is that snap runs the code in the hat block, which we don't want (since the code in the hat block is already running). So unfortunately we have to use metaprogramming to remove the hat block.
I don't know. Can you send a script pic of it (right click the script and select "script pic"). With a script pic, you can drag and drop the image into snap, and it'll load the script in that image.
ohhhh let me fix it
edit: i fixed the issues, but the code still doesnt work. the thingis, its no longer actually running the hat block script
oh i made a lot of mistakes
aaaaaand it still doesnt work
Try dragging and dropping my script pic into snap. If it doesn't load, then click on the image to make it bigger, then drag and drop it.
oh it actually worked!
i looked more closely at the code and i think i realized the 2 problems
- i defined the ‘script under hat block’ without the warp block
- i accidently used an ‘any’ slot instead of a lambda slot
i should pay more attention to detail lol
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.














