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

Developer want to make NoitaMP compatible with other mods #96

Open
Ismoh opened this issue Dec 30, 2022 · 2 comments
Open

Developer want to make NoitaMP compatible with other mods #96

Ismoh opened this issue Dec 30, 2022 · 2 comments
Labels
enhancement New feature or request. This will increase MINOR version number, when merged into develop. help_wanted Extra attention is needed

Comments

@Ismoh
Copy link
Owner

Ismoh commented Dec 30, 2022

Is your feature request related to a problem? Please describe.
Does NoitaMP work with other mods?

Describe the solution you'd like
There is a config.lua in noita-mp root directory, which work like a patch file for other mods.
Let's mark this mod as the first mod for testing mod compatibility.

Additional context
Make sure NoitaMP is at the bottom of mod load order!

@Ismoh Ismoh added enhancement New feature or request. This will increase MINOR version number, when merged into develop. help_wanted Extra attention is needed labels Dec 30, 2022
@Ismoh Ismoh added this to the Features or QoL milestone Dec 30, 2022
@Ismoh Ismoh added this to NoitaMP Dec 30, 2022
@Ismoh
Copy link
Owner Author

Ismoh commented Dec 30, 2022

look at
https://github.com/Ismoh/NoitaMP/blob/84d3d26464789772cea3b6caef8033227d9cb15b/mods/noita-mp/config.lua
and add:

EntityGetWithTag("player_unit") = { EntityUtils.getLocalPlayerEntityId() }

Done! Should work theoretically.

------------------------------------------------------------------------------------------------
--- getLocalPlayerEntityId
------------------------------------------------------------------------------------------------
--- Returns the local player entity id.
--- @return number localPlayerEntityId
function EntityUtils.getLocalPlayerEntityId()
local cpc = CustomProfiler.start("EntityUtils.getLocalPlayerEntityId")
if EntityUtils.isEntityAlive(EntityUtils.localPlayerEntityId) then
-- TODO: I think this can lead to problems. Think of polymorphed minä. EntityId will change!
CustomProfiler.stop("EntityUtils.getLocalPlayerEntityId", cpc)
return EntityUtils.localPlayerEntityId
end
local polymorphed, entityId = EntityUtils.isPlayerPolymorphed()
if polymorphed then
---@cast entityId number
CustomProfiler.stop("EntityUtils.getLocalPlayerEntityId", cpc)
return entityId
end
local playerEntityIds = EntityGetWithTag("player_unit")
for i = 1, #playerEntityIds do
if NetworkVscUtils.hasNetworkLuaComponents(playerEntityIds[i]) then
local compOwnerName, compOwnerGuid, compNuid = NetworkVscUtils.getAllVcsValuesByEntityId(playerEntityIds[i])
if compOwnerGuid == localOwner.guid then
EntityUtils.localPlayerEntityId = playerEntityIds[i]
CustomProfiler.stop("EntityUtils.getLocalPlayerEntityId", cpc)
return playerEntityIds[i]
end
end
end
logger:debug(logger.channels.entity,
"Unable to get local player entity id. Returning first entity id(%s), which was found.",
playerEntityIds[1])
EntityUtils.localPlayerEntityId = playerEntityIds[1]
CustomProfiler.stop("EntityUtils.getLocalPlayerEntityId", cpc)
return playerEntityIds[1]
end

@ofoxsmith ofoxsmith moved this to 📋 Backlog in NoitaMP Feb 7, 2023
@Ismoh
Copy link
Owner Author

Ismoh commented Nov 4, 2023

There are different/separated lua contexts per init.lua/mod. Other mods needs to loadfile(mods/noita-mp/config.lua)?

To make overwritten noita api functions available?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request. This will increase MINOR version number, when merged into develop. help_wanted Extra attention is needed
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant