Modding Discussion Batch tool for packing, creating log, zip, upload and archive.

Discussion in 'Starbound Modding' started by Armed Mosquito, Nov 22, 2014.

?

Should I release other stuff like this for mod developers?

Poll closed Nov 29, 2014.
  1. Yes, Please!

    3 vote(s)
    100.0%
  2. No, Thank You!

    0 vote(s)
    0.0%
  1. Armed Mosquito

    Armed Mosquito Existential Complex

    : CAUTION :
    Configure your paths properly! You don't want to remove the wrong folders due to setting the wrong path location.


    This is certainly not something everyone needs when creating mods, in fact there only be a few people who could use this. The reason its here is only because I wanted to share the batch I created to handle the update process of my mods. If you don't know batch at all its actually very simple to learn in minutes.

    Everyone is welcomed to use, change, and redistribute. Totally free.

    This still has some stuff hard coded such as the ftp commands and log file names. Just be sure to check what the ftp put commands are doing to ensure you update the mod to the proper server path.

    Code:
    :: Starbound MOD Packer, Create LOG, ZIP, Upload to FTP Server & Archive
    :: Support URL: http://community.playstarbound.com/index.php?members/armed-mosquito.239858/
    :: Version: 1.3
    :: Description: This tool was created to help pack a mod and instantly upload it to a ftp server from anywhere on your pc after configuration. You can run a scheduler with this file to automate it.
    :: You can also set this to do more than one mod at a time. Its just a simple tool to make life easier.
    
    :: Path where 7z or 7za was installed to properly run this script.
    SET ZIPPATH=C:\Program Files (x86)\7-Zip\7z.exe
    :: Configure your local Starbound Directory aka Folder
    SET STARBOUNDPATH=F:\My Files(ArmedMosquito)\Program Files\Steam\steamapps\common\Starbound
    :: Configure your FTP Server Settings - User Archiver is optional using same password as the other.
    SET FTPADDRESS=ftp.yourftpserver.com
    SET FTPPASSWORD=ftppassword
    SET USERMODUPLOADER=ftpuserMOD
    SET USERARCHIVER=ftpuserARCHIVE
    :: Configure your Starbound MOD
    SET MODFOLDERTOPACK=F:\SquitoProjects\WildThings
    SET PACKEDTOANDAS=F:\batchJOB\WildThings.modpak
    SET ZIPNAME=WildThings-EarlyAccessVersion
    SET MODNAME=WildThings
    SET SUPPORTURL=http://community.playstarbound.com/index.php?threads/wild-things.86113/
    :: END OF CONFIGURATION
    
    :: Sure you want to continue starting the process..
    @[USER=7469]Echo[/USER] off
    SET /P ANSWER=Do you want to continue (Y/N)?
    echo You chose: %ANSWER%
    if /i {%ANSWER%}=={y} (goto :yes)
    if /i {%ANSWER%}=={yes} (goto :yes)
    goto :no
    :no
    exit /b 1
    :yes
    :: Lets work inside the starbound folder to get the pack job done.
    PUSHD "%STARBOUNDPATH%"
    cd win32
    asset_packer.exe "%MODFOLDERTOPACK%" "%PACKEDTOANDAS%"
    POPD
    :: Lets set the date, and 24hour clock this will be saved so its the same update time throughout the rest of the process.
    SET DateSave=%date:~4,2%-%date:~7,2%-%date:~10,4%
    SET TimeSave=%Time%
    :: Time to add the version and support url shortcut to the zip with the .modpak file as well.
    echo You have the early access version of %MODNAME% from %DateSave%, %TimeSave% >> view-my-version-help.txt
    echo Get support @ %SUPPORTURL% >> view-my-version-help.txt
    "%ZIPPATH%" a -tzip %ZIPNAME%.zip "%PACKEDTOANDAS%" -mx9
    "%ZIPPATH%" a -tzip %ZIPNAME%.zip view-my-version-help.txt -mx9
    :: Last lets add the modpak file to the zip itself. Remove all the new files, but we will leave the .zip to upload to the server next.
    "%ZIPPATH%" a -tzip %ZIPNAME%.zip "%PACKEDTOANDAS%" -mx9
    del "view-my-version-help.txt"
    del "*.modpak"
    :: Create the update text
    echo Last Updated On, %DateSave% %TimeSave%>> updates.txt
    :: Connecting to the FTP Server. Uploading updates.txt and the zip created.
    @[USER=7469]Echo[/USER] off
    echo user %USERMODUPLOADER%> ftpcmd.dat
    echo %FTPPASSWORD%>> ftpcmd.dat
    echo bin>> ftpcmd.dat
    echo put updates.txt>> ftpcmd.dat
    echo cd private/ea>> ftpcmd.dat
    echo put %ZIPNAME%.zip>> ftpcmd.dat
    echo quit>> ftpcmd.dat
    ftp -n -s:ftpcmd.dat %FTPADDRESS%
    del ftpcmd.dat
    :: This is an optional archiving part of the script and can be skipped once you reach this far in the script.
    @[USER=7469]Echo[/USER] off
    SET /P ANSWER=Would you like to archive the zip the ftp server (Y/N)?
    echo You chose: %ANSWER%
    if /i {%ANSWER%}=={y} (goto :yes)
    if /i {%ANSWER%}=={yes} (goto :yes)
    goto :no
    :no
    del "*.zip"
    exit /b 1
    :yes
    rename %ZIPNAME%.zip %MODNAME%_%DateSave%.zip
    @[USER=7469]Echo[/USER] off
    echo user %USERARCHIVER%> ftpcmd.dat
    echo %FTPPASSWORD%>> ftpcmd.dat
    echo bin>> ftpcmd.dat
    echo put %MODNAME%_*>> ftpcmd.dat
    echo quit>> ftpcmd.dat
    ftp -n -s:ftpcmd.dat %FTPADDRESS%
    del ftpcmd.dat
    :: Lets finally finish and remove the created .zip
    del "*.zip"
    
    To use the code above copy and paste into your favorite text editor and save the file as any name with file format .bat

    This batch file is using 7zip command line to zip files you can download it here.

    I'm happy to assist anyone who is interested in using this for there work flow just pm me or reply here.


    p.s. this batch file will help unpack Starbound assets to a desired location you set. It removes all earlier files from that location you set before adding the new asset files, seems to be a safer way then updating.
    Code:
    :: Starbound Asset Unpacker
    :: Support URL: http://community.playstarbound.com/index.php?members/armed-mosquito.239858/
    :: Version: 1.0
    :: Description: This is used to help you quickly unpack starbound assets to your set location using configuration.
    
    :: CONFIGURATION BEGIN
    SET STARBOUNDPATH=F:\My Files(ArmedMosquito)\Program Files\Steam\steamapps\common\Starbound
    SET STARBOUNDASSETFILE="F:\My Files(ArmedMosquito)\Program Files\Steam\SteamApps\common\Starbound\assets\packed.pak"
    SET UNPACKLOCATION="F:\StarboundAssetsUnpacked"
    :: CONFIGURATION END
    
    :: Removing the old assets this will take some time.
    rmdir /S /Q %UNPACKLOCATION%
    :: Now we enter into the starbound folder to unpack the new assets to the location you set above.
    PUSHD "%STARBOUNDPATH%"
    cd win32
    asset_unpacker.exe %STARBOUNDASSETFILE% %UNPACKLOCATION%
    POPD
    Just an idea you can check google out on scheduling task and run a batch file by automation. For example you could have it run the batch file to unpack your assets every morning or night to ensure you are working with changes.

    Lastly it looks like the development team has added a batch file in the "Starbound\win32" folder. What there .bat file does is unpack the assets for you without configuration. There version as of this posting now is much easier to use, however it requires you to currently remove the assets by hand after all its safer for someone new to this approach.

    • Quickly did some fixing after using this script all day I found some new ways to make it not only a little easier but also 100% accurate now on the time stamps including the file that is packed up in the zip and the site. The other focus was I had to basically fix up the path setup it would work but it is much more clear now. Be careful when using this to set paths properly, if you want help just message me.
     
    Last edited: Nov 23, 2014

Share This Page