Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #123

Closed
wants to merge 10 commits into from
137 changes: 137 additions & 0 deletions .debug/lua-definitions/noitapatcher.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---@meta 'noitapatcher'
---@module noitapatcher

local noitapatcher = {}

---Enable OnProjectileFired and OnProjectileFiredPost callbacks.
---@return nil
function noitapatcher.InstallShootProjectileFiredCallbacks() end

---Enables GetDamageDetails in newly created Lua states.
---@return nil
function noitapatcher.InstallDamageDetailsPatch() end

---Sets Noita's internal RNG state to the specified value.
---This RNG state is used for many things including setting a fired projectile's
---direction based on random spread.
---@param rng_value integer New RNG state value
function noitapatcher.SetProjectileSpreadRNG(rng_value) end

---Disable the red flash upon taking damage for all entities with a PlatformShooterPlayerComponent except for the one specified by entity_id.
---You can restore the original behaviour by passing in -1 for the entity_id.
---@param entity_id integer ID of the only entity for which to do the damage flash.
function noitapatcher.RegisterPlayerEntityId(entity_id) end

---Change the item that the entity is holding.
---@param entity_id integer id of the entity for which you want to change what they are holding.
---@param item_id integer id of the entity that should be held. For the best effect it should be an item in the inventory_quick child of the entity specified by entity_id.
---@param unknown boolean Not sure what this does. Let me know if you find out!
---@param make_noise boolean Whether or not switching to this item should make a noise.
function noitapatcher.SetActiveHeldEntity(entity_id, item_id, unknown, make_noise) end

---Changes the entity that the game considers to be the player.
---This determines what entity is followed by the camera and whose death ends the game.
---A bunch more stuff is probably tied to this.
---@param entity_id integer The entity to make the game think of as the player.
function noitapatcher.SetPlayerEntity(entity_id) end

---Enables or disables game simulate pausing when opening escape or wand menu.
---You can only disable pausing at the moment, reenabling is not supported.
---@param enabled boolean Whether to enable or disable pausing.
function noitapatcher.EnableGameSimulatePausing(enabled) end

---Disable InventoryGuiComponent updates without disabling the component.
---Disabling updates for this component makes clicking on an empty wand slot work
---after using EnableGameSimulatePausing(false) and entering the wand pickup menu.
---@param enabled boolean Whether to enable or disable Inventory GUI updates.
function noitapatcher.EnableInventoryGuiUpdate(enabled) end

---Enable/disable ItemPickUpperComponent updates for the entity registerd using RegisterPlayerEntityId
---Disabling updates for this component prevents double wand cards from appearing
---after using EnableGameSimulatePausing(false) and entering the wand pickup menu.
---@param enabled boolean Whether to enable or disable ItemPickUpper updates.
function noitapatcher.EnablePlayerItemPickUpper(enabled) end

---Send a 'use item' message causing the item to get activated by the entity's ability component.
---@param responsible_entity_id integer Entity that should be seen as responsible for the item's use.
---@param item_entity_id integer Wand or other item entity.
---@param ignore_reload boolean _
---@param charge boolean _
---@param started_using_this_frame boolean _
---@param pos_x number _
---@param pos_y number _
---@param target_x number _
---@param target_y number _
function noitapatcher.UseItem(responsible_entity_id, item_entity_id, ignore_reload, charge, started_using_this_frame, pos_x, pos_y, target_x, target_y) end

---Patch out logging for a certain string literal.
---@param logstr string The string to look for in the exe, it should end with a newline character in most cases.
---@return bool patch_successful
function noitapatcher.SilenceLogs(logstr) end

---Like Noita's LoadPixelScene, but doesn't care if the scene has been loaded before.
---@param materials_filename string
---@param colors_filename string
---@param x number
---@param y number
---@param background_file string
---@param skip_biome_checks bool Defaults to false
---@param skip_edge_textures bool Defaults to false
---@param color_to_material_table table Defaults to {}
---@param background_z_index int Defaults to 50
function noitapatcher.ForceLoadPixelScene(materials_filename, colors_filename, x, y, background_file, skip_biome_checks, skip_edge_textures, color_to_material_table, background_z_index) end

---Enable source location logging
---@param enable boolean enable or disable
function noitapatcher.EnableExtendedLogging(enable) end

---Enable the FilterLog callback
---@param enable boolean enable or disable
function noitapatcher.EnableLogFiltering(enable) end

---Disable system updates
---@param system_name string Name of the system to disable, for instance BlackHoleSystem
---@param change_to bool enable (true) or disable (false)
---@return bool change_succeeded
function noitapatcher.ComponentUpdatesSetEnabled(system_name, change_to) end

---Serialize an entity
---@param entity_id integer
---@nodiscard
---@return string serialized_data
function noitapatcher.SerializeEntity(entity_id) end

---Deserialize an entity. If x and y are provided then the entity's position is changed to that instead of using the position info in the serialized data.
---@param entity_id integer Entity to deserialize into, most of the time you want this to be an "empty" entity.
---@param serialized_data string The serialized data
---@param x number? Position to force the entity to if provided
---@param y number? Position to force the entity to if provided
---@return integer? entity_id The entity_id passed into the function if deserialization was successful.
function noitapatcher.DeserializeEntity(entity_id, serialized_data, x, y) end

---Set box2d parameters of a PhysicsBody(2)Component
---@param component_id integer The PhysicsBody(2)Component
---@param x number box2d x coordinate
---@param y number box2d y coordinate
---@param r number box2d rotation
---@param vx number box2d x velocity
---@param vy number box2d y velocity
---@param av number box2d angular velocity
function noitapatcher.PhysBodySetTransform(component_id, x, y, r, vx, vy, av) end

---Get the box2d parameters of a PhysicsBody(2)Component
---@param component_id integer The PhysicsBody(2)Component
---@nodiscard
---@return number box2d x coordinate
---@return number box2d y coordinate
---@return number box2d rotation
---@return number box2d x velocity
---@return number box2d y velocity
---@return number box2d angular velocity
function noitapatcher.PhysBodyGetTransform(component_id) end

---Mark the current game mode as a daily. Disables spell progress and if called during mod init makes all spells available for the run.
---@param deterministic bool
function noitapatcher.SetGameModeDeterministic(deterministic)end

return noitapatcher
31 changes: 18 additions & 13 deletions .github/workflows/dependency-updater.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
name: Update dependecies now and then
name: Update dependecies every saturday at 00:00 UTC
on:
schedule:
# Weekly on saturday
# Weekly on saturday at 00:00 UTC
- cron: "0 0 * * 6"
push:
branches:
- develop

jobs:
update-dependencies:
name: Update dependencies
runs-on: windows-latest

steps:
- uses: actions/checkout@v3
with:
Expand All @@ -27,7 +30,7 @@ jobs:

# - name: Install and init luarocks
# shell: cmd
# run: |
# run: |
# cd ${{ github.workspace}}\mods\noita-mp\
# set INIT_PATH=%CD%
# REM // resolve absolute path
Expand All @@ -41,10 +44,10 @@ jobs:
# popd
# echo Relative path: %REL_PATH%
# echo Maps to path: %ABS_PATH%

# REM // init luarocks
# %ABS_PATH%\luarocks --lua-dir="${{ github.workspace}}\LuaJIT-2.0.4" --lua-version="5.1" init noita-mp --output="${{ github.workspace}}\mods\noita-mp" --homepage="https://github.com/Ismoh/NoitaMP" --lua-versions="5.1" --license="GNU GPL v3"

# REM // change luarocks projects config
# %ABS_PATH%\luarocks config --scope="project" lua_interpreter luajit.exe
# %ABS_PATH%\luarocks config --scope="project" lua_dir ${{ github.workspace}}\LuaJIT-2.0.4
Expand All @@ -53,7 +56,7 @@ jobs:
# %ABS_PATH%\luarocks config --scope="project" variables.LUA_INCDIR ${{ github.workspace}}\LuaJIT-2.0.4\include
# %ABS_PATH%\luarocks config --scope="project" variables.CFLAGS "GODDAMNIT"
# %ABS_PATH%\luarocks config

# if exist lua.bat (
# echo "LuaRocks project init successfully"
# ) else (
Expand All @@ -66,7 +69,7 @@ jobs:
# echo "::error::LuaRocks project init failed. Unable to find luarocks.bat"
# exit 1
# )

# - name: Fix LuaRocks bug
# env:
# GH_TOKEN: ${{ github.token }}
Expand All @@ -83,13 +86,13 @@ jobs:
# call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86 10.0.22000.0 -vcvars_ver=14
# cd ${{ github.workspace }}\mods\noita-mp\
# # luarocks install --only-deps ${{ github.workspace }}\mods\noita-mp\noita-mp-3.0.0-3.rockspec

# git commit -m "Updated LuaRocks dependencies" -a || echo "No changes to commit"

- name: Update NoitaPatcher
env:
GH_TOKEN: ${{ github.token }}
run: |
GH_TOKEN: ${{ github.token }}
run: |
$noitaptacherPath = "${{ github.workspace }}\mods\noita-mp\lua_modules\lib\lua\5.1\noitapatcher.dll"

if ([System.IO.File]::Exists($noitaptacherPath)) {
Expand Down Expand Up @@ -122,6 +125,7 @@ jobs:
cd ${{ github.workspace }} # go back to root otherwise we cannot delete the temp folder
Remove-Item -Path "${{ github.workspace }}\temp" -Recurse -Force

git add ${{ github.workspace }}\mods\noita-mp\lua_modules\lib\lua\5.1\noitapatcher.version
git add -f $noitaptacherPath
git add "${{ github.workspace }}\.debug\lua-definitions\noitapatcher.lua"
git commit -m "Updated NoitaPatcher dependencies" -a || echo "No changes to commit"
Expand Down Expand Up @@ -165,20 +169,21 @@ jobs:
cd ${{ github.workspace }} # go back to root otherwise we cannot delete the temp folder
Remove-Item -Path "${{ github.workspace }}\temp" -Recurse -Force

git add ${{ github.workspace }}\mods\noita-mp\lua_modules\lib\lua\5.1\nsew.version
git add -f $nsewPath
git add -f "${{ github.workspace }}\mods\noita-mp\lua_modules\share\lua\5.1\nsew\*.lua"
git commit -m "Updated nsew dependencies" -a || echo "No changes to commit"

- name: Push changes
- name: Push changes and create a pull request
env:
GH_TOKEN: ${{ github.token }}
run: |
git pull origin dependency-updates
git push origin dependency-updates

$prTitleArray = gh pr list --head "dependency-updates" --json "title" | ConvertFrom-Json
if ($prTitleArray.Count -gt 0) {
echo "PR already exists. Nothing to do!"
exit 0
} else {
gh pr create --title "Update dependencies" --body "This PR was automatically created by the dependency updater workflow. Resolves #117" --base develop --head dependency-updates
}
Binary file not shown.
1 change: 1 addition & 0 deletions mods/noita-mp/lua_modules/lib/lua/5.1/noitapatcher.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
release-1.18.0
1 change: 1 addition & 0 deletions mods/noita-mp/lua_modules/lib/lua/5.1/nsew.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
release-0.0.5
Binary file not shown.
43 changes: 43 additions & 0 deletions mods/noita-mp/lua_modules/share/lua/5.1/nsew/load.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
--- Helper module for loading NSEW into your mod.
--
-- This is not a module you would load in using `load = require("nsew.load")`.
-- Instead this file exists to help make Lua's `require` function work with the
-- NSEW modules.
--
-- @module nsew.load

__nsew_path = nil

--- Setup the environment for `require`-ing NSEW modules.
-- The usage example shows how you would use this file for the following Noita
-- mod structure:
--
-- <code><pre>nsew_client/
--├── init.lua
--├── mod.xml
--├── files
--│   └── ...
--├── deps
--│   └── nsew
--│   ├── load.lua
--│   └── < .. all other nsew files .. ></pre></code>
--
-- You can adapt this example for your own mod. :^)
--
-- @tparam string path path to the directory that contains the 'nsew' folder
-- @usage
-- -- nsew_client/init.lua
--
-- -- This tells NSEW where its files are, and configures Lua `package` globals
-- -- so that [`local world = require("nsew.world")`] will work.
-- local nsew_do_load = dofile_once("mods/nsew_client/deps/nsew/load.lua")
-- nsew_do_load("mods/nsew_client/deps")
--
-- local world = require("nsew.world")
-- -- ...
function do_load(path)
__nsew_path = path .. "/nsew/"
package.path = package.path .. ";" .. path .. "/?.lua"
end

return do_load
11 changes: 11 additions & 0 deletions mods/noita-mp/lua_modules/share/lua/5.1/nsew/native_dll.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- Native library. Primarily for internal use.
-- @module nsew.native_dll

local ffi = require("ffi")

native_dll = {}

--- The NSEW support dll loaded in with `ffi.load`.
native_dll.lib = ffi.load(__nsew_path .. "nsew_native.dll")

return native_dll
Loading