IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> PYAI quick start guide, How to Convert your scaiedit scripts to PYAI
Archon_Wing    San Francisco
Jul 28 2009, 11:30 AM    Post #1
As the documentation for everything is all over the place, and it can be quite confusing, I copy and pasted my instructions on how to get started on PYAI here. This was originally intended for people that want to convert their scaiedit asc3 files over which will probaly apply to most people starting to use PYAI. If you don't have a script to convert, just ignore the parts about converting. wink.gif

FAQ
Q:I just want to use someone else's script. How can I tell if it's a scaiedit file or a pyai file?
A: Scaiedit files have an .asc3 extension at the end of the file. PYAI files are txt files, like ai.txt

Q: I don't see any extensions at the end of a file.
A: By default Windows is lame and hides your extensions. Unhide them: http://www.kevinscrate.com/blog/2007/10/04...tensions-in-xp/

Q: Wtf it's an aiscript.bin!!
A: You can open these directly in PYAI. Just click file---> open and choose aiscript.bin. If it asks for a bwscript.bin click cancel if you don't have that. However, because labels aren't saved in those files, it can be very hard to read. Try to get a txt/asc3 file if possible.

Q: Wtf it's a bwscript.bin!!
BWscript.bin is extra space for files and can't be opened without an aiscript.bin with it. Get the aiscript.bin. If they don't have it, then someone has screwed up.

Q: How do I open a scaiedit file?
A: Try opening the file. Windows will tell you it doesn't recognize it, so choose select a program. Then find notepad in the list. After that, these files will always open in notepad if you double click them.

Q: It's already a PYAI file
A: Follow steps 1-4. Then goto edit---> import scripts and choose the file. Then skip to step 8

Q: The AI I want has none of these. I only have the mod file.
A: Get Winmpq: http://shadowflare.samods.org/dwnload.html#WinMPQ and follow instructions there.
Then open up the mod file in winmpq. You should see aiscript.bin somewhere and just drag that out to your desktop or any folder of your choosing. Drag the bwscript.bin if it is there too. Then follow the instructions above.

Convert your SCAIEditIII script to PyAI
1.) Make sure you have downloaded the exe version of PYMS , and unzipped it to a folder
In PYAI, click edit----> manage external definition files.

2.) Then click the + icon.


3.) Navigate to the folder you placed PYAI in (It should already be there by default). There should be a file called unitdef.txt ; select this file and click open.

4.) Now click ok. Then, start a new aiscript.bin by clicking file---> new
Click the disk icon "Save Information Comments and Labels"

5.) Click the edit script button. This will open a new window. When it opens, delete everything in the window.

6.) Copy and paste your scaiedit script in the window. Click the convert to pyai icon (2nd last from right). Click the check mark to check for any errors. Note that PYAI is case sensitive. Once that's done, close the window and say yes if you want to save.

7.)You will see a new script created (Terran/Protoss/Zerg Expansion level). It is strongly recomended you export the script by right clicking on the script and choosing export. Name it anything you want but make sure it has a .txt at the end. In case anything goes wrong, you can simply import this text file into pyai (import is the 5th icon from bottom left of the toolbar)


8.) Repeat this for any other scripts you wish to import
To save the aiscript.bin, click file---> save as. Save it to a folder you will remember and save the file as aiscript.bin

9.) To actually play the AIs you will need to use WINMPQ to move the aiscript.bin into the BWAIwar4 exe file.
Follow the instructions here
10.) To open the aiscript.bin file again, just click file---> open and choose aiscript.bin. It'll then ask you for a bwscript.bin ; click cancel if that doesn't exist-- you don't need it.


 
Go to the top of the page +
poiuy_qwert    Canada
Jul 28 2009, 02:30 PM    Post #2
Very nice and thanks for writing a guide for my program! A couple tips:
- If you set file associations (teal cubes button on toolbar or in the menu) you can double click on aiscript.bin's in explorer/WinMPQ to open them in PyAI (modders note: since both AI and IScript use the same extension [.bin], their file associations will overwrite eachother)
- You dont have to create a new script (step 5) to get to the script editor, you can press Ctrl+E (or press the button on the toolbar/do it in the menu).
- If you did not know you can also export your script before closing the script editor (step 6)


 
Go to the top of the page +
Archon_Wing    San Francisco
Jul 28 2009, 02:53 PM    Post #3
QUOTE
You dont have to create a new script (step 5) to get to the script editor, you can press Ctrl+E (or press the button on the toolbar/do it in the menu).


Ok, I updated the post to contain that.


 
Go to the top of the page +
bajadulce    Santa Cruz, California
Dec 31 2009, 05:06 PM    Post #4
excellent tutorial. There are a few things that could be changed, but I'll make a separate post rather than edit your excellent tutorial. 2 methods from 2 different ppl might clear some things up that are confusing in one or the other. The following will deal specifically with converting a SCAIEdit3 script to PYAI specifically to be able to make use of the BWAILauncher.

Configuring PYAI's external definitions:
*note this step is not required for converting, but will convert the script using more familiar terms such as that of SCAIEdit rather than the raw SCraft stat_txt.tbl strings. example build(1, drone, 80) vs. build(1, Zerg Drone, 80)

Open PYAI and select Edit > Manage External Files (cntl+x) OR use the tool tip (labeled "x=y")
Attached Image


This will bring up the External Definition Window as seen below.
Select the "+" button and navigate to your PyMS folder.
You should see a .txt file named "unitdef.txt". Select this file.
Attached Image


... and hit OK. PyAI is now setup to use these definitions... which is nice! smile.gif
*this also only has to be done once btw or should you want to change it. This will be set this way each time you open PyAI.
Attached Image

###############

Importing your SCAIEdit3 script for conversion:
In order to access PyAI's editor to convert your script we will need to open an existing aiscript such as the default one or a new one. A new one is easy enough: (cntrl+N) or use the tooltip (first one on left has "sunrays" )
Attached Image

Nothing much will change in the main window as you have just created a new "blank" aiscript.bin. Some tooltips should light up however AND you will see the label atop PyAI change (red arrow at top). We can now access the editor. Open editor (Ctrl-E) or use the tooltip (resembles script with a pencil & eraser)
Attached Image

The editor is now open with a blank script and is ready to import your SCAIEdit3 script. Import your code (Ctrl-I) or use the tooltip (resembles a script with a red arrow)
Attached Image

NOTE:
PyAI is set to look for .txt files for scripts by default. Change the dropdown "files of type:" from .txt files to "all files" as seen in pic below so the ".asc3" file can be seen in window. Select your file. (* You could also add the .txt extension to you SCAIEdit3 .asc3 file such as "Custom Expansion Zerg.asc3.txt")
Attached Image

You should now see your SCAIEDIT 3 script in the main Window. Compile your script from asc3 to PyAI (Ctrl+Alt+P) or use the tooltip (resembles gears and is at the far right)
Attached Image

And if all goes well, you should see your script magically transform into that of the PyAI formatting.

You should also see some green text alerting you of script flags and instructions to change a header appropriately.
Be sure to change the line to the following:
TMCx(1342, 101, aiscript): For Terran
PMCx(1343, 101, aiscript): For Toss.
ZMCx(1344, 101, aiscript): For Zerg.
(*typically they will be listed as "111" instead of "101". So watch out for that)
Attached Image


Now let's check to make sure everything is compliant by testing code (Ctrl-T) or use the tooltip (big red check mark).
If everything goes OK, you should get the nice "your a stud no errors warning" smile.gif Most likely tho you may get a few "warnings". Some warnings are pretty benign while others such as a loop without a wait statement you should fix! Any interpreting error however will have to be fixed! PyAI is really good about highlighting the error and you can cycle through them as well. When all is done hit OK and let's move to the final step.
Attached Image

Exporting your converted file:
The final step is to export your converted script and give it a meaningful name. Export script as (Ctrl+Alt+A) or use the tooltip (script with red arrow and floppy disk)
Attached Image



... Your done! Add some debug strings (*not required) and test out your creation in the BWAILauncher.

*example debug string:
CODE
#if #debug
    debug(null, AccelDefault T v0.8x by Equalizer)
    --null--
#endif


 
Go to the top of the page +

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 7th September 2010 - 07:00 PM