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
You can use the
cMonster:SetCustomName method. You can use it like this:
world:DoWithEntityByID(entityId, function(entity)
entity:SetCustomName("Name")
end)
(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
Did you actually use <world>:DoWithEntityByID? Because simply defining a function doesn't immediately call it.
(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.
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.
(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

but I totally understand.
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?
(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

. 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.