1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Set Text on a Sign/SignPost

Discussion in 'Facepalm' started by UncOG, Aug 5, 2017.

  1. UncOG

    UncOG Shog Chips

    Messages:
    0
    Hello,

    I am working on a plugin called DeathMarker and currently at the location of your death will place a sign and a red poppy flower.

    I am struggling to figure out how to write on the sign RIP $name. Ideally RIP on Text2 and $name on Text3.

    I have not yet figured out the differences in using blocks and tiles but have fumbled my way through trying combinations of both.

    I've looked at the Neon code but that uses the PlayerInteractEvent to update the sign color. In my case the player will be gone.

    The SignPost that I am adding is done by this:
    $player->getLevel()->setBlock($lastdeath[$name],Block::get(Block::SIGN_POST),false,false);

    How do I get that tile to use setText? When I have tried getTile I am told setText is undefined for Air.

    Thank you,
    UncOG
     
  2. PsyOps

    PsyOps Silverfish

    Messages:
    16
    This is a very aggressive forum from what I have seen so far. I asked the same question and never got response. I am afraid of getting the "LEARN PHP" or "check the docs" or whatever else. This isn't a noob friendly place.
    The pocketmine code snippets are so scattered its kind of hard to find stuff anywhere on the net. ( at least for me anyway ). I don't know how good this code is but It seems to work for what I need it to. Try looking at line 253-269. It is what i wrote to clone a sign from one spot and paste it into new spot. line 269 is what actually puts the text on the sign.
    - hope it helps
     
  3. UncOG

    UncOG Shog Chips

    Messages:
    0
    PsyOps,

    I agree with you 100%! Before making an account I looked on this forum a lot and actually commented to a buddy on all the "LEARN PHP" responses! I have come across your posts as well and found you to be one of the few helpful, I appreciate you reaching out. The code snippets are hard to find for me as well. I have been reading the source code of pocketmine a lot instead of googling, takes up time but proving useful.

    Which code are you referring to for cloning the sign?

    While I have you here, do you know how to add an Object (like Grass, Stone and Torches) to the inventory? I can only see adding Items.

    Thank you for your reply! I will keep you updated on anything that I come across.
     
  4. PsyOps

    PsyOps Silverfish

    Messages:
    16
    No sorry. To give you an idea of my nubness, I just started playing minecraft PE a few months ago and that was my first experience with minecraft ever. I do hobby stuff with java and c# mainly, but after playing MCPE I thought that making plugins was kinda cool. So i found myself here. I will look through the code as well see what I can find.

    The clone code I have updated now does transfer chest stuff. I don't know if that would help you out maybe.
     
  5. UncOG

    UncOG Shog Chips

    Messages:
    0
    I just got into minecraft recently as well, I play with my nephew. I've written software professionally since out of college but its mostly embedded industrial with its own languages. I've fooled around with most languages, enough to get my feet wet and be slightly dangerous.

    I will check out the clone code for the chest inventory stuff. I really enjoy the php aspect as the driving force behind this.
     
  6. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    Agreed. Best thing you can do is learn yourself or ask friends
     
  7. PsyOps

    PsyOps Silverfish

    Messages:
    16
    Its just frustrating that this is probably the biggest pocketmine community on the interwebz and its all about elitism. "We are pocketmine plugin developing GODS and you must discuss development at our level or be cast off to the kiddie table (Facepalm section)".

    This section is for the new developers and I am amazed how ppl get treated here as well. ...

    Sorry. I hijacked the thread. I'll stop now.
    UncCog if you still are devving and have questions for me just respond to this thread or pm me. Ill look for the lil red icon hehe.

    I will take option"B" Levi. Ill just get frustrated and quit. Maybe I am too old and bitter :)
     
  8. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    You're looking at this form the wrong perspective, the staff is just trying to keep the normal Development section clean from synthax errors, too simple and duplicated questions so that it can be used as a proper future reference for future plugin devs.
    If you look at the posts in the facepalm section you probably won't find anything usefull to you at all, mostly synthax errors, outdated code or false used functions.
    The section is there so these kind of posts don't overtake everything and don't have to be deleted.

    Example please?
     
  9. PsyOps

    PsyOps Silverfish

    Messages:
    16
    Keep in mind "Facepalm" is the noob of the noob forums. So bad english and novice programming skills are expected.

    I know it gets frustrating repeating yourself. But it can make a big difference. So how about one swallows his frustration and maybe replies...
    " You know a good way to find out how pocketmine works is by looking at the source code. It is located on the server at (directory) or if you want the github (link) blah blah.

    Now I am not saying everyone is mean ALL the time. I am just giving my opinion (a novice programmer, new to minecraft, and new to forum). It is an overall feeling I get from this place. I only went through maybe 10 threads. I am sure I can find much more. But I have moved on. Maybe I will pick up pocketmine later.
     
  10. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Yes, I do agree that the overall attitude isn't very noobfriendly. But as you quoted my post, I might as well explain my message. If you looked at that thread, you would be able to see that every single line of the code he made contained at least one syntax error. I cleaned his code of it, but have let him know this really isn't the place to post these things. Okay, fine, I could have been a bit nicer, but these things don't belong on the PocketMine forums. They're general PHP knowledge and simply don't have to do with PocketMine, but simple PHP syntax. When we have to help with that, we (at least I) get quite a bit annoyed because of the low level of effort put into it. Creating a good thread with sufficient description and good attitude also helps getting better answers.

    Now, this post wouldn't have ended in the Facepalm section if this wouldn't have gone so off-topic. I'm sure of that. Either way, back to topic. You started off well, by creating a sign block. Signs need additional data, and require a Tile to have text on them. This is done using NBT. In the source there's a perfect example of this. Let's take a look at this: https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/block/SignPost.php#L63-L72
    It shows the creation of the NBT of the sign tile. You could technically copy that and enter the 'RIP' text on whatever line you want in that NBT. In order to actually create the tile, you have to look at the end of the function: https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/block/SignPost.php#L92
    So after setting the block, which you did well, you create the NBT, then you create the tile with that NBT. Hope this helped you.
     
  11. PsyOps

    PsyOps Silverfish

    Messages:
    16
    Yeh that is all I am saying too. Unfortunately I think this forum is going to have to take the burden of teaching plugin development as well as general PHP.

    Perhaps the dev forum is too accessible. Maybe user roles and permissions (maybe some type of organic groups) need to be tweaked. I agree that mods could be spending more time helping nubs like me that ask retartded questions :), instead of having to sort out every thread and moving it if needbe. Make the dev forum viewable but not postable to nubs? dunno just a thought.
     
  12. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    I don't understand the point of this part of your message...

    Kinda weird how the person with the least dumb questions and descriptive posts complains the most...
     
  13. PsyOps

    PsyOps Silverfish

    Messages:
    16
    Really? Come on bud this is what I am talking about. I hold no ill will with anyone.
    I was asked to elaborate.

    But ok. not one more complaint from me.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.