NpcDialog Save

🗽 PocketMine-MP virion to add dialogs to entities easily

Project README

NpcDialog

Download

The compiled phar is available on poggit

How to use

First, you have to register the virion, you can do this during the onEnable() of your plugin main class.

public function onEnable(): void {
    NpcDialog::register($this);
}

Then you have to spawn or get the object of the entity you want to have the dialog form (it can't be a player!). For this example, I will spawn a zombie using PocketMine built-in methods.

$nbt = Entity::createBaseNBT($player, null, $player->yaw, $player->pitch);
$entity = Entity::createEntity("Zombie", $player->level, $nbt);
$entity->spawnToAll();

$entity->setNameTag("Jerry The Zombie!");

Finally you will have to create the form and pair it with the entity.

$form = new DialogForm("This is the dialog text");
 
$form->addButton(new Button("Hi", function(Player $player) {
    $player->sendMessage("Hi!!");
}));

$form->setCloseListener(function(Player $player) {
    $player->sendMessage("You closed the form!");
});

$form->pairWithEntity($entity);

The result of this example would be an entity showing this when it's right-clicked (or hold in the mobile versions):

Example

Open Source Agenda is not affiliated with "NpcDialog" Project. README Source: andresbytes/NpcDialog
Stars
1
Open Issues
0
Last Commit
3 years ago

Open Source Agenda Badge

Open Source Agenda Rating