Why does this not work and how can I make it work?

Questions about GP commands and how to do things

Moderator: MSandro

Post Reply
MSandro
Posts: 162
Joined: Jul 26th, '17, 21:12

Why does this not work and how can I make it work?

Post by MSandro » Mar 14th, '18, 22:06

Hi, I've tried a around several hours to figure out how to load a other project. With no result.
I've found this block in the GP libs:
openProjectFromFile.png
openProjectFromFile.png (10.08 KiB) Viewed 7468 times
On run this block GP looks like this:
Bildschirmfoto von »2018-03-14 23-06-22«.png
How could I get this to work?

vickiS
Posts: 7
Joined: Oct 5th, '17, 16:26
Contact:

Re: Why does this not work and how can I make it work?

Post by vickiS » Mar 15th, '18, 22:52

I'm just wondering how you are trying to implement this. The open project button triggers this function but the button itself is outside the script editor. When I played with this in the script editor it never got past the clearProject method in openProject because the block disappears I think. I also managed somehow to disappear the class methods in the ProjectEditor class browser and cause an Undefined function: blockSpecs error. Reloading fixed that. I tried setting it up in a class browser but that's not working for me either. I haven't tried loading an external file into the system browser.

MSandro
Posts: 162
Joined: Jul 26th, '17, 21:12

Re: Why does this not work and how can I make it work?

Post by MSandro » Mar 16th, '18, 08:13

Okay, so I have to find a way how to run a script in "background". So it'll not be stopped/removed on a clear.

Edit: I've tried around to solve this about several hours. I used tasks, broadcasts and more. I also tried to add some code to the GP backend, but with no result. I am not sure how to solve this.

I've already tried how to import a class with a small script/block successfully.
Bildschirmfoto_2018-03-16_09-13-03.png
Bildschirmfoto_2018-03-16_09-13-03.png (7.03 KiB) Viewed 7432 times
This works fine because no code will be removed.

MSandro
Posts: 162
Joined: Jul 26th, '17, 21:12

Re: Why does this not work and how can I make it work?

Post by MSandro » Mar 18th, '18, 21:36

I've now found a nice litle workaround:

This works:
Bildschirmfoto vom 2018-03-18 22-18-13.png

This doesn't work:
Bildschirmfoto vom 2018-03-18 22-19-09.png


Because I've found a "openProjectFromFile" in the "Stage" class, I've tried to replace "ProjectEditor" with "Stage" and ... it works!
It could look a bit glitchy but it works. This block only load the given project in the stage, not in the project editor, so all classes you've created are still there. But the project you've want is visible in the stage, GP will automaticaly go into presentation mode too. I think there are more advantages to this method than disadvantages. For example, you can easily add elements to a post-loaded project, such as a close button to return to another project, without having to make any changes in the loaded project.


Here is a example:
openProject.gpp
(8.91 KiB) Downloaded 435 times

Post Reply