Change Villager's name
#1
Ok, so I want to change Villager's name. To get the Villager, I can only use it's entity ID...

How can I change it's CustomDisplayName and/or other properties?

Thanks in advance
Reply
Thanks given by:
#2
You can use the cMonster:SetCustomName method. You can use it like this:
world:DoWithEntityByID(entityId, function(entity)
   entity:SetCustomName("Name")
end)
Reply
Thanks given by: MGlolenstine
#3
(08-02-2018, 02:19 AM)NiLSPACE Wrote: You can use the cMonster:SetCustomName method. You can use it like this:
world:DoWithEntityByID(entityId, function(entity)
   entity:SetCustomName("Name")
end)

That's what I tried, but it didn't work...

Here's my code
Code:
local vilName = "Villager123"
function ChangeVillager(Entity)
       if(Entity:IsMob())then
               Entity:SetRelativeWalkSpeed(0)
               Entity:SetCustomName(vilName)
               Entity:SetCustomNameAlwaysVisible(true)
               vilName = ""
               Entity:SetMaxHealth(999999999999)
               Entity:SetHealth(999999999999)
       end
end
Reply
Thanks given by:
#4
Did you actually use <world>:DoWithEntityByID? Because simply defining a function doesn't immediately call it.
Reply
Thanks given by:
#5
(08-02-2018, 05:27 AM)NiLSPACE Wrote: Did you actually use <world>:DoWithEntityByID? Because simply defining a function doesn't immediately call it.

I did...

Code:
Player:GetWorld():DoWithEntityByID(Player:GetWorld():SpawnMob(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ(), mtVillager, false), ChangeVillager)

I do know how to code, but I'm new to LUA and Cuberite.
Reply
Thanks given by:
#6
Maybe you know how to code (how are we supposed to know?), but we do know that you definitely suck at asking questions.
http://catb.org/~esr/faqs/smart-questions.html#intro
Reply
Thanks given by:
#7
Quote: but we do know that you definitely suck at asking questions.

That's a little harsh, but you do have a point. Remember, we know nothing except the context you give us.

Could you validate that the callback is actually being called? A simple print statement in the beginning should suffice.
Reply
Thanks given by:
#8
(08-02-2018, 06:45 AM)NiLSPACE Wrote:
Quote: but we do know that you definitely suck at asking questions.

That's a little harsh, but you do have a point. Remember, we know nothing except the context you give us.

Could you validate that the callback is actually being called? A simple print statement in the beginning should suffice.

Well it is being called, as the Villager is "Invincible"...
I just don't think that the SetCustomName is working, as it's the only thing in that code block that shows no results.

And you xoft... I don't mind a bit of productive criticism, but I don't like toxic people Wink but I totally understand.
Reply
Thanks given by:
#9
Yeah, sorry, I'm in a bit foul mood today.

I have a feeling that the custom name (or its change) is not propagated through the network protocol. If you log out and back in to the game, does the name update?
Reply
Thanks given by:
#10
(08-02-2018, 07:01 AM)xoft Wrote: Yeah, sorry, I'm in a bit foul mood today.

I have a feeling that the custom name (or its change) is not propagated through the network protocol. If you log out and back in to the game, does the name update?

Don't worry, I hppe that you'll be in a better mood tomorrow Smile . Sadly the name doesn't update on a relog, not even after I restart the server.

I'm using Raspberry Pi 2B if that makes any difference.
Reply
Thanks given by:




Users browsing this thread: 7 Guest(s)