Page 1 of 1

PyAI Corrupts My Scripts

Posted: Sun Jan 09, 2011 1:17 am
by pastelmind
So I'm using Windows 7 Korean with Python 2.6 and PIL, and attempting to create an AI script that works with a custom stat_txt.tbl. Opening and reading AI scripts works fine with both the script version and the EXE version of PyAI. However, after I modify and save a script (e.g. Terran Expansion Custom Level), many of the labels (e.g. TMCx 0026) are converted to TMCx 0000. Thus, trying to edit and save the script a second time results in a "multiple labels found" error. Could this be an encoding/compatibility issue?

Posted: Sun Jan 09, 2011 3:58 pm
by poiuy_qwert
It definitely could be since I've never tested any of the programs on Windows 7 (let alone one thats not an english version), or using Python 2.6 (I used 2.5.4 for all my development/usage). Its also possible that its a bug, something like that has happened in earlier versions but should be fixed. Try re-arranging your blocks and/or adding/removing blocks and see if you get better results. Also, what happens when you open one of the default scripts and try and save it with no modifications?

Posted: Mon Jan 10, 2011 11:10 am
by pastelmind
Saving an unmodified default script (TMCx, Terran Expansion Custom Level) also caused it to be encoded weirdly. Strangely enough, StarCraft seems to be running fine with the "corrupted" script (except that Terran seems to like making multiple expansions after the second push).

I've compared the script files before & after the corruption to look for a pattern, and among the hundreds of blocks, only the following were converted to 0000:

Code: Select all

0005, 0012, 0019, 0020, 0021, 0025, 0031, 0035, 0041, 0042, 0045, 0052, 0054, 0056, 0063, 0070, 0078, 0085, 0088, 0091, 0097, 0100, 0103, 0106


For clarity, I detail what happens:
  1. I open PyAI.exe and set it to open the appropriate MPQs and my modified stat_txt.tbl
  2. I open the default AI scripts. No problem.
  3. I select and open a script for editing. No problem.
  4. I (modify and) save the opened script. Code compiles with no problem, and no visual changes.
  5. I close the script editor window, returning the focus to the list of scripts in the script files.
  6. I reopen the saved script. Bam! Various labels are converted to 0000s. Saving it again? Not allowed because of block name collision.
Since this happens with the EXE version as well, I assume this is not a problem caused by Python version issues.

By the way, is there a reason why you are not moving on to newer versions of Python?

Posted: Mon Jan 10, 2011 4:48 pm
by poiuy_qwert
Oh, another thing to try; if you are saving with extra information, try without. Its the button on the toolbar, in both the script editor and main window, that's icon is a disk with +i on it. Make sure that it is not pressed in when saving, that might fix the problem. Also, does this problem happen everytime, even with small simple scripts?

Since this happens with the EXE version as well, I assume this is not a problem caused by Python version issues.
Good point.

There is no real point in moving to a newer version of Python, especially since not many people use the source version.

Posted: Wed Jan 12, 2011 1:21 am
by pastelmind
[quote name='poiuy_qwert' post='9957' date='Jan 11 2011, 01:48 AM']Oh, another thing to try; if you are saving with extra information, try without. Its the button on the toolbar, in both the script editor and main window, that's icon is a disk with +i on it. Make sure that it is not pressed in when saving, that might fix the problem.[/quote]

That seems to solve the problem. Thanks!

Posted: Sat Sep 10, 2011 11:28 pm
by Archon_Wing
I'll be honest. I usually have all the scripts saved as .txt files and import/export as needed, since the labels seem to be a frequent problem and I absolutely need the extra information, otherwise I can't read my own scripts. ;)

Edit: Yikes, this thread is old. :S