mirror of
https://github.com/Ellpeck/TinyLifeExampleMod.git
synced 2024-11-26 05:28:34 +01:00
Compare commits
No commits in common. "ccd87ee2524b34c8bb576f5f65bc68cc3da29e03" and "1097f6d8f9d743cecbb784b350be5476febb4fc7" have entirely different histories.
ccd87ee252
...
1097f6d8f9
7 changed files with 45 additions and 81 deletions
|
@ -1,12 +0,0 @@
|
||||||
{
|
|
||||||
"version": 1,
|
|
||||||
"isRoot": true,
|
|
||||||
"tools": {
|
|
||||||
"cake.tool": {
|
|
||||||
"version": "2.2.0",
|
|
||||||
"commands": [
|
|
||||||
"dotnet-cake"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
11
Publish.bat
Normal file
11
Publish.bat
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
@echo off
|
||||||
|
rem move to the script directory
|
||||||
|
cd /d "%~dp0"
|
||||||
|
rem build the mod
|
||||||
|
dotnet build || exit /b
|
||||||
|
rem zip the mod
|
||||||
|
cd ./bin/Debug/net6.0
|
||||||
|
for /F %%p in ('dir /b "*.dll"') do (set file=%%p)
|
||||||
|
set dest=%file:~0,-4%.zip
|
||||||
|
tar -acf ../%dest% --exclude ref --exclude *.pdb --exclude *.deps.json *
|
||||||
|
echo Published to bin/Debug/%dest%
|
11
Publish.sh
Normal file
11
Publish.sh
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# move to the script directory
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
# build the mod
|
||||||
|
dotnet build || exit
|
||||||
|
# zip the mod
|
||||||
|
cd ./bin/Debug/net6.0
|
||||||
|
file=$(find *.dll -print)
|
||||||
|
dest=${file%????}.zip
|
||||||
|
zip -FSr ../$dest * --exclude 'ref/*' --exclude '*.pdb' --exclude '*.deps.json'
|
||||||
|
echo Published to bin/Debug/$dest
|
|
@ -1,4 +1,4 @@
|
||||||
# Tiny Life Example Mod
|
# Tiny Life Example Mod
|
||||||
An example mod for my game Tiny Life. Use this template repository to create your own mod!
|
An example mod for my game Tiny Life. Use this template repository to create your own mod!
|
||||||
|
|
||||||
To learn how to use the example mod repository and create your own mods, check out the [Modding Basics](https://docs.tinylifegame.com/articles/mod_basics.html) documentation.
|
The Tiny Life modding and custom content documentation has found a permanent home at [docs.tinylifegame.com](https://docs.tinylifegame.com).
|
11
Run.bat
Normal file
11
Run.bat
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
@echo off
|
||||||
|
rem move to the script directory
|
||||||
|
cd /d "%~dp0"
|
||||||
|
rem build the mod
|
||||||
|
dotnet build || exit /b
|
||||||
|
rem copy the mod to the mods folder
|
||||||
|
robocopy ./bin/Debug/net6.0/ "%LOCALAPPDATA%/Tiny Life/Mods" /e /is
|
||||||
|
rem run the game
|
||||||
|
set /p dir=<"%LOCALAPPDATA%/Tiny Life/GameDir"
|
||||||
|
cd /d %dir%
|
||||||
|
"Tiny Life.exe" -v --skip-splash --skip-preloads
|
11
Run.sh
Normal file
11
Run.sh
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# move to the script directory
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
# build the mod
|
||||||
|
dotnet build || exit
|
||||||
|
# copy the mod to the mods folder
|
||||||
|
cp -r ./bin/Debug/net6.0/* "$HOME/.local/share/Tiny Life/Mods"
|
||||||
|
# run the game
|
||||||
|
dir=$(<"$HOME/.local/share/Tiny Life/GameDir")
|
||||||
|
cd "$dir"
|
||||||
|
"./Tiny Life" -v --skip-splash --skip-preloads
|
68
build.cake
68
build.cake
|
@ -1,68 +0,0 @@
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
var target = Argument("target", "Run");
|
|
||||||
var config = Argument("configuration", "Release");
|
|
||||||
|
|
||||||
var tinyLifeDir = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/Tiny Life";
|
|
||||||
|
|
||||||
Task("Build").DoesForEach(GetFiles("**/*.csproj"), p => {
|
|
||||||
DotNetBuild(p.FullPath, new DotNetBuildSettings { Configuration = config });
|
|
||||||
});
|
|
||||||
|
|
||||||
Task("CopyToMods").IsDependentOn("Build").Does(() => {
|
|
||||||
var dir = $"{tinyLifeDir}/Mods";
|
|
||||||
CreateDirectory(dir);
|
|
||||||
var files = GetFiles($"bin/{config}/net*/**/*");
|
|
||||||
CopyFiles(files, dir, true);
|
|
||||||
});
|
|
||||||
|
|
||||||
Task("Run").IsDependentOn("CopyToMods").Does(() => {
|
|
||||||
// start the tiny life process
|
|
||||||
var exeDir = $"{tinyLifeDir}/GameDir";
|
|
||||||
if (!FileExists(exeDir))
|
|
||||||
throw new Exception("Didn't find game directory information. Run the game manually at least once to allow the Run task to be executed.");
|
|
||||||
var exe = $"{System.IO.File.ReadAllText(exeDir)}/Tiny Life";
|
|
||||||
var process = Process.Start(new ProcessStartInfo(exe) {
|
|
||||||
CreateNoWindow = true
|
|
||||||
});
|
|
||||||
|
|
||||||
// we wait a bit to make sure the process has generated a new log file, bleh
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
|
|
||||||
// attach to the newest log file
|
|
||||||
var logsDir = $"{tinyLifeDir}/Logs";
|
|
||||||
var log = System.IO.Directory.EnumerateFiles(logsDir).OrderByDescending(System.IO.File.GetCreationTime).FirstOrDefault();
|
|
||||||
if (log != null) {
|
|
||||||
using (var stream = new FileStream(log, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
|
|
||||||
using (var reader = new StreamReader(stream)) {
|
|
||||||
var lastPos = 0L;
|
|
||||||
while (!process.HasExited) {
|
|
||||||
if (reader.BaseStream.Length > lastPos) {
|
|
||||||
reader.BaseStream.Seek(lastPos, SeekOrigin.Begin);
|
|
||||||
string line;
|
|
||||||
while ((line = reader.ReadLine()) != null)
|
|
||||||
Information(line);
|
|
||||||
lastPos = reader.BaseStream.Position;
|
|
||||||
}
|
|
||||||
Thread.Sleep(10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Information($"Tiny Life exited with exit code {process.ExitCode}");
|
|
||||||
});
|
|
||||||
|
|
||||||
Task("Publish").IsDependentOn("Build").DoesForEach(() => GetDirectories($"bin/{config}/net*"), d => {
|
|
||||||
var dllFile = GetFiles($"{d}/**/*.dll").FirstOrDefault();
|
|
||||||
if (dllFile == null)
|
|
||||||
throw new Exception($"Couldn't find built mod in {d}");
|
|
||||||
var dllName = System.IO.Path.GetFileNameWithoutExtension(dllFile.ToString());
|
|
||||||
var zipLoc = $"{d.GetParent()}/{dllName}.zip";
|
|
||||||
Zip(d, zipLoc, GetFiles($"{d}/**/*"));
|
|
||||||
Information($"Published {dllName} to {zipLoc}");
|
|
||||||
});
|
|
||||||
|
|
||||||
RunTarget(target);
|
|
Loading…
Reference in a new issue