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 #121

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
10 changes: 5 additions & 5 deletions mods/noita-mp/.luarocks/config-5.1.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ external_deps_dirs = {
}
lua_interpreter = "luajit.exe"
variables = {
CFLAGS = "-O2 -v",
LUA_BINDIR = "D:\\______BACKUP\\NoitaMP_repo\\NoitaMP\\LuaJIT-2.0.4\\bin",
LUA_DIR = "D:\\______BACKUP\\NoitaMP_repo\\NoitaMP\\LuaJIT-2.0.4",
LUA_INCDIR = "D:\\______BACKUP\\NoitaMP_repo\\NoitaMP\\LuaJIT-2.0.4\\include",
LUA_LIBDIR = "D:\\______BACKUP\\NoitaMP_repo\\NoitaMP\\LuaJIT-2.0.4\\lib"
CFLAGS = "-v -O2",
LUA_BINDIR = "D:\\a\\NoitaMP\\NoitaMP\\LuaJIT-2.0.4\\bin",
LUA_DIR = "D:\\a\\NoitaMP\\NoitaMP\\LuaJIT-2.0.4",
LUA_INCDIR = "D:\\a\\NoitaMP\\NoitaMP\\LuaJIT-2.0.4\\include",
LUA_LIBDIR = "D:\\a\\NoitaMP\\NoitaMP\\LuaJIT-2.0.4/bin"
}
2 changes: 1 addition & 1 deletion mods/noita-mp/lua.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
setlocal
IF "%*"=="" (set I=-i) ELSE (set I=)
set "LUAROCKS_SYSCONFDIR=C:\Program Files (x86)/luarocks"
"D:\______BACKUP\NoitaMP_repo\NoitaMP\LuaJIT-2.0.4\bin\luajit.exe" -e "package.path=\"D:\\______BACKUP\\NoitaMP_repo\\NoitaMP\\mods\\noita-mp/./lua_modules/share/lua/5.1/?.lua;D:\\______BACKUP\\NoitaMP_repo\\NoitaMP\\mods\\noita-mp/./lua_modules/share/lua/5.1/?/init.lua;C:\\Users\\Ismoh-PC\\AppData\\Roaming/luarocks/share/lua/5.1/?.lua;C:\\Users\\Ismoh-PC\\AppData\\Roaming/luarocks/share/lua/5.1/?/init.lua;\"..package.path;package.cpath=\"D:\\______BACKUP\\NoitaMP_repo\\NoitaMP\\mods\\noita-mp/./lua_modules/lib/lua/5.1/?.dll;C:\\Users\\Ismoh-PC\\AppData\\Roaming/luarocks/lib/lua/5.1/?.dll;\"..package.cpath" %I% %*
"D:\a\NoitaMP\NoitaMP\LuaJIT-2.0.4\bin\luajit.exe" -e "package.path=\"D:\\a\\NoitaMP\\NoitaMP\\mods\\noita-mp/./lua_modules/share/lua/5.1/?.lua;D:\\a\\NoitaMP\\NoitaMP\\mods\\noita-mp/./lua_modules/share/lua/5.1/?/init.lua;C:\\Users\\runneradmin\\AppData\\Roaming/luarocks/share/lua/5.1/?.lua;C:\\Users\\runneradmin\\AppData\\Roaming/luarocks/share/lua/5.1/?/init.lua;\"..package.path;package.cpath=\"D:\\a\\NoitaMP\\NoitaMP\\mods\\noita-mp/./lua_modules/lib/lua/5.1/?.dll;C:\\Users\\runneradmin\\AppData\\Roaming/luarocks/lib/lua/5.1/?.dll;\"..package.cpath" %I% %*
exit /b %ERRORLEVEL%
Binary file not shown.
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
134 changes: 134 additions & 0 deletions mods/noita-mp/lua_modules/share/lua/5.1/nsew/rect.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
--- Rectangle utilities.
-- @module nsew.rect

local rect = {}

local ffi = require("ffi")
local native_dll = require("nsew.native_dll")

ffi.cdef([[

struct nsew_rectangle {
int32_t left;
int32_t top;
int32_t right;
int32_t bottom;
};


struct nsew_rectangle_optimiser;

struct nsew_rectangle_optimiser* rectangle_optimiser_new();
void rectangle_optimiser_delete(struct nsew_rectangle_optimiser* rectangle_optimiser);
void rectangle_optimiser_reset(struct nsew_rectangle_optimiser* rectangle_optimiser);
void rectangle_optimiser_submit(struct nsew_rectangle_optimiser* rectangle_optimiser, struct nsew_rectangle* rectangle);
void rectangle_optimiser_scan(struct nsew_rectangle_optimiser* rectangle_optimiser);
int32_t rectangle_optimiser_size(const struct nsew_rectangle_optimiser* rectangle_optimiser);
const struct nsew_rectangle* rectangle_optimiser_get(const struct nsew_rectangle_optimiser* rectangle_optimiser, int32_t index);


struct lua_nsew_rectangle_optimiser {
struct nsew_rectangle_optimiser* impl;
};

]])

local Rectangle_mt = {
__index = {
area = function(r)
return (r.right - r.left) * (r.bottom - r.top)
end,
height = function(r)
return r.bottom - r.top
end,
width = function(r)
return r.right - r.left
end,
},
}
rect.Rectangle = ffi.metatype("struct nsew_rectangle", Rectangle_mt)

--- Given an iterator that returns rectangles, return an iterator where the
--- rectangle extents never exceed `size`.
-- @param it iterator returning squares
-- @tparam int size maximum width and height
-- @return rectangle iterator where the extents never exceed `size`
function rect.parts(it, size)
local region
local posx
local posy
return function()
if region == nil then
region = it()
if region == nil then
return nil
end
posx = region.left
posy = region.top
end

local endx = math.min(posx + size, region.right)
local endy = math.min(posy + size, region.bottom)

local ret = rect.Rectangle(posx, posy, endx, endy)

-- Setup for next iteration: place to the right, wraparound, or
-- we're done with this region.
if endx ~= region.right then
posx = endx
elseif endy ~= region.bottom then
posx = region.left
posy = endy
else
region = nil
end

return ret
end
end

local Optimiser_mt = {
__gc = function(opt)
native_dll.lib.rectangle_optimiser_delete(opt.impl)
end,

__index = {
submit = function(opt, rectangle)
native_dll.lib.rectangle_optimiser_submit(opt.impl, rectangle)
end,
scan = function(opt)
native_dll.lib.rectangle_optimiser_scan(opt.impl)
end,
reset = function(opt)
native_dll.lib.rectangle_optimiser_reset(opt.impl)
end,
size = function(opt)
return native_dll.lib.rectangle_optimiser_size()
end,
get = function(opt, index)
return native_dll.lib.rectangle_optimiser_get(index)
end,
iterate = function(opt)
local size = native_dll.lib.rectangle_optimiser_size(opt.impl)
local index = 0
return function()
if index >= size then
return nil
end

ret = native_dll.lib.rectangle_optimiser_get(opt.impl, index)
index = index + 1
return ret
end
end,
}
}
rect.Optimiser = ffi.metatype("struct lua_nsew_rectangle_optimiser", Optimiser_mt)

--- Create a new rectangle Optimiser
-- @treturn Optimiser empty optimiser
function rect.Optimiser_new()
return rect.Optimiser(native_dll.lib.rectangle_optimiser_new())
end

return rect
Loading
Loading