
Potato Patch Utils
A util library for mods created by the Potato PatchPotato-Patch-Utils
A util library for mods created by the Potato Patch with the explicit intent of being used for events run by the group
What functionality does this mod add?
Automatic File Loading
PotatoPatchUtils.load_files(path, blacklist)
Will automatically load all .lua files within the passed in path (will typically be SMODS.current_mod.path)
path(string) [REQUIRED] - The file path the file loader will start at. Will automatically open folders and load files within them as wellblacklist(table) - A table of strings of file names that should be ignored on file loading (file extension, i.e..luamust be included)
Developer and Team objects
These objects are used for credits and calculating contexts outside of a traditional game object
PotatoPatchUtils.Team(args)
args is a table of the following values:
name(string) [REQUIRED] - The name of the Teamcolour(colour/gradient) - The Team name's text fill colourloc(string/boolean) - Assigns the Team's display name to a localization key of your choosing fromdescriptions.PotatoPatch. Will be assigned to'PotatoPatchTeam_' .. args.nameif a boolean is passedcalculate(function(self, context)) - A traditional calculate function, much like global mod calculate from Steamoddedcredit_rows(table) - How many developer objects to display on each row (credit screen has 2 rows, a table of 1 number will center the row in the page)short_credit(boolean) - Setting this totruewill change the team credit template text from'Created by team 'to'Created by '
PotatoPatchUtils.Team {
name = 'Example Team',
colour = HEX(ffffff),
loc = true, -- Can also be `loc = 'k_exampleteam_name'` where the string is an arbitrary localization dictionary entry
}
PotatoPatchUtils.Developer(args)
args is a table of the following values:
name(string) [REQUIRED] - The name of the Developercolour(colour/gradient) - The Developer name's text fill colourloc(string/boolean) - Assigns the Developer's display name to a localization key of your choosing fromdescriptions.PotatoPatch. Will be assigned to'PotatoPatchDev_' .. args.nameif a boolean is passedcalculate(function(self, context)) - A traditional calculate function, much like global mod calculate from Steamoddedteam(string) - The name of the Team the Developer is a part ofatlas(string) - The key of the atlas your credit art will be pulled frompos(table) - A coordinate table for the position of your credit artsoul_pos(table) - A coordinate table for the position of your credit art's soul sprite
PotatoPatchUtils.Developer {
name = 'doofus',
colour = HEX(000000),
loc = true, -- Can also be `loc = 'k_doofus_name'` where the string is an arbitrary localization dictionary entry
team = 'Example Team' -- Must match an already existing Team name
atlas = 'modprefix_atlas',
pos = {x = 0, y = 0}
}
Credits
Adding these values to a game object will automatically add Credits to whoever is specified in the object's description box. The format should look something like this: ppu_artist = {'Artist1', 'Artist2'}
If the name of a Developer or Team object are used, the text will use the specified colour of the associated object. For example, if Developer 'Eremel' exists with a colour property and a Joker contains ppu_coder = {'Eremel'}, the text will be coloured in with Eremel's defined colour property
ppu_artist(table) - The artist(s) of the Game Objectppu_coder(table) - The coders(s) of the Game Objectppu_team(table) - The team the Game Object was created for
If you wish to add a credit page for each Team present in your mod, add SMODS.current_mod.extra_tabs = PotatoPatchUtils.CREDITS.register_page(SMODS.current_mod) to your mod.
Localization Loading
This feature allows for multiple localization .lua files to be used in one project. This allows for much easier handling of localization files in collaborative efforts
PotatoPatchUtils.LOC.process_loc_text(locPath)
locPath(string) [REQUIRED] - A string of the path leading to the root localization folder Creating a folder within the localization folder that has a name that matches a valid localization code will be loaded automatically after running this function
Info Menu
A customizeable workflow that allows easy creation of pop-up windows, primarily for use as tutorials
Text for an Info Menu must be defined in a localization file under PotatoPatch = { Info_Menu = { menu_type } }, and will consist of a name and text field. text fields can contain subsequent name and text fields which will make up the pages of a window.
The following is an example of proper localization setup from Stocking Stuffer's tutorial pop-up:
PotatoPatchUtils.INFO_MENU.create_menu(args)
args is a table of the following values:
menu_type(string) [REQUIRED] - The user-specified type or name of the menu to create. Must also match a key defined in localizationback_func(string) - A string that points to the menu's callback function. Defaults toexit_overly_menupage(int) - The page of the menu that will be opened on call. Defaults to1image(sprite) - A sprite that is to be displayed at the top of the menuvars(table) - A table of values to pass into as localization variables