Announcement

Collapse
No announcement yet.

Anybody want to write an applescript?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Anybody want to write an applescript?

    Cuz I don't know how.And so far,attempts at learning have been highly unsuccessful.

    I need one for this.It tells which events.txt to load.They can be loaded manually but it would be nice to have it automated.


    @echo off
    cls
    echo.
    echo 2194 Days of War
    echo.
    echo Loading event files for play as specific nation
    echo Please choose from the options below:
    echo.
    echo 1. Load German event file
    echo 2. Load Soviet event file
    echo 3. Load American event file
    echo 4. Load British event file
    echo 5. Load Japanese event file
    echo X. Exit without Loading
    echo.
    choice /c:12345X Enter your selection

    if errorlevel 6 goto done
    if errorlevel 5 goto japanese
    if errorlevel 4 goto british
    if errorlevel 3 goto american
    if errorlevel 2 goto soviet
    if errorlevel 1 goto german

    :german
    echo.
    echo Loading German Game
    copy events1.txt events.txt
    copy rules1.txt rules.txt
    copy sound\Jetbomb.wav sound\Extra2.wav
    copy sound\Jetbomb.wav sound\Extra3.wav
    copy sound\Mchnguns.wav sound\Swrdhors.wav
    copy sound\Extra1.wav sound\Extra6.wav
    copy sound\Cavalry.wav sound\Extra8.wav
    goto done

    :soviet
    echo.
    echo Loading Soviet Game
    copy events2.txt events.txt
    copy rules2.txt rules.txt
    copy sound\Jetbomb.wav sound\Extra2.wav
    copy sound\Jetbomb.wav sound\Extra3.wav
    copy sound\Mchnguns.wav sound\Swrdhors.wav
    copy sound\Extra1.wav sound\Extra6.wav
    copy sound\Cavalry.wav sound\Extra8.wav
    goto done

    :american
    echo.
    echo Loading American Game
    copy events3.txt events.txt
    copy rules2.txt rules.txt
    copy sound\Jetbomb.wav sound\Extra2.wav
    copy sound\Jetbomb.wav sound\Extra3.wav
    copy sound\Mchnguns.wav sound\Swrdhors.wav
    copy sound\Extra1.wav sound\Extra6.wav
    copy sound\Cavalry.wav sound\Extra8.wav
    goto done

    :british
    echo.
    echo Loading British Game
    copy events4.txt events.txt
    copy rules2.txt rules.txt
    copy sound\Jetbomb.wav sound\Extra2.wav
    copy sound\Jetbomb.wav sound\Extra3.wav
    copy sound\Mchnguns.wav sound\Swrdhors.wav
    copy sound\Extra1.wav sound\Extra6.wav
    copy sound\Cavalry.wav sound\Extra8.wav
    goto done

    :japanese
    echo.
    echo Loading Japanese Game
    copy events5.txt events.txt
    copy rules1.txt rules.txt
    copy sound\Jetbomb.wav sound\Extra2.wav
    copy sound\Jetbomb.wav sound\Extra3.wav
    copy sound\Mchnguns.wav sound\Swrdhors.wav
    copy sound\Extra1.wav sound\Extra6.wav
    copy sound\Cavalry.wav sound\Extra8.wav
    goto done

    :done
    echo.
    exit
    quit

    ps..I am holding my breath...
    The only thing that matters to me in a MP game is getting a good ally.Nothing else is as important.......Xin Yu

  • #2
    Ok, here's a try at an Applescript to do what you want.

    The batch file above seems to do three things:
    [list=1][*] It copies one of the files events1.txt, events2.txt, ... events5.txt to events.txt, depending on the country you choose.[*] It copies one of the files rules1.txt or rules2.txt to rules.txt, depending on whether your'e playing an Axis or Allied country.[*] It unconditionally copies a bunch of sound files.[/list=a]

    It appears that the sound files in use are never actually changed, so the last point seems to be useless, and I didn't bother implementing it. This script just does the first two points.

    The script is located at http://www.jlc.net/~faiman/update_events.sit . If you're lucky, you can just click on the link and your browser will automatically download the file and unstuff it for you, leaving you with an Applescript applet file named "Update 2194 Days Events". If your browser tries to display the link as a bunch of gibberish instead of downloading, you'll have to control click, click-and-hold, or whatever you do in your particular browser to get a contextual menu that lets you say "download this file to disk". If you get update_events.sit on your disk, but it isn't automatically expanded, then you'll need to drag it onto your copy of Stuffit Expander.

    Once you have the applet on your system, you can just run it by double clicking it like any other program. The first time you run it, it will bring up a dialog to ask you to locate the 2194 Days of War scenario folder (the folder that contains the rules and events files). After the first time, it will remember how to find the folder and you won't have to tell it again, even if you move the folder around on your disk. However, if it ever "loses" the folder, just drag any file or folder onto the applet icon to "reset" it, and the next time you run the script, it will ask you to locate the scenario folder again.

    Once the applet has located the scenario folder, it will a display dialog box asking the user what country he wants to play as, will choose the appropriate events and rules files in the scenario folder, and will make copies of them to replace the events.txt and rules.txt files in the scenario folder.

    If this isn't what you had in mind, or if you have problems getting it to work, please let me know. If you want to play with the script yourself, you can open it in the Apple Script Editor application.

    Comment


    • #3
      Whoa!bloody lovely.This exactly what I wanted.

      However

      I got this

      ???
      The only thing that matters to me in a MP game is getting a good ally.Nothing else is as important.......Xin Yu

      Comment


      • #4
        Oh heck.I misplaced the sound files.Have to get em again.Is this the problem?

        nope.it doesn't do anything with sounds duh
        [This message has been edited by Smash (edited November 02, 2000).]
        The only thing that matters to me in a MP game is getting a good ally.Nothing else is as important.......Xin Yu

        Comment


        • #5
          Odd. I guess the first question would be what MacOS version you're running.

          The Finder doesn't let you copy one file right on top of another one, so the script deletes the original events.txt, makes a copy of the selected events file, and then renames the copy. Can you check what events files are in your scenario folder after the script dies? I would expect that there would *not* be a file named events.txt, and that there *would* be a file named "events1.txt copy" (or events2.txt, or whichever one is appropriate for your selected country).

          (I do hope you made a copy of the whole scenario folder to play with before you started trying this out. :-)

          Perhaps you could use Stuffit to package up your scenario folder as a .sit file and put it somewhere I could copy it, and I could try my script on your folder and see if I can reproduce the problem here.

          It might simplify things if you could send me your email address so that we can work on this more directly than by exchanging messages here in the forum. I'm at faiman@jlc.net .
          [This message has been edited by RNF (edited November 02, 2000).]

          Comment


          • #6
            RNF - Thanks for helping with this script! I'm sure that all the Mac-Civers will benifit from this exercise in the not too distant future!

            ------------------
            "And now for something completely different..."
            - John Cleese
            "Don't stop thinking about tomorrow! It'll soon be here!" - Fleetwood Mac

            Have you checked out the MacAddict Forums? I'm "Father of the Bar Mitzvah" if you visit!

            Comment


            • #7
              Yes its worth repeating this greatly appreciated.

              8.5.1-I know,I know but if ain't broke don't fix it.Could this be the problem?

              Yes I do get an events1.txt copy.It seems to be working properly up to this point then I get the message I posted above.

              For some reason I couldn't upload the scenario so I sent a compressed copy to your e-mail.1034kb-hope it makes it.

              to be continued......
              The only thing that matters to me in a MP game is getting a good ally.Nothing else is as important.......Xin Yu

              Comment

              Working...
              X