Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Changing the text on a Sign

Comments in 'Plugin Development' started by aliuly, Apr 30, 2015.

Thread Status:
Not open for further replies.
  1. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    Hi,

    I am working on a Sign plugin that would lets me show dynamic text there. So I think I got the mechanics right. (getTileEntities, get the Sign object and then do setText...)

    My question is how do you fill the text in the sign? i.e. how many characters can I put on each line? I read somewhere that the amount of text depends on the width of the characters. So, how do you calculate this?

    Any ideas?
  2. Asparanc
    Offline

    Asparanc Active Member

    Joined:
    Feb 20, 2015
    Posts:
    210
    Minecraft User:
    Asparanc
    $sign = $event->getPlayer()->getLevel()->getTile(new Vector3($block->getX(),$block->getY(),$block->getZ()));
    $sign->setText("line 1","line 2","line 3","line 3");

    This is an exemple for blockBreakEvent/place/touch/ or others event with block.
  3. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    That is not what I am asking for. My question is:

    Line1: How much text can you put here?
    Line2: How much text can you put here?
    Line3: How much text can you put here?
    Line4: How much text can you put here?
    iksaku likes this.
  4. Asparanc
    Offline

    Asparanc Active Member

    Joined:
    Feb 20, 2015
    Posts:
    210
    Minecraft User:
    Asparanc
    It depend of the letters and it you write on italic or bold, we can't calculate it beacause of so many posibilities.
  5. LegendsOfMCPE
    Offline

    LegendsOfMCPE New Member Plugin Developer

    Joined:
    May 21, 2014
    Posts:
    21
    Plugins:
    3
    @iksaku says:
    Once a player have spawned in the world, you can use:
    PHP:
    $signs = [];
    foreach(
    $level->getTiles() as $tile){
        if(
    $tile instanceof Sign){
            
    $signs[] = $tile;
        }
    }
    Now you have all the signs available in that world... time to do whatever you want :3
    For line lenght.... Just test and keep testing xD
    Praxthisnovcht likes this.
  6. PixelGuy75
    Offline

    PixelGuy75 Notable Member Plugin Developer

    Joined:
    Feb 9, 2014
    Posts:
    316
    Plugins:
    2
    Minecraft User:
    PixelGuy75
    It's like guess and check.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Take a look at TextWrapper.php in the PocketMine src.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Or just pass $block instead of a new Vector3. $block instanceof Vector3, so passing it directly is OK.
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I pretty believe that a chunk far from the player won't be loaded. Why don't you just listen to ChunkLoadEvent?
    iksaku, Falk and LegendsOfMCPE like this.
  10. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    Thanks, that is what I was looking for!
  11. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    I think the line lengths are 16 characters, and colour codes count as characters.
    Falk likes this.
  12. TonyDroide
    Offline

    TonyDroide Active Member Plugin Developer

    Joined:
    Jun 5, 2015
    Posts:
    122
    Plugins:
    1
    Minecraft User:
    TonyDroidd
  13. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    Why?
  14. TonyDroide
    Offline

    TonyDroide Active Member Plugin Developer

    Joined:
    Jun 5, 2015
    Posts:
    122
    Plugins:
    1
    Minecraft User:
    TonyDroidd
    Text Say All :)
  15. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    It says do this, it doesn't say why.

    The question in this thread (from April) is:
    Which already been answered.
    BTW, My plugin, GrabBag has had the feature to change the text of existing Signs for quite some time already (from v1.4.0 from April 16).
    jojoe77777 likes this.
  16. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    So this thread has been "solved". How do I add such prefix to this?
  17. TonyDroide
    Offline

    TonyDroide Active Member Plugin Developer

    Joined:
    Jun 5, 2015
    Posts:
    122
    Plugins:
    1
    Minecraft User:
    TonyDroidd
    Edit the title of the thread
  18. TonyDroide
    Offline

    TonyDroide Active Member Plugin Developer

    Joined:
    Jun 5, 2015
    Posts:
    122
    Plugins:
    1
    Minecraft User:
    TonyDroidd

    Attached Files:

  19. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    That doesn't work here.
Thread Status:
Not open for further replies.

Share This Page

Advertisement