Cuberite Forum

Full Version: Edit signs
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is it possible to programaticaly (by code) change sign text?

I wonna show status of few places that are around city in city hall on signs. Is it possible with MCSever and Lua plugin?
Usually you need to do something like this:
-- World is the cWorld of the sign, X, Y, Z are the sign's coords
World:DoWithBlockEntityAt(X, Y, Z,
  function (a_CBBlockEntity)
    local BlockType = a_CBBlockEntity:GetBlockType()
    if ((BlockType == E_BLOCK_WALLSIGN) or (BlockType == E_BLOCK_SIGNPOST)) then
      local Sign = tolua.cast(a_CBBlockEntity, "cSignEntity")
      Sign:SetLines("line1", "line2", "line3", "line4")
    end
  end
)
Note that I wrote this code off of my head, might not work Smile
(10-02-2014, 08:00 AM)LO1ZB Wrote: [ -> ]Have a look here: http://mc-server.xoft.cz/LuaAPI/cSignEntity.html
"This class is only used when generating chunks, so that the plugins may generate signs within new chunks"

I wonna edit sign in existing world, so cSignEntity itself it's not for me Smile

(10-02-2014, 03:57 PM)xoft Wrote: [ -> ]Usually you need to do something like this:
-- World is the cWorld of the sign, X, Y, Z are the sign's coords
World:DoWithBlockEntityAt(X, Y, Z,
  function (a_CBBlockEntity)
    local BlockType = a_CBBlockEntity:GetBlockType()
    if ((BlockType == E_BLOCK_WALLSIGN) or (BlockType == E_BLOCK_SIGNPOST)) then
      local Sign = tolua.cast(a_CBBlockEntity, "cSignEntity")
      Sign:SetLines("line1", "line2", "line3", "line4")
    end
  end
)
Note that I wrote this code off of my head, might not work Smile
Thank, I'll try it.
If you want to edit signs in an existing world you have to use cWorld:SetSignLines(a_X, a_Y, a_Z, a_Line1, a_Line2, a_Line3, a_Line4, [cPlayer])
The player parameter is optional.
Right, STR_Warrior got the right answer, I completely forgot about that function.

The code I gave you should work as well, but is needlessly complicated.