Cuberite Forum
Edit signs - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: Edit signs (/thread-1604.html)



Edit signs - misiek - 10-02-2014

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?


RE: Edit signs - LO1ZB - 10-02-2014

Have a look here: http://mc-server.xoft.cz/LuaAPI/cSignEntity.html


RE: Edit signs - xoft - 10-02-2014

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


RE: Edit signs - misiek - 10-03-2014

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


RE: Edit signs - NiLSPACE - 10-03-2014

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.


RE: Edit signs - xoft - 10-03-2014

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.