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

creature/npc:setName() is not working properly #2920

Open
2 of 5 tasks
pudimtibia opened this issue Sep 27, 2024 · 1 comment
Open
2 of 5 tasks

creature/npc:setName() is not working properly #2920

pudimtibia opened this issue Sep 27, 2024 · 1 comment
Labels
Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.

Comments

@pudimtibia
Copy link
Contributor

Priority

Medium

Area

  • Datapack
  • Source
  • Map
  • Other

What happened?

When we call the :setName() function, the name of the NPC or Creature is not changing. Apparently the problem is related to updating the information for the spectators. A creature:reload() function was created for this purpose, but in my tests I was not successful.

    local npc = Game.createNpc("Dummy Npc", Position(SOME_POSITION))
    if npc then
        npc:setName("Potato")
    end

What OS are you seeing the problem on?

Windows

Code of Conduct

  • I agree to follow this project's Code of Conduct
@pudimtibia pudimtibia added the Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors. label Sep 27, 2024
@luanluciano93
Copy link
Contributor

local talk = TalkAction("/setmonstername")

function talk.onSay(player, words, param)

	if param == "" then
		player:sendCancelMessage("Command param required.")
		return true
	end

	local split = param:split(",")
	local monsterNewName = split[1]

	local spectators, spectator = Game.getSpectators(player:getPosition(), false, false, 15, 15, 15, 15)
	for i = 1, #spectators do
		spectator = spectators[i]
		if spectator:isMonster() then
			spectator:setName(monsterNewName)
		end
	end

	return false
end

talk:separator(" ")
talk:groupType("god")
talk:register()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
Development

No branches or pull requests

2 participants