[Plugin] instance bank2

Post your completed addons to share with the community

Post » Sun Feb 24, 2013 4:04 pm

Ok, I did some more digging through related posts and it looks like this is by design. Destroy flags the sprite to be destroyed at the end of the event sheet per Ashley:

[QUOTE=Ashley] This is sort of by design... "Destroy" means "flag to be destroyed at the end of the event sheet". This is because people commonly write events like

Destroy Sprite
Create explosion at Sprite.X, Sprite.Y

If the Sprite was really destroyed, the explosion would have nowhere to be created because the Sprite doesn't have an X or Y co-ordinate any more. I could fix the two cases you've shown, but the object would still actually exist until the end of the event sheet, which might just make for some more confusing cases.[/QUOTE]

So I guess this means if one is loading an InstanceBank, the layout should not have any pre created objects of the saved type in it prior to the loadAllInstances call, otherwise, duplication occurs.

There I go, answering my own questions... lol

Thanks!

B
5
S
1
G
1
Posts: 9
Reputation: 908

Post » Mon Feb 25, 2013 12:46 am

@Dieck

Yes, you could call load many times , to create a lot of copies.
B
97
S
22
G
177
Posts: 4,111
Reputation: 103,525

Post » Thu Feb 28, 2013 2:08 am

@RexRainbow

So in order to avoid the duplication, would it make sense to stage the load one event cycle after destroying the objects?

Thanks!
B
5
S
1
G
1
Posts: 9
Reputation: 908

Post » Thu Feb 28, 2013 2:41 am

@Dieck

It depends on your design.
B
97
S
22
G
177
Posts: 4,111
Reputation: 103,525

Post » Thu Feb 28, 2013 2:52 am

@RexRainbow


Ok so given the example InstanceBank_savedUID, it seems no matter what I do to the original object sub and main, when LoadAllInstances get called, the newly load instances have new UIDs and the original instances always stay around. That would seem to indicate if you are loading objects from InstanceBank that were placed in the Layout editor, it will always duplicate on load with new UIDs. Is that the case?

Would it be more appropriate to use a Dictionary or CSV object to store the individual object state including UID and then reset the sprites from that structure?

Dieck2013-02-28 03:07:54
B
5
S
1
G
1
Posts: 9
Reputation: 908

Post » Thu Feb 28, 2013 3:27 am

@Dieck

"Would it be more appropriate to use a Dictionary or CSV object to store the individual object state including UID and then reset the sprites from that structure?"

It depends on you, too. This instance bank could be replaced by dictionary and event sheet.

Or you could save one instance into instance bank, then pick the JSON string and put it into dictionary.
[code]instance (sprite) -> instance bank -> dictionary[/code]
So that you could load instance as you want from dictionary.
[code]dictionary -> instance bank -> instance (sprite)[/code]
rexrainbow2013-02-28 03:27:55
B
97
S
22
G
177
Posts: 4,111
Reputation: 103,525

Post » Thu Feb 28, 2013 3:40 am

@RexRainbow

Ah I see! I will try that method and see how it works.

Thanks for the thought help on this! :)
B
5
S
1
G
1
Posts: 9
Reputation: 908

Post » Mon Mar 04, 2013 6:42 am

[QUOTE=rexrainbow] @Dieck

"Would it be more appropriate to use a Dictionary or CSV object to store the individual object state including UID and then reset the sprites from that structure?"

It depends on you, too. This instance bank could be replaced by dictionary and event sheet.

Or you could save one instance into instance bank, then pick the JSON string and put it into dictionary.
[code]instance (sprite) -> instance bank -> dictionary[/code]
So that you could load instance as you want from dictionary.
[code]dictionary -> instance bank -> instance (sprite)[/code]
[/QUOTE]

Would you make an example how to use dictionary for specificed instances using private variables to do not load ALL instances, only it can load some instances?
B
96
S
25
G
20
Posts: 3,052
Reputation: 22,638

Post » Mon Mar 04, 2013 4:26 pm

@Joannesalfa

Uh, not "load some instances", just "save specificed instances" in the bank, then read all saved instances to JSON string.
B
97
S
22
G
177
Posts: 4,111
Reputation: 103,525

Post » Tue Mar 05, 2013 12:15 pm

So how do you "save specificed instances"?

Is possible to load instances with registered instance variables like "AllowSaveInstance" ?

Every time you keep replying at me "Uh" at first place :P
B
96
S
25
G
20
Posts: 3,052
Reputation: 22,638

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: Kev5454, Kyatric, Lordshiva1948 and 5 guests