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

Solved Set sign text

Comments in 'Plugin Development' started by FlamingGenius, Oct 13, 2015.

  1. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Where is the function to set sign text? I thought it was in \pocketmine\tile\sign?
    And also an example on how to use would be nice :)

    EDIT:nvm i found it not exactly sure how to use it though
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    I will be nice :)
    search before creating threads! i already posted about this -_-
    But Ok :
    PHP:
    $tile $this->getServer()->getLevelByName("world")->getTile(new Vector3($x,$y$z));//gets the position
    if($sg1tile instanceof Sign){//prevent from crash if the current position isn't a sign
    $tile->setText("Text Line 1""Text Line 2""Text Line 3""Text Line 4");
    }
  3. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    This is what im using :)
    PHP:
     public function lottoGame(PlayerInteractEvent $event){
      
    $block $event->getPlayer()->getLevel()->getTile($event->getBlock());
      if(
    $block instanceof Sign){
       
    $signtext $block->getText();
       if(
    $signtext[0] === "[Lottery]"){
        
    $block->setText(
         
    "§6[Lottery]",
         
    "§bTap to play"
        
    );
       }
  4. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Oh so you want text replacing when the first line is [Lottery] ?
  5. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Its just for good measure lol the goal is when someone creates a sign and the first line is
    [Lottery] the text will be replaced with a colored [Lottery] txt and will become an actual game sign in which when clicked will run a command(the lottery command)
  6. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Sorry, Can't post because i am not sure of something ;)
  7. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Not sure whatcha mean but ok
  8. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    More effecient
    PHP:
    public function onSignCreate(SignChangeEvent $event){
    if(
    $event->getLine(0) === 'lottery'){ // check does player is creating lottery sign
        
    if($player->hasPermission('some.perm')){//  check perm.
                // Format sign
                  
    $event->setLine(0'[LotterY]');
                  
    $event->setLine(1'Tap to play');
                  
    $event->setLine(2'');
                  
    $event->setLine(3'');
               
    // Save sign
                 
    $this->signs[$event->getBlock()->getPosition()] // Blah blah, or whatever you do it.
              // Inform player about the action he did
                
    $event->getPlayer()->sendMessage('[LotterY] Sign created');
        }
    }
    }
  9. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    when clicked will run a command(the lottery command)
  10. CavinMiana
    Offline

    CavinMiana Active Member

    Joined:
    Aug 26, 2015
    Posts:
    101
    Minecraft User:
    CavinMiana
    I bet you got warning for doing that lol :p because when I put my words in Bold. I got a warning point
  11. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    What was the point of this?

Share This Page

Advertisement