Pakgen

From Daelphinux
Jump to: navigation, search

Pakgen is a simple package generator for PHPBB3 smiley packages.

Problem

I needed to take some emoticon icon sets and turn them into PHPBB3 smiley packages for the [Forums]. The easiest way to accomplish this en masse was to write a script that would create the necessary '.pak' file to avoid having to code each emoji in by hand.

Solution

.Pak Structure

The big trick of making smiley packages is the .pak file has to be configured the right way, or the forum will reject it and the smilies will not get added to the forum properly.

The formatting is as follows:

'filename','width','height','shown on selector','Emotion','use code',

This shows that each value has to be encapsulated in single quotes, and a comma follows every value *even at the end of the line*. This is a departure from normal CSV files.

Value Definitions

  • 'filename'
    • This is the name of the file that will be the emoticon
  • height
    • This is the height of the image in format '##.px'
  • width
    • This is the width of the image in format '##.px'
  • shown on selector
    • This determines whether or not the emoticon will be shown on the emote selector every time a user makes a post.
  • Emotion
    • This is a simple descriptor of the emoticon
  • use code
    • This is the code that will be invoked to use the emoticon

Python Solution

I write a simple .pak file generator in python that can be found on my [Scripts Repo].

Use

In a terminal run

Python3 pakgen.py  

This will run the pakgen against the current directory. There are three other optional arguments.

Arguments

  • -d, --directory
    • This allows you to point the script at another directory, either by absolute or relative path.
  • -s, --show
    • This is a boolean (True or False) value that will determine whether or not the emoticon is shown on the selector.
  • -o, --output
    • This requires a filename for the application to write output to. This will be your .pak file.
    • If this is not specified the application will output to standard out.