Skip to content

Commit

Permalink
Merge pull request #40 from Ismoh/23-show-players-name-in-game
Browse files Browse the repository at this point in the history
Function to show players names

Going to create a follow up issue to add this function after #27 was merged.
  • Loading branch information
Ismoh authored Apr 16, 2022
2 parents 6af3562 + 6fb39f0 commit fbccb29
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions mods/noita-mp/files/scripts/noita-components/name-tags.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function PlayerNameFunction(playerName)
gui = gui or GuiCreate()
GuiStartFrame(gui)
local screenWidth, screenHeight = GuiGetScreenDimensions(gui)
screenWidth, screenHeight = screenWidth/2, screenHeight/2

local entityId = GetUpdatedEntityID()
local x, y = EntityGetTransform(entityId)

function getEntityPositionOnScreen(entityId)
local camX, camY = GameGetCameraPos()
return screenWidth+((x-camX)*1.5),screenHeight+((y-camY)*1.5)
end

local entityX, entityY = getEntityPositionOnScreen(EntityGetWithTag("player_unit")[1])
local playerNameLength = string.len(playerName)
local playerNameMid = entityX -(playerNameLength*2)

GuiText(gui,playerNameMid,entityY,playerName)
end

PlayerNameFunction("testname")

0 comments on commit fbccb29

Please sign in to comment.