Edit signs
#1
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?
Reply
Thanks given by:
#2
Have a look here: http://mc-server.xoft.cz/LuaAPI/cSignEntity.html
Reply
Thanks given by:
#3
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
Reply
Thanks given by:
#4
(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.
Reply
Thanks given by:
#5
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.
Reply
Thanks given by: xoft
#6
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.
Reply
Thanks given by: NiLSPACE




Users browsing this thread: 4 Guest(s)