Bug Issue: I CAN'T OPEN A SCENE IN THE EDITOR


Pages: 1

KingMinion333

  • Junior Stencyler
April 17, 2019, 05:36:16 am
When i tried to open the scene i can't open it.
I go to details and this say.
Code: [Select]
java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 4, Size: 0
at stencyl.sw.app.tasks.StencylWorker.done(StencylWorker.java:74)
at stencyl.sw.app.tasks.StencylWorker.done(StencylWorker.java:54)
at stencyl.sw.app.tasks.OpenResourceTask.done(OpenResourceTask.java:76)
at javax.swing.SwingWorker$5.run(SwingWorker.java:737)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(SwingWorker.java:832)
at sun.swing.AccumulativeRunnable.run(AccumulativeRunnable.java:112)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(SwingWorker.java:842)
at javax.swing.Timer.fireActionPerformed(Timer.java:313)
at javax.swing.Timer$DoPostEvent.run(Timer.java:245)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.IndexOutOfBoundsException: Index: 4, Size: 0
at java.util.ArrayList.rangeCheckForAdd(ArrayList.java:661)
at java.util.ArrayList.add(ArrayList.java:473)
at stencyl.sw.editors.scene.layerviews.ActorLayer.addActorToLayer(ActorLayer.java:208)
at stencyl.sw.editors.scene.layerviews.InteractiveLayerView.addActorToLayer(InteractiveLayerView.java:79)
at stencyl.sw.editors.scene.EditorSceneModel.addActorToBuckets(EditorSceneModel.java:893)
at stencyl.sw.editors.scene.EditorSceneModel.addActor(EditorSceneModel.java:945)
at stencyl.sw.editors.scene.EditorSceneModel.<init>(EditorSceneModel.java:206)
at stencyl.sw.editors.scene.Designer.<init>(Designer.java:559)
at stencyl.sw.editors.scene.SceneMainPage.initDesigner(SceneMainPage.java:307)
at stencyl.sw.editors.scene.SceneMainPage.<init>(SceneMainPage.java:134)
at stencyl.sw.editors.scene.SceneTab.init(SceneTab.java:140)
at stencyl.sw.editors.scene.SceneTab.<init>(SceneTab.java:122)
at stencyl.sw.app.doc.Workspace.fetchEditorForResource(Workspace.java:832)
at stencyl.sw.app.doc.Workspace.finishOpenResource(Workspace.java:679)
at stencyl.sw.app.tasks.OpenResourceTask.doInBackground(OpenResourceTask.java:67)
at stencyl.sw.app.tasks.OpenResourceTask.doInBackground(OpenResourceTask.java:20)
at javax.swing.SwingWorker$1.call(SwingWorker.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at javax.swing.SwingWorker.run(SwingWorker.java:334)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Please helpppp
« Last Edit: June 25, 2019, 04:21:13 am by Justin »


RicoSalva

  • Junior Stencyler
May 06, 2019, 09:22:35 am
When i tried to open the scene i can't open it.
I go to details and this say.

Code: [Select]
java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 4, Size: 0
at stencyl.sw.app.tasks.StencylWorker.done(StencylWorker.java:74)
at stencyl.sw.app.tasks.StencylWorker.done(StencylWorker.java:54)
at stencyl.sw.app.tasks.OpenResourceTask.done(OpenResourceTask.java:76)
at javax.swing.SwingWorker$5.run(SwingWorker.java:737)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(SwingWorker.java:832)
at sun.swing.AccumulativeRunnable.run(AccumulativeRunnable.java:112)
at [url=https://gimp.software/][color=#000000]gimp[/color][/url] [url=https://freejobalert.vip/][color=#000000]freejobalert[/color][/url] [url=https://notepad.software/][color=#000000]notepad++[/color][/url] javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(SwingWorker.java:842)
at javax.swing.Timer.fireActionPerformed(Timer.java:313)
at javax.swing.Timer$DoPostEvent.run(Timer.java:245)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.IndexOutOfBoundsException: Index: 4, Size: 0
at java.util.ArrayList.rangeCheckForAdd(ArrayList.java:661)
at java.util.ArrayList.add(ArrayList.java:473)
at stencyl.sw.editors.scene.layerviews.ActorLayer.addActorToLayer(ActorLayer.java:208)
at stencyl.sw.editors.scene.layerviews.InteractiveLayerView.addActorToLayer(InteractiveLayerView.java:79)
at stencyl.sw.editors.scene.EditorSceneModel.addActorToBuckets(EditorSceneModel.java:893)
at stencyl.sw.editors.scene.EditorSceneModel.addActor(EditorSceneModel.java:945)
at stencyl.sw.editors.scene.EditorSceneModel.<init>(EditorSceneModel.java:206)
at stencyl.sw.editors.scene.Designer.<init>(Designer.java:559)
at stencyl.sw.editors.scene.SceneMainPage.initDesigner(SceneMainPage.java:307)
at stencyl.sw.editors.scene.SceneMainPage.<init>(SceneMainPage.java:134)
at stencyl.sw.editors.scene.SceneTab.init(SceneTab.java:140)
at stencyl.sw.editors.scene.SceneTab.<init>(SceneTab.java:122)
at stencyl.sw.app.doc.Workspace.fetchEditorForResource(Workspace.java:832)
at stencyl.sw.app.doc.Workspace.finishOpenResource(Workspace.java:679)
at stencyl.sw.app.tasks.OpenResourceTask.doInBackground(OpenResourceTask.java:67)
at stencyl.sw.app.tasks.OpenResourceTask.doInBackground(OpenResourceTask.java:20)
at javax.swing.SwingWorker$1.call(SwingWorker.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at javax.swing.SwingWorker.run(SwingWorker.java:334)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Please helpppp
Facing similar issues here too. In need of help.

Thanks in advance.
Regards,
Rico
« Last Edit: June 25, 2019, 04:21:43 am by Justin »


watermelonmonster

  • Junior Stencyler
June 16, 2019, 10:56:23 am
Same thing here.  This error occurs when I attempt to edit one of the scenes in one of my games; other scenes and other games seem to open just fine.

I'm running Mac OSX 10.13.6
Stencyl 4.0.1 (b10300) - 3515

Code: [Select]
java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 44, Size: 0
at stencyl.sw.app.tasks.StencylWorker.done(StencylWorker.java:74)
at stencyl.sw.app.tasks.StencylWorker.done(StencylWorker.java:54)
at stencyl.sw.app.tasks.OpenResourceTask.done(OpenResourceTask.java:76)
at javax.swing.SwingWorker$5.run(SwingWorker.java:737)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(SwingWorker.java:832)
at sun.swing.AccumulativeRunnable.run(AccumulativeRunnable.java:112)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(SwingWorker.java:842)
at javax.swing.Timer.fireActionPerformed(Timer.java:313)
at javax.swing.Timer$DoPostEvent.run(Timer.java:245)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.IndexOutOfBoundsException: Index: 44, Size: 0
at java.util.ArrayList.rangeCheckForAdd(ArrayList.java:665)
at java.util.ArrayList.add(ArrayList.java:477)
at stencyl.sw.editors.scene.layerviews.ActorLayer.addActorToLayer(ActorLayer.java:208)
at stencyl.sw.editors.scene.layerviews.InteractiveLayerView.addActorToLayer(InteractiveLayerView.java:79)
at stencyl.sw.editors.scene.EditorSceneModel.addActorToBuckets(EditorSceneModel.java:893)
at stencyl.sw.editors.scene.EditorSceneModel.addActor(EditorSceneModel.java:945)
at stencyl.sw.editors.scene.EditorSceneModel.<init>(EditorSceneModel.java:206)
at stencyl.sw.editors.scene.Designer.<init>(Designer.java:559)
at stencyl.sw.editors.scene.SceneMainPage.initDesigner(SceneMainPage.java:307)
at stencyl.sw.editors.scene.SceneMainPage.<init>(SceneMainPage.java:134)
at stencyl.sw.editors.scene.SceneTab.init(SceneTab.java:140)
at stencyl.sw.editors.scene.SceneTab.<init>(SceneTab.java:122)
at stencyl.sw.app.doc.Workspace.fetchEditorForResource(Workspace.java:832)
at stencyl.sw.app.doc.Workspace.finishOpenResource(Workspace.java:679)
at stencyl.sw.app.tasks.OpenResourceTask.doInBackground(OpenResourceTask.java:67)
at stencyl.sw.app.tasks.OpenResourceTask.doInBackground(OpenResourceTask.java:20)
at javax.swing.SwingWorker$1.call(SwingWorker.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at javax.swing.SwingWorker.run(SwingWorker.java:334)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)





New attachment added by watermelonmonster - June 16, 2019, 11:04:26 am


watermelonmonster

  • Junior Stencyler
June 16, 2019, 11:05:23 am
I've attached the flash log file (it's a .zip).

Other things I've tried that don't seem to help:
* Restarting the computer
* Exporting and re-importing the game


Justin

  • Master Stencyler
  • *
June 16, 2019, 12:19:00 pm
Sorry about this, this is a bug that unfortunately slipped past in the current public release. It's fixed in the private releases (available to subscribers). We'll issue a new public release sometime soon.

To manually fix this for any of your scenes that won't open, follow these steps:

> Press Ctrl + o in Stencyl, and type in * followed by the name of the scene. Take note of the number you see at SceneEvents_[ID] (Scene: [SCENE_NAME]). Remember the number you see at [ID].

> Go to Tools > Workspace > View Folder for this Game, and then open the "scenes" folder and find the .xml file corresponding to the broken scene. scenes/[ID].xml.

> Go to the <actors> element in the xml file, and for each item listed there, check it's "z" attribute, and make sure the "order" attribute increases sequentially, starting at 0 for the first actor in the list per "z" grouping.

Here's an example. There are "z" values of 1 and 2, so two different sequences in the "order" attribute, each starting at 0. Scroll the code box to the right to see some comments.

Code: [Select]
   <actors>
        <actor a="" aid="" c="" group="" id="" name="" order="0" sx="" sy="" x="" y="" z="1"/>     <---  z is 1, start the ordering for the z=1 group at 0
        <actor a="" aid="" c="" group="" id="" name="" order="1" sx="" sy="" x="" y="" z="1"/>
        <actor a="" aid="" c="" group="" id="" name="" order="2" sx="" sy="" x="" y="" z="1"/>
        <actor a="" aid="" c="" group="" id="" name="" order="3" sx="" sy="" x="" y="" z="1"/>
        <actor a="" aid="" c="" group="" id="" name="" order="0" sx="" sy="" x="" y="" z="2"/>     <---  z is 2, so a new order list starts here at 0
        <actor a="" aid="" c="" group="" id="" name="" order="1" sx="" sy="" x="" y="" z="2"/>
        <actor a="" aid="" c="" group="" id="" name="" order="4" sx="" sy="" x="" y="" z="1"/>     <---  z is 1, so we're back to the other order list that left off at 4
   </actors>

Another options is to simply go nuclear and delete all of the actors from the scene's xml file.
« Last Edit: June 16, 2019, 12:20:13 pm by Justin »


watermelonmonster

  • Junior Stencyler
June 24, 2019, 08:37:04 pm
Thanks Justin!    Any hints on when the next version will be publicly available?


Issue updated by Justin - June 25, 2019, 04:20:58 am
  • Status changed from New to Confirmed


Stensheep

  • Junior Stencyler
September 04, 2019, 03:04:25 pm
For anyone out there having trouble with fixing the scenes manually, I am attaching a python script that fixes all scenes.

Will create backup file (named XXX.xml.original - one for each scene) so even it the script makes some mistake you can restore the original file.

You need to install python to use it and run it from the command line. (sorry, hard to explain if you are not familiar with it)

Code: [Select]
import sys

import xml.etree.ElementTree

import shutil
import os.path

def fix_single_scene_file(scene_file_to_fix):
    et = xml.etree.ElementTree.parse(scene_file_to_fix)

    z_level_to_current_order = {}
   
    for actor in et.iter('actor'):
        current_actor_z_attribute = actor.attrib['z']
        if current_actor_z_attribute not in z_level_to_current_order:
            z_level_to_current_order[current_actor_z_attribute] = 0
        else:
            z_level_to_current_order[current_actor_z_attribute] += 1
        actor_current_order_in_z_level = int(actor.attrib['order'])
        # if actor_current_order_in_z_level != z_level_to_current_order[current_actor_z_attribute]:
        #    print('Fixing actor order level on z {} from {} to {}'.format(current_actor_z_attribute, actor_current_order_in_z_level, z_level_to_current_order[current_actor_z_attribute]))
        actor.set('order', str(z_level_to_current_order[current_actor_z_attribute]))       
       
    et.write(scene_file_to_fix)
    print("Scene {} is now fixed".format(scene_file_to_fix))

def main(argv):
    if len(argv) != 2:
        print('Usage: <path to scenes folder>')
        return -1
   
    scene_folder = argv[1]
   
    scene_file_name = 'scenes.xml'
   
    et = xml.etree.ElementTree.parse(os.path.join(scene_folder, scene_file_name))
       
    for scene in et.iter('scene'):
        scene_to_fix_file_name = os.path.join(scene_folder, '{}.xml'.format(scene.attrib['id']))
       
        backup_file_name = scene_to_fix_file_name + ".original"
       
        if os.path.exists(backup_file_name):
            raise Exception('File {} already exists, cannot create backup'.format(backup_file_name))       
       
        print("Creating backup file in " + backup_file_name)
        shutil.copyfile(scene_to_fix_file_name, backup_file_name)     
   
    for scene in et.iter('scene'):
        scene_to_fix_file_name = os.path.join(scene_folder, '{}.xml'.format(scene.attrib['id']))
        print('Fixing scene {}.xml ({})'.format(scene_to_fix_file_name, scene.attrib['name']))
        fix_single_scene_file(scene_to_fix_file_name)
   
    return 0
   
if __name__ == '__main__':
    sys.exit(main(sys.argv))



JeffreyDriver

  • Subscriber - Stencyl Indie
  • *
September 17, 2019, 12:59:09 pm
For anyone out there having trouble with fixing the scenes manually, I am attaching a python script that fixes all scenes.

Will create backup file (named XXX.xml.original - one for each scene) so even it the script makes some mistake you can restore the original file.

You need to install python to use it and run it from the command line. (sorry, hard to explain if you are not familiar with it)

Code: [Select]
import sys

import xml.etree.ElementTree

import shutil
import os.path

def fix_single_scene_file(scene_file_to_fix):
    et = xml.etree.ElementTree.parse(scene_file_to_fix)

    z_level_to_current_order = {}
   
    for actor in et.iter('actor'):
        current_actor_z_attribute = actor.attrib['z']
        if current_actor_z_attribute not in z_level_to_current_order:
            z_level_to_current_order[current_actor_z_attribute] = 0
        else:
            z_level_to_current_order[current_actor_z_attribute] += 1
        actor_current_order_in_z_level = int(actor.attrib['order'])
        # if actor_current_order_in_z_level != z_level_to_current_order[current_actor_z_attribute]:
        #    print('Fixing actor order level on z {} from {} to {}'.format(current_actor_z_attribute, actor_current_order_in_z_level, z_level_to_current_order[current_actor_z_attribute]))
        actor.set('order', str(z_level_to_current_order[current_actor_z_attribute]))       
       
    et.write(scene_file_to_fix)
    print("Scene {} is now fixed".format(scene_file_to_fix))

def main(argv):
    if len(argv) != 2:
        print('Usage: <path to scenes folder>')
        return -1
   
    scene_folder = argv[1]
   
    scene_file_name = 'scenes.xml'
   
    et = xml.etree.ElementTree.parse(os.path.join(scene_folder, scene_file_name))
       
    for scene in et.iter('scene'):
        scene_to_fix_file_name = os.path.join(scene_folder, '{}.xml'.format(scene.attrib['id']))
       
        backup_file_name = scene_to_fix_file_name + ".original"
       
        if os.path.exists(backup_file_name):
            raise Exception('File {} already exists, cannot create backup'.format(backup_file_name))       
       
        print("Creating backup file in " + backup_file_name)
        shutil.copyfile(scene_to_fix_file_name, backup_file_name)     
   
    for scene in et.iter('scene'):
        scene_to_fix_file_name = os.path.join(scene_folder, '{}.xml'.format(scene.attrib['id']))
        print('Fixing scene {}.xml ({})'.format(scene_to_fix_file_name, scene.attrib['name']))
        fix_single_scene_file(scene_to_fix_file_name)
   
    return 0
   
if __name__ == '__main__':
    sys.exit(main(sys.argv))


Are you able to give any direction? I've got Python installed, but am struggling with this. Thanks.

I've tried manually fixing the scenes but I was just creating more problems. Besides, I have hundreds of scenes.


Stensheep

  • Junior Stencyler
October 10, 2019, 12:52:17 pm
For anyone out there having trouble with fixing the scenes manually, I am attaching a python script that fixes all scenes.

Will create backup file (named XXX.xml.original - one for each scene) so even it the script makes some mistake you can restore the original file.

You need to install python to use it and run it from the command line. (sorry, hard to explain if you are not familiar with it)

Code: [Select]
import sys

import xml.etree.ElementTree

import shutil
import os.path

def fix_single_scene_file(scene_file_to_fix):
    et = xml.etree.ElementTree.parse(scene_file_to_fix)

    z_level_to_current_order = {}
   
    for actor in et.iter('actor'):
        current_actor_z_attribute = actor.attrib['z']
        if current_actor_z_attribute not in z_level_to_current_order:
            z_level_to_current_order[current_actor_z_attribute] = 0
        else:
            z_level_to_current_order[current_actor_z_attribute] += 1
        actor_current_order_in_z_level = int(actor.attrib['order'])
        # if actor_current_order_in_z_level != z_level_to_current_order[current_actor_z_attribute]:
        #    print('Fixing actor order level on z {} from {} to {}'.format(current_actor_z_attribute, actor_current_order_in_z_level, z_level_to_current_order[current_actor_z_attribute]))
        actor.set('order', str(z_level_to_current_order[current_actor_z_attribute]))       
       
    et.write(scene_file_to_fix)
    print("Scene {} is now fixed".format(scene_file_to_fix))

def main(argv):
    if len(argv) != 2:
        print('Usage: <path to scenes folder>')
        return -1
   
    scene_folder = argv[1]
   
    scene_file_name = 'scenes.xml'
   
    et = xml.etree.ElementTree.parse(os.path.join(scene_folder, scene_file_name))
       
    for scene in et.iter('scene'):
        scene_to_fix_file_name = os.path.join(scene_folder, '{}.xml'.format(scene.attrib['id']))
       
        backup_file_name = scene_to_fix_file_name + ".original"
       
        if os.path.exists(backup_file_name):
            raise Exception('File {} already exists, cannot create backup'.format(backup_file_name))       
       
        print("Creating backup file in " + backup_file_name)
        shutil.copyfile(scene_to_fix_file_name, backup_file_name)     
   
    for scene in et.iter('scene'):
        scene_to_fix_file_name = os.path.join(scene_folder, '{}.xml'.format(scene.attrib['id']))
        print('Fixing scene {}.xml ({})'.format(scene_to_fix_file_name, scene.attrib['name']))
        fix_single_scene_file(scene_to_fix_file_name)
   
    return 0
   
if __name__ == '__main__':
    sys.exit(main(sys.argv))


Are you able to give any direction? I've got Python installed, but am struggling with this. Thanks.

I've tried manually fixing the scenes but I was just creating more problems. Besides, I have hundreds of scenes.

Hello, well first now I have an updated script that handles more cases of corruption. My updated script is not perfect, If you use the inspector to customize things this script might break the customization, but in handles more cases. Here it is:

Code: [Select]
import sys

import xml.etree.ElementTree

import shutil
import os.path
import re

def main(argv):
    if len(argv) != 2:
        print('Usage: <scene_file.xml>')
        return -1
   
    scene_file_to_fix = argv[1]
   
    et = xml.etree.ElementTree.parse(scene_file_to_fix)
   
    current_actor_id = 0
   
    z_level_to_current_order = {}
   
    actor_name_default_pattern = re.compile('([a-zA-Z]+) \d+')
   
    for actor in et.iter('actor'):           
        current_actor_z_attribute = actor.attrib['z']
        if current_actor_z_attribute not in z_level_to_current_order:
            z_level_to_current_order[current_actor_z_attribute] = 0
        else:
            z_level_to_current_order[current_actor_z_attribute] += 1
        actor_current_order_in_z_level = int(actor.attrib['order'])
        if actor_current_order_in_z_level != z_level_to_current_order[current_actor_z_attribute]:
            print('Fixing actor order level on z {} from {} to {}'.format(current_actor_z_attribute, actor_current_order_in_z_level, z_level_to_current_order[current_actor_z_attribute]))
           
        current_actor_id = current_actor_id + 1       
               
        actor.set('aid', str(current_actor_id))
       
        name_match = actor_name_default_pattern.match(actor.attrib['name'])
        if name_match:
            actor.set('name', "{} {}".format(name_match.group(1), current_actor_id))
       
        actor.set('order', str(z_level_to_current_order[current_actor_z_attribute]))   
   
    backup_file_name = scene_file_to_fix + ".original"
   
    if os.path.exists(backup_file_name):
        print('File {} already exists, cannot create backup'.format(backup_file_name))
        return -1
       
   
    print("Creating backup file in " + backup_file_name)
    shutil.copyfile(scene_file_to_fix, backup_file_name)
       
    et.write(scene_file_to_fix)
    print("Scene is now fixed")
   
    return 0
   
if __name__ == '__main__':
    sys.exit(main(sys.argv))

Now about how to use this script -
1. Install python
2. Open command line (cmd) - type "CMD" in Windows search box and open the black thing :)
3. Open stencyl, click File->Preferences->Workspace. Copy the path that is there.
4. Get the number of your broken scene by using the instruction that other people provided in this forum:
Quote
> Go to Tools > Workspace > View Folder for this Game, and then open the "scenes" folder and find the .xml file corresponding to the broken scene. scenes/[ID].xml.
5. run the following (replace paths) : python "C:\path\to\script\fix_broken_scene.py " "workspace_path\stencylworks\games\YOU GAME NAME\scenes\XXX.xml"

That's it, hope you now understand  :)



=======================================================
Play my game, Lunar Station: sheeproid.itch.io/lunarstation
« Last Edit: October 10, 2019, 01:07:35 pm by Stensheep »


alohabrij

  • Junior Stencyler
October 14, 2019, 07:47:46 pm
thanks a lot Stensheep for the script and Justin for the guidance , got my scene fixed with the script


adytt

  • Junior Stencyler
October 31, 2019, 12:26:52 pm
Thank 's a lot for this python script, I managed to repair my scenes using it.
I also managed to repair the scenes manually, but after some few new modifications regarding actor positions on different layers it all got messed up again, and no manual action would solve it.
In my case, if I move an actor from one layer to another it will trigger that error and the scene won't open.


Pages: 1

Details

  • Reported
    April 17, 2019, 05:36:16 am
  • Updated
    October 31, 2019, 12:26:52 pm

  • View Status
    Public
  • Type
    Bug
  • Status
    Confirmed
  • Priority
    Normal
  • Version
    (none)
  • Fixed in
    (none)
  • Assigned to
    (none)
  • Category
    Scene Designer

Tags


Attachments

* log-2019-06-16.zip (631.92 kB - downloaded 118 times.)