Event

peer:nickname:change

Client

Fired when the player nickname is changed

Signal

"peer:nickname:change"

Arguments

TypeNameDescription
stringold_nameUsername before the change
stringnew_nameUsername after the change

This signal is only fired on the client.

  • Both arguments are the effective username, an empty nickname resolves to the operating system username.
  • It is not fired when the resulting username stays the same, for example when only surrounding whitespace changes.
  • It is not fired for the nickname loaded from the saved settings when the client starts, use core.engine.get_nickname to read the initial value.

Example

React to a nickname change
util.event.on("peer:nickname:change", function(old_name, new_name)
    core.engine.print("info", "Nickname changed:", old_name, "->", new_name)
end)
Keep a cached name up to date
local player_name = core.engine.get_nickname()

util.event.on("peer:nickname:change", function(_, new_name)
    player_name = new_name
end)

On this page