Tutorial How to successfully pack and unpack .pak files

Discussion in 'Starbound Modding' started by SexualRhinoceros, Jan 26, 2014.

  1. Happy you got it working mate! Let me know if you run into any more issues.
     
  2. Mackinz

    Mackinz The Waste of Time

    Hello, folks. I haven't really read up on how to pack mods since the pack/unpack functionality came into being sometime early in 2014, but my packing tool is non-functional now so I have to ask.... can someone help me understand the process of packing from a beginner's viewpoint? >.>
     
  3. uniden0

    uniden0 Void-Bound Voyager

    6.png

    After sending to an unexisting folder I keep getting this? I reinstalled starbound...I think the unpacker is bugger.

    Newest upbeat giraffe update.
     
  4. User error. I just unpacked assets a few hours ago.
    What are you passing in?
     
  5. SexualRhinoceros

    SexualRhinoceros Existential Complex

    I made a kewl file extractor. Just make a new batch file in your Starbound directory and it'll do the rest!
    Code:
    Echo off
    
    :: Localise environment.
    setlocal enableextensions enabledelayedexpansion
    
    ::Make a variable for backspace cause $h is being a dickwad
    for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"
    
    :: delete all files in the directory that have the name "tmp_" in the front of them
    del "tmp_*.*" 2>nul
    ::make the temporary batch file that extracts the assets while the main window waits have
    ::the commands needed to extract and delete the flag file
    echo >>"tmp_asset_extractor.cmd" "win32\asset_unpacker.exe" "assets\packed.pak" "unpackedAssets"
    echo >>"tmp_asset_extractor.cmd" del "tmp_asset_extractor.flg"
    ::start the child batch file and start monitoring for the flag file's deletion
    call :monitor "tmp_asset_extractor.cmd" "tmp_asset_extractor.flg" 900
    
    goto :final
    
    :monitor
        :: Create flag file and start the extractor.
        echo >>%2 dummy file ignore this.
        start /min cmd.exe /c "%1"
    
        :: Start monitoring for completion
        set i=0
        set m=%3
        <nul (set /p z=Waiting assets to finish extracting: ^|)
    
        :: Loop here awaiting completion.
        :loop
            :: Wait one second.
            ping 127.0.0.1 -n 2 >nul
    
            :: Update counters and output progress indicator.
            set /a "i = i + 1"
            set /a "m = m - 1"
            if %i% equ 4 set i=0
            if %i% equ 0 <nul (set /p z=%BS%^|)
            if %i% equ 1 <nul (set /p z=%BS%/)
            if %i% equ 2 <nul (set /p z=%BS%-)
            if %i% equ 3 <nul (set /p z=%BS%\)
    
            :: End conditions, complete or timeout.
            if not exist %2 (
                echo.
                echo.  Files Successfully extracted!
                del "tmp_*.*" 2>nul
                pause
                goto :final
            )
            if %m% leq 0 (
                echo.
                echo.  *** ERROR: Timed-out waiting for extraction to finish.
                pause
                goto :final
            )
            goto :loop
    :final
    endlocal
    if anyone has any issues with it, let me know!
     
    Last edited: Feb 2, 2015
    Mackinz likes this.
  6. Mackinz

    Mackinz The Waste of Time

    Think you could make one for individual mods, Sexy Rhino man?
     
  7. SexualRhinoceros

    SexualRhinoceros Existential Complex

    you could easily edit it to make it work with whatever mod you want it to as long as its a packed file!
    Just replace the Red with whatever the path is as explained in the OP!
    Echo off

    :: Localise environment.
    setlocal enableextensions enabledelayedexpansion

    ::Make a variable for backspace cause $h is being a dickwad
    for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"

    :: delete all files in the directory that have the name "tmp_" in the front of them
    del "tmp_*.*" 2>nul
    ::make the temporary batch file that extracts the assets while the main window waits have
    ::the commands needed to extract and delete the flag file
    echo >>"tmp_asset_extractor.cmd" "win32\asset_unpacker.exe" "assets\packed.pak" "unpackedAssets"
    echo >>"tmp_asset_extractor.cmd" del "tmp_asset_extractor.flg"
    ::start the child batch file and start monitoring for the flag file's deletion
    call :monitor "tmp_asset_extractor.cmd" "tmp_asset_extractor.flg" 900

    goto :final

    :monitor
    :: Create flag file and start the extractor.
    echo >>%2 dummy file ignore this.
    start /min cmd.exe /c "%1"

    :: Start monitoring for completion
    set i=0
    set m=%3
    <nul (set /p z=Waiting assets to finish extracting: ^|)

    :: Loop here awaiting completion.
    :loop
    :: Wait one second.
    ping 127.0.0.1 -n 2 >nul

    :: Update counters and output progress indicator.
    set /a "i = i + 1"
    set /a "m = m - 1"
    if %i% equ 4 set i=0
    if %i% equ 0 <nul (set /p z=%BS%^|)
    if %i% equ 1 <nul (set /p z=%BS%/)
    if %i% equ 2 <nul (set /p z=%BS%-)
    if %i% equ 3 <nul (set /p z=%BS%\)

    :: End conditions, complete or timeout.
    if not exist %2 (
    echo.
    echo. Files Successfully extracted!
    del "tmp_*.*" 2>nul
    pause
    goto :final
    )
    if %m% leq 0 (
    echo.
    echo. *** ERROR: Timed-out waiting for extraction to finish.
    pause
    goto :final
    )
    goto :loop
    :final
    endlocal


    Edit: if a lot of people have trouble with this or don't trust themselves, I'll happily make one that asks for user input on what their packed file name is!
     
  8. Mackinz

    Mackinz The Waste of Time

    After a bit of fiddling, I finally got it to work. Thanks for your help, SR man!
     
  9. Banished

    Banished Subatomic Cosmonaut

    I managed to get my files unpacked thanks to this!
     
  10. SexualRhinoceros

    SexualRhinoceros Existential Complex

    no problem!


    I guess this post got removed from the official modding guides sticky ;_; why @mollygos do you like to see rhinos cry?
     
    Banished likes this.
  11. AstralGhost

    AstralGhost Pangalactic Porcupine

    @Dunto is the one updating the 'official modding guides' post.
    The reason that guides were removed is because Stable was just updated and most guides are now outdated. If you believe this guide is updated just contact Dunto and I'm sure he'd be happy to add it back in.
     
    Dunto and The | Suit like this.
  12. Dunto

    Dunto Guest

    For some reason I felt compelled to come here.... :p

    Yes, I did go through the list of guides and remove links to ones that hadn't been updated in a while. Since yours is being kept up to date, I've re-added it.
     
    Olxinos and The | Suit like this.
  13. AstralGhost

    AstralGhost Pangalactic Porcupine

    It is my psychic powers.

    Don't worry, I only use them for good...... mostly.
     
  14. SexualRhinoceros

    SexualRhinoceros Existential Complex

    :party:
    <3
     
  15. mellian

    mellian Space Hobo


    I am getting this, in Win7 64bit and steam, and I am not sure how to get pass this to successfully repack. I edited the bat file with specific "what" "input" "output", and tried all of the '[-i] [-s] [-d] conditions resulting in the same. Modhelper is useless to me as the goal is to create a new pak to replace the base one (which i have backed up in case of errors), but nothing is creating it.
     
  16. SexualRhinoceros

    SexualRhinoceros Existential Complex

    look at tutorial in OP
     
  17. Dolan

    Dolan Pangalactic Porcupine

    As the "asset_packer" help is telling us, it required now a new argument to allow the packing process to work.
    Before update you had to tell it <mod folder> and <output name>, now you have to tell it, <assets source name>, <assets folder path> and <output filename>.
    Due to this new argument, this means a regression for all uses of "asset_packer".

    I didn't see any official communication about it, if someone got a link to more details about this evolution, thanks to him.
     
    Last edited: Feb 8, 2015
  18. DarkzXD

    DarkzXD Void-Bound Voyager

    For mac, how do you pack it? I tried doing the opposite of unpacking it but the terminal said "
    /Users/[insert my name here]/Library/Application Support/Steam/SteamApps/common/Starbound/assets/packed: Not a directory" I really need help... I used asset_packer also
     
  19. Dolan

    Dolan Pangalactic Porcupine

    What is the command line you are using ?
     
  20. agmoyer

    agmoyer Cosmic Narwhal

    Okay so the unpacker program did not do anything for me though it said it did. If it did work where was it suppose to be place and where was it suppose to place the unpacked files?

    I was able to extract 15 files... Can't do anything with them as they are random bits and pieces.
     
    Last edited: Feb 9, 2015

Share This Page