2022-07-18 20:53:34 +00:00
|
|
|
-- Copyright (c) 2022 David Vogel
|
|
|
|
--
|
|
|
|
-- This software is released under the MIT License.
|
|
|
|
-- https://opensource.org/licenses/MIT
|
|
|
|
|
2022-07-23 15:36:21 +00:00
|
|
|
-- Emulate and override some functions and tables to make everything conform more to standard lua.
|
|
|
|
-- This will make `require` work, even in sandboxes with restricted Noita API.
|
2022-07-23 18:43:04 +00:00
|
|
|
local libPath = "mods/noita-mapcap/files/libraries/"
|
|
|
|
dofile(libPath .. "noita-api/compatibility.lua")(libPath)
|
2022-07-23 15:36:21 +00:00
|
|
|
|
2022-07-23 18:43:04 +00:00
|
|
|
local EntityAPI = require("noita-api.entity")
|
2022-07-18 20:53:34 +00:00
|
|
|
|
|
|
|
local oldPerkSpawn = perk_spawn
|
|
|
|
|
|
|
|
---Spawns a perk.
|
|
|
|
---@param x number
|
|
|
|
---@param y number
|
|
|
|
---@param perkID integer
|
|
|
|
---@param dontRemoveOtherPerks boolean
|
2022-07-29 09:51:20 +00:00
|
|
|
---@return number|nil
|
2022-07-18 20:53:34 +00:00
|
|
|
function perk_spawn(x, y, perkID, dontRemoveOtherPerks)
|
2022-07-26 20:32:47 +00:00
|
|
|
local entity = EntityAPI.Wrap(oldPerkSpawn(x, y, perkID, dontRemoveOtherPerks))
|
2022-07-18 20:53:34 +00:00
|
|
|
if entity == nil then return end
|
|
|
|
|
|
|
|
-- Remove the SpriteOffsetAnimatorComponent components from the entity.
|
|
|
|
local components = entity:GetComponents("SpriteOffsetAnimatorComponent")
|
|
|
|
for _, component in ipairs(components) do
|
|
|
|
entity:RemoveComponent(component)
|
|
|
|
end
|
2022-07-29 09:51:20 +00:00
|
|
|
|
|
|
|
return entity.ID
|
2022-07-19 11:50:30 +00:00
|
|
|
end
|