Export resources to open formats (like Construct2)

Forum for plugin, effect and behavior programmers. Please use the Help & Support forum for help using Construct.

Post » Wed May 02, 2012 9:53 am

Hello everybody,

I am a programmer wanting to use Construct Classic as event and sprite behavior editor. To integrate CC to my current project's pipeline I would need to be able to export event sheets, properties and other info into an open and readable format (similarly to what Construct 2 does with XML).

Now, I searched the forums for quite a while and I could not find anything related so I assumed that it is either trivial (and I am making a stupid question) or it hasn't been done yet.

I would appreciate if anyone can help find out which one is it and, in case it's the 2nd, the advisable way to go (e.g., Plugins, compiling the CC GUI and implementing a new saving procedure etc.).

Many thanks in advance

PS: I prefer to use CC as opposed to Construct 2 because it's open source.
B
19
S
4
G
4
Posts: 70
Reputation: 3,896

Post » Wed May 02, 2012 10:20 am

This is not possible in Construct Classic. Part of the reason we started Construct 2 is to re-engineer the whole architecture to be more modular, such as with our exporter system (although we haven't released the exporter development kit yet).

So why not try going with C2? You could just read event XML files directly out the project folder rather than having to deal with Classic.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Wed May 02, 2012 10:28 am

Thanks for the quick reply. This answers my first question handsomely.

Are you sure it's not possible at all? Maybe it would just be very bothersome to do so. I am currently looking at the cpps used for creating cap file, just dumping the event sheet structure into a txt file looks like a feasible first step.

PS: I would really like to make it work with CC if possible as I would like to keep the ability to hack away/workaround any issues I may find.Alcemon2012-05-02 10:29:50
B
19
S
4
G
4
Posts: 70
Reputation: 3,896

Post » Wed May 02, 2012 5:55 pm

[quote]Are you sure it's not possible at all? Maybe it would just be very bothersome to do so.[/quote]
It's bothersome to do so. Images and Layouts are simple enough to extract but events are tricky since ACE names are not stored in the cap, only number indexes.

I made a python module to read/edit cap files that may be useful:
http://dl.dropbox.com/u/5426011/utility/capreader.py
It more or less mirrors the cpp files for saving/loading cap files.
B
79
S
24
G
54
Posts: 4,747
Reputation: 40,757

Post » Fri May 04, 2012 8:07 am

Wow, you have saved me a world of pain.

Thanks a lot.
B
19
S
4
G
4
Posts: 70
Reputation: 3,896

Post » Fri May 04, 2012 9:34 pm

Hello again, running the script you posted on spaceship.cap from the demo page, gives me the following result:

>>> test=capreader.capfile('spaceship.cap')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "capreader.py", line 130, in __init__
    this.rw(cap)
File "capreader.py", line 199, in rw
    rwArray(cap,this,'layouts','C',CLayout)
File "capreader.py", line 67, in rwArray
    new.rw(cap)
File "capreader.py", line 236, in rw
    rwArray(cap,this,'objects','iC0','uid',CObj,'obj')
File "capreader.py", line 80, in rwArray
    new.rw(cap)
File "capreader.py", line 268, in rw
    rwHeader(cap,'CObj', 3)
File "capreader.py", line 50, in rwHeader
    assert name==newname, 'invalid header %s!=%s'%(name,newname)
AssertionError: invalid header CObj!=?C?C?BdB???~?>????Sprite??Sprite6

I will try to debug it over the next week (as Python is not my forte) but if the problem is trivial to anyone please feel free to enlighten me.

Thanks again for all the help.Alcemon2012-05-04 21:42:00
B
19
S
4
G
4
Posts: 70
Reputation: 3,896

Post » Fri May 04, 2012 10:31 pm

I can't reproduce that error. Did you open the cap file in construct and re-save it? I designed the script to only work with cap files saved with construct 0.9996 or newer. I also have only tested the script with python 2.6 and 2.7.
B
79
S
24
G
54
Posts: 4,747
Reputation: 40,757

Post » Sat May 05, 2012 4:45 pm

Im using python 2.7.3 and the Construct that is currently up for download (R1.2).

I will try resaving the cap, without resaving and finally debugging and repost here the findings.

Thanks again for all the help
B
19
S
4
G
4
Posts: 70
Reputation: 3,896

Post » Sun May 06, 2012 8:57 am

Ok, I tried the code on the cap without resaving it in the new Construct and predictably I got a version error (posted at the end of this post for completeness).
With resaving in the new CC I get the message that I originally posted.

I will try debugging (and actually trying to understand the code) and post the results here.

Thanks

--result when running the cap without resaving in a new CC--

>>> test=capreader.capfile('spaceshipo.cap')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "capreader.py", line 130, in __init__
    this.rw(cap) #<---
File "capreader.py", line 145, in rw
    rwHeader(cap,'CApplication',18)
File "capreader.py", line 51, in rwHeader
    assert version==newver, 'invalid version %d!=%d'%(version,newver)
AssertionError: invalid version 18!=8
B
19
S
4
G
4
Posts: 70
Reputation: 3,896

Post » Sun May 06, 2012 7:59 pm

Works like a charm with Python 2.6.

Apparently the problem was that I was using Python 2.7+

Thanks for everything!
B
19
S
4
G
4
Posts: 70
Reputation: 3,896

Next

Return to Construct engineering

Who is online

Users browsing this forum: No registered users and 0 guests