Skip to content

Commit fe77b40

Browse files
authored
Added code from the wiki mod creation guide (#6)
1 parent 86af892 commit fe77b40

5 files changed

Lines changed: 86 additions & 10 deletions

File tree

src/.gitignore

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
1-
# Thunderstore CLI build output
2-
build/
1+
# For files used only by a symlink to the ReturnOfModding plugins folder
2+
/src/LICENSE
3+
/src/icon.png
4+
/src/manifest.json
5+
6+
# For source files used to build packages
7+
/packages
8+
9+
# For build artifacts created by the Thunderstore CLI
10+
/build
11+
# For the Thunderstore CLI executable itself, if you include it in your root folder
12+
tcli.exe

src/src/main.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@ public.config = config -- so other mods can access our config
4141
local function on_ready()
4242
-- what to do when we are ready, but not re-do on reload.
4343
if config.enabled == false then return end
44-
44+
mod = modutil.mod.Mod.Register(_PLUGIN.guid)
45+
4546
import 'ready.lua'
4647
end
4748

4849
local function on_reload()
4950
-- what to do when we are ready, but also again on every reload.
5051
-- only do things that are safe to run over and over.
51-
52+
if config.enabled == false then return end
53+
5254
import 'reload.lua'
5355
end
5456

src/src/ready.lua

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
-- so you will most likely want to have it reference
88
-- values and functions later defined in `reload.lua`.
99

10+
-- These are some sample code snippets of what you can do with our modding framework:
1011
local file = rom.path.combine(rom.paths.Content, 'Game/Text/en/ShellText.en.sjson')
11-
1212
sjson.hook(file, function(data)
1313
return sjson_ShellText(data)
1414
end)
@@ -20,4 +20,56 @@ end)
2020

2121
game.OnControlPressed({'Gift', function()
2222
return trigger_Gift()
23-
end})
23+
end})
24+
25+
26+
-- Everything below this line is part of the example mod creation guide,
27+
-- which you can find on our wiki, replacing Schelemeus portrait:
28+
-- https://sgg-modding.github.io/Hades2ModWiki/docs/category/creating-your-first-mod
29+
-- Note that the custom .pkg files are not included in the template, and you will
30+
-- need to create them yourself if you want to follow the tutorial.
31+
32+
-----------------------------------------------------------
33+
--------------- Step 1: Loading the package ---------------
34+
-----------------------------------------------------------
35+
36+
------- Method 1: Calling the package load function when entering the Hub_PreRun room
37+
-- modutil.mod.Path.Wrap("DeathAreaRoomTransition", function(base, source, args)
38+
-- if game.CurrentHubRoom.Name == "Hub_PreRun" then
39+
-- mod.LoadSkellyPackage()
40+
-- end
41+
-- base(source, args)
42+
-- end)
43+
44+
45+
------- Method 2: Adding the package load function to the Schelemeus setup events
46+
-- local loadSkellyPackageCall = { FunctionName = _PLUGIN.guid .. ".LoadSkellyPackage" }
47+
-- table.insert(game.EnemyData.NPC_Skelly_01.SetupEvents, loadSkellyPackageCall)
48+
49+
50+
------- Method 3: Adding the package to the list of packages loaded whenever Schelemeus is spawned
51+
local customPortraitsPackageName = _PLUGIN.guid .. "Portraits"
52+
table.insert(game.EnemyData.NPC_Skelly_01.LoadPackages, customPortraitsPackageName)
53+
54+
55+
-----------------------------------------------------------
56+
----------- Step 2: Modifying the portrait path -----------
57+
-----------------------------------------------------------
58+
59+
-- All packages built by `deppth2 hpk` will have the package name as part of all file paths, to prevent mods from clashing
60+
-- If you added any nested folders in your package, include them here as well
61+
local newPortraitFilePath = _PLUGIN.guid .. "Portraits\\Portraits_Skelly_01"
62+
63+
-- rom.path.combine is provided by Hell2Modding to build file paths correctly across different operating systems
64+
-- rom.paths.Content() will return the path to the Content folder of the current Hades II installation
65+
local guiPortraitsVFXFile = rom.path.combine(rom.paths.Content(), "Game\\Animations\\GUI_Portraits_VFX.sjson")
66+
67+
sjson.hook(guiPortraitsVFXFile, function(data)
68+
for _, entry in ipairs(data.Animations) do
69+
if entry.Name == "Portrait_Skelly_Default_01" or entry.Name == "Portrait_Skelly_Default_01_Exit" then
70+
entry.FilePath = newPortraitFilePath
71+
entry.CreateAnimations = {}
72+
entry.OffsetY = 0
73+
end
74+
end
75+
end)

src/src/reload.lua

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
-- this file will be reloaded if it changes during gameplay,
66
-- so only assign to values or define things here.
77

8+
9+
-- These functions are part of the example code snippets from ready.lua
810
function sjson_ShellText(data)
911
for _,v in ipairs(data.Texts) do
1012
if v.Id == 'MainMenuScreen_PlayGame' then
@@ -21,4 +23,14 @@ end
2123

2224
function trigger_Gift()
2325
modutil.mod.Hades.PrintOverhead(config.message)
24-
end
26+
end
27+
28+
29+
-------------------------------------------------------------------
30+
-- This function is part of the mod creation guide from the wiki --
31+
-------------------------------------------------------------------
32+
function mod.LoadSkellyPackage()
33+
local packageName = _PLUGIN.guid .. "Portraits"
34+
print("AuthorName-ModName - Loading package: " .. packageName)
35+
LoadPackages({ Name = packageName })
36+
end

src/thunderstore.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ schemaVersion = "0.0.1"
55
[package]
66
namespace = "AuthorName"
77
name = "ModName"
8-
versionNumber = "0.0.0"
8+
versionNumber = "0.0.1"
99
description = "Allows to do some super duper thing."
1010
websiteUrl = "https://github.com/AuthorName/ModName"
1111
containsNsfwContent = false
1212

1313
[package.dependencies]
14-
Hell2Modding-Hell2Modding = "1.0.67"
14+
Hell2Modding-Hell2Modding = "1.0.70"
1515
LuaENVY-ENVY = "1.2.0"
1616
SGG_Modding-Chalk = "2.1.1"
1717
SGG_Modding-ReLoad = "1.0.2"
@@ -36,7 +36,7 @@ target = "./LICENSE"
3636
source = "./src"
3737
target = "./plugins"
3838

39-
# Remove the commented lines below if you have files to copy to the plugins_data folder (like custom .pkg files)
39+
# Uncomment (remove the #) the three lines below if you have any files to copy to the plugins_data folder (like custom .pkg files)
4040
# [[build.copy]]
4141
# source = "./data"
4242
# target = "./plugins_data"

0 commit comments

Comments
 (0)