A script for converting Articy Draft X output to Ren'py code

A place to discuss things that aren't specific to any one creator or game.
Forum rules
Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.
Post Reply
Message
Author
pb_choco
Newbie
Posts: 3
Joined: Sat May 18, 2024 10:47 am
Contact:

A script for converting Articy Draft X output to Ren'py code

#1 Post by pb_choco »

I made a script for generating Ren'py code based on exported Articy Draft X data. You can find it here.

It generates a fully working game but it's pretty bare-bones text. No images or anything so you'll definitely have some more work to do editing and customizing the generated code. However for those who like to use visual design tools like Articy, being able to save all the work of manually translating the Articy output to Ren'py code may be a real time-saver.

I did a fair amount of testing with this but if you do something I didn't, you very well may break it. I'm happy to work with you to get it working on your project if you are willing to work with me. I don't hang out here much but I'll try to check in from time to time. You're welcome to message me here or on gitlab and I'll try to address any issues people find.

XYNTA
Newbie
Posts: 3
Joined: Wed May 22, 2024 8:16 am
Contact:

Re: A script for converting Articy Draft X output to Ren'py code

#2 Post by XYNTA »

Hi! This script is just what I was looking for. Thank you very much for sharing your work!

I tried to run it on test projects built in articy (Dracula, Maniac Manfred X) and got the following error. Can you point me in the direction of solving the problem?

Code: Select all

/Users/admin/PycharmProjects/atorp/venv/bin/python atorp.py Dracula/manifest.json 
INFO:root:Loading from Dracula/manifest.json...
INFO:root:Output directory: 
INFO:root:Output dialog text as menu captions where applicable: False
Traceback (most recent call last):
  File "/Users/admin/PycharmProjects/atorp/atorp.py", line 739, in <module>
    main()
  File "/Users/admin/PycharmProjects/atorp/atorp.py", line 725, in main
    game_data = load(args.manifest_filename)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/admin/PycharmProjects/atorp/atorp.py", line 599, in load
    objs.load_from_dict(object_data)
  File "/Users/admin/PycharmProjects/atorp/atorp.py", line 138, in load_from_dict
    obj = create_object(self, item)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/admin/PycharmProjects/atorp/atorp.py", line 186, in create_object
    obj = cls(root, properties)
          ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/admin/PycharmProjects/atorp/atorp.py", line 208, in __init__
    self.load_properties(properties)
  File "/Users/admin/PycharmProjects/atorp/atorp.py", line 348, in load_properties
    super().load_properties(properties)
  File "/Users/admin/PycharmProjects/atorp/atorp.py", line 260, in load_properties
    assert len(input_pins) < 2, f'Too many input pins for id {self.unique_id}'
           ^^^^^^^^^^^^^^^^^^^
AssertionError: Too many input pins for id 0x0100000000000756

Process finished with exit code 1

pb_choco
Newbie
Posts: 3
Joined: Sat May 18, 2024 10:47 am
Contact:

Re: A script for converting Articy Draft X output to Ren'py code

#3 Post by pb_choco »

I ran the script on the projects you mentioned and saw the issue you mentioned, along with some others. Thanks for giving me the opportunity to improve my script. There are a few things going on here. The Dracula project has some circular paths that I hadn't tested against before, and those caused infinite loops which broke things. I've made some changes to the script to attempt to address this issue. Please download the latest version and give it a try.

However that was not the cause of the error you saw. That was caused by a shortcoming in my script. It expects dialogues and dialogue fragments to have only one input pin. Although this causes some of the sample projects to break, it shouldn't be a problem in practice. It's easy to build a project without extra input pins. In fact you can easily just remove the extra input pin on the main dialogue in the Dracula project and it will then not give you that error.
Screenshot.png
(46.67 KiB) Not downloaded yet
That extra input pin doesn't seem to be doing anything that I can tell. The other error I got in the Dracula script is due to it having two Dialogues with the same name. This doesn't work for my script because the Dialogue name is used as the output Ren'py script file name, and if two Dialogues have the exact same name the file would get overwritten. So the script throws an error to help you avoid causing that issue. I don't know why you would need two Dialogues in a project with the exact same name, but again it's really easy to avoid.

Once I fixed those two issues in the source project the new script was able to export the Dracula project just fine.

The Maniac Manfred X project also has a Dialogue with two input pins. They were not completely unnecessary though, so I couldn't just delete one to fix it. It would require a bit of restructuring in that project to fix the issue. Quite doable, but for new projects it should be easy to avoid. You can still express any logic flow you want, there are multiple ways to do it that don't require multiple input pins.

If that turns out to be a significant restriction let me know and I'll see about upgrading the script to handle more input pins. I didn't do it at the start because I was trying to keep the problem manageable. Flattening a graph structure like the one generated by Articy into Ren'py code is not a simple task, and since limiting input pins doesn't in any way (that I could identify) limit your expressiveness, it seemed like a reasonable compromise.

But again if that's something you need, just let me know, and ideally provide a use case for it so I can understand the problem I'm trying to solve.

XYNTA
Newbie
Posts: 3
Joined: Wed May 22, 2024 8:16 am
Contact:

Re: A script for converting Articy Draft X output to Ren'py code

#4 Post by XYNTA »

Thank you for fast update! I think I'm on one step further :D
But there are still some difficulties so far.
At the moment the conversion is completed, but there are errors in the log and the renpay itself can't start using the generated files.

Steps for reproduction:
Removed the extra pin from the tutorial and renamed the repetitive dialog in the Dracula demo.
Unloaded the json from Articy.
Ran a script to convert to RenPy.
Copied the resulting files into an empty RenPy project.

I have backed up all my steps with screenshots for clarity. I put the screenshots of my steps, the output of atorp, the generated files for RenPy and the error log from RenPy in the archive(Attached to this message).
run_logs.zip
(1.58 MiB) Downloaded 13 times
At first I thought the errors were because I was running the script on macos. But after running the script on windows for the test, I realized that the result is the same on both platforms.

If I can provide more information or run some tests, just let me know ;)

pb_choco
Newbie
Posts: 3
Joined: Sat May 18, 2024 10:47 am
Contact:

Re: A script for converting Articy Draft X output to Ren'py code

#5 Post by pb_choco »

Hi thanks for the reply. I've updated the code a bit to handle some of the idiosyncrasies of the sample projects. For example they sometimes have conditions that don't have any actual code, just a comment. Those are not valid conditions. So I changed the script to default those to True and output a warning when those are encountered. There were also some characters in some of the labels that were not valid in Ren'Py labels, so I improved my filter for those.

With this updated code the only errors that still happen when I convert the Dracula project are due to stage directions. Those are output directly as they are encountered in the project, but Ren'Py doesn't know what to do with them. My expectation with this script is that when creating a project in Articy that it would be done with the fact in mind that it would be converted to Ren'Py eventually, and so you would only use features that can be converted. So stage directions in Articy should only contain valid Ren'Py code.

However I realize that you can only do that if you know what those limitations are, and I failed to document them. I have attempted to rectify that now. In addition to updating the code, I also updated the README with these known limitations, and I'll add any more that I've forgotten as they come up.

In the Dracula project I edited each of the remaining errors due to stage directions in Ren'Py and then the project ran.

I don't think that those limitations restrict your ability to build games in Ren'Py in any way. It's just that there is not a direct one-to-one correlation in Ren'Py for every feature in Articy. If you come across something that's not being converted that you think could be brought over, please let me know and I'll look into it.

XYNTA
Newbie
Posts: 3
Joined: Wed May 22, 2024 8:16 am
Contact:

Re: A script for converting Articy Draft X output to Ren'py code

#6 Post by XYNTA »

Thank you so much! Didn't have time to test it right away. Now it works:) I'm ashamed to ask for something else, considering the amount of work done. And I don't have enough experience in RenPy to form adequate requests. Perhaps in the future I will come again. Once again, thank you very much for the tool! 🙏

Post Reply

Who is online

Users browsing this forum: No registered users