Saving Layouts?

For questions about using Classic.

Post » Mon Feb 08, 2016 9:58 pm

Yeah I mean making a list of like 700 objects is a pain but it's a doable pain. Any way to rip a list of object names out of a cap? (I'd have a much easier time excluding stuff not to save, but it's not a huge deal).

Curious to hear what the 'not quite actually an object' issue is though. Hopefully not another deep inset construct nightmare. D:
B
12
S
4
G
4
Posts: 238
Reputation: 2,426

Post » Mon Feb 08, 2016 11:46 pm

You can use this to get a list of all the object type names in a cap:
https://dl.dropboxusercontent.com/u/542 ... peDump.zip

just change the filename in the script. Also you can filter the dumped list by plugin, so if you wanted only sprites do this:
Code: Select all
for ot in cap.objtypes:
   if ot.ot.plugin=="Sprite":
      names+=ot.ot.name+","



The not "quite an object" issue I think has to do with objects being created outside of the event sheet so it doesn't do the usual stuff to move the new objects to the normal object lists from the new object lists. I recall messing with that a while back and the solution is to pick the objects with events somehow so it takes care of it, I think a for each would do it.
B
88
S
30
G
89
Posts: 5,106
Reputation: 60,323

Post » Tue Feb 09, 2016 9:37 pm

So the problem with this is like... what's the best way to do selection since creating objects by name doesn't seem to handle selection right?
B
12
S
4
G
4
Posts: 238
Reputation: 2,426

Post » Tue Feb 09, 2016 10:16 pm

I had a test, and when you do for example this:
Code: Select all
Start of layout
--- python: System.Create("Sprite", 1, 100,100)

always
--- Sprite: rotate 100*timedelta degrees clockwise


Only the new sprite will rotate.

But if you add a "for each" everything can be picked again.
Code: Select all
Start of layout
--- python: System.Create("Sprite", 1, 100,100)

for each sprite
---

always
--- Sprite: rotate 100*timedelta degrees clockwise


It only needs to be done after creating an object from python and even then it only needs to be done once. Also the object used can be anything.
B
88
S
30
G
89
Posts: 5,106
Reputation: 60,323

Post » Wed Feb 10, 2016 12:13 am

That's wild that even works.

Okay I am left with one question!

So if you take my example cap and change it to save "Latern" and you load the lantern... the size of it is all mucked. The width gets set to a value that makes no sense (18.somothernonsense). I thought it might be because it 'loops to' an dhas sprite parts of difference sizes and other such issues but it was impossible for me to recreate this in your example.

I can work around it in this one case but it's one of those things that's like "Oh uh.. is this... alright? This isn't going to fuck anything else up is it?" so knowing why it happens would be very useful. D:
B
12
S
4
G
4
Posts: 238
Reputation: 2,426

Post » Wed Mar 23, 2016 5:47 am

Getting back to integrating this (probably my next big project for the game) and fixed the size bug. Just had to set size after setting animations and bam. ANYWAYS I have one tiny problem.

So when stuff is all set up, animations are paused. I've tried throwing obj.ResumeAnim in a million different spots or just actually addressing objects and other stuff and it seems ResumeAnim is busted in python? or am I doing something wrong? Because it would be MUCH easier for me to be able to use python to restart the animations on the object list I'm providing rather than having a huge list of things to manually restart. Or I can put every animating object into a family. and restart that (I've... had some shadiness at one point with multiple families but I don't know if thats actually a construct bug or was just something I screwed up years ago?). Still if you know anything about restarting animations through python, let me know, but I guess it isn't really critical seeing as I have a backup solution.

edit: Actually thinking about this, I don't need to save the animation frame ANYWAYS if I'm saving immediately (which I would be doing for a production solution) so this might be totally unnecessary. But if its just a simple tweak, let me know.

edit2: Actually just ran into another snag. using the dump of objects name leads to an error of "more than 255 arguments". As in the dump works but using it with the saving code does not because there are some 700+ objects.I suppose passing a list of as one argument would be preferrable. I can maybe work that out with my very minimal python knowledge tomorrow, but of course any help is welcome.
B
12
S
4
G
4
Posts: 238
Reputation: 2,426

Post » Wed Mar 23, 2016 5:46 pm

Sprite.ResumeAnim() works. If it's an action with no parameters it needs the () so maybe that's what was missing.

For the 2nd edit, you can change the function from
def save(filename, *objtypes):
to
def save(filename, objtypes):
to make it use a list.

Then call the function with:
save("myfile.txt", [sprite,sprite2])
instead of
save("myfile.txt", sprite,sprite2)
B
88
S
30
G
89
Posts: 5,106
Reputation: 60,323

Post » Thu Mar 24, 2016 6:59 am

Ugh more problems. Getting tons of errors like -'NoneType' object is not callable-. I've identified at least two of these out of the huge list and they're... normal, sprite objects? The only thing special with them is they were in the family with the dash - in their name that got fixed by the python fixer... but even after I delete the family, the issue persists. The object (EnergyUp and HealthUp) saves fine in the old rojo test file I sent you which makes me think the fixer is doing something? But that's just a faint guess. Anyways sorry to keep going back to you but this one is -definitely- over my head. :|

http://kayin.moe/forrojo2.cap

Edit: also if I clone the object, the new object works fine?
B
12
S
4
G
4
Posts: 238
Reputation: 2,426

Post » Fri Mar 25, 2016 7:16 pm

That latest cap gives an error when opening.
"An invalid object in a condition was referenced"

I don't have time currently to dive into the cap file and find where the issue is. Basically it would involve opening the cap in python with capreader, going to where the object types are listed to get all the oids, then going through the event section and verifying the oid of every event is in the list.


I've never enjoyed the python error reporting in CC, it's kind of broken since it only gives an error and doesn't say where it happens. The most immediate idea that comes to mind is since python is case sensitive you might get errors like that if the capitalization isn't the same.
B
88
S
30
G
89
Posts: 5,106
Reputation: 60,323

Post » Fri Mar 25, 2016 7:41 pm

Wait when you run the cap or compile the cap? I don't get that error in either case, which is... strange.

edit: In case the issue is with opening it, I tore out some unused event sheets that might have caused that. kayin.pyoko.org/forrojo3.cap Not that it seems like you have the time to do much anyways. Capitalization is the same.

It's weird to think of things being mucked upside the cap but the object in question working perfectly fine. Hm...
B
12
S
4
G
4
Posts: 238
Reputation: 2,426

PreviousNext

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest