Call () with inputs () in a custom block throws error

I know Jens thinks that the create variables library and primitives shouldn't exist (among many other libraries & primitives) but I was bored and wanted to challenge myself. Like, a lot. So I took a crack at creating a block in vanilla Snap! that reports the value of a variable just by its name, similar to var_get(name).

I had many trials and failures until I realized the following code outputted something that should work.
untitled script pic (49)

This outputs
untitled script pic (50)
which is what I am looking for. When I call this, however, I get an error (even when z exists)- there's no error message or anything, the block just glows red.

untitled script pic (51)
untitled script pic (52)

Again- no error message. Just an angry red reporter. Oddly enough, when I do this,
untitled script pic (53)
and call x again, I get the expected output- 1, the value of the variable z.

Is there an error in my code? Why is this happening?

This happened???
untitled script pic (54)
I was trying to drag the variable z into the "() input names: ()" block (as shown above), and the variable replaced the input name block. So I pressed CTRL+Z... and then this happened.

Running the block makes the variable x disappear- while the show box for x is still checked. Clicking on the show box makes the variable x reappear for an instant, then disappear again. The only way to get x to stay stable is to set x to a value other than... that... and then re-click the show box. Yeah.

EDIT: I forgot to include the project link!
Here's the project link in case anybody wants to look at all these weird occurences.

I don't think creating variables using metaprogramming works.

I'm not trying to create variables, just get their value. Again: like the var_get(name) primitive.

Creating variable reporter blocks using metaprogramming doesn't work. I tried it once in a compiler project I was making that compiles to Snap!.

Ohh, okay. Thanks for the clarification.

... but I still don't know why it returns an error... one without a message, even...

I know right?

(Yes, that is relevant to this topic)

untitled script pic(87)



you're welcome. it only works with globals as far as I can tell. maybe sprite vars too but haven't tested that

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.