Code Monkey home page Code Monkey logo

Comments (13)

acs avatar acs commented on May 28, 2024

After read http://pluginbase.pocoo.org/ it seems that we need:

«Setuptools based plugins are very useful to extend libraries from other libraries.»

The way to go:

https://packaging.python.org/guides/creating-and-discovering-plugins/

The first approach must be the simplest one: "Using naming convention".

The goal is to discover the plugins installed, the ones called mcthings_, load them and make visible its things to be used (mcthings will be extended with the new things).

So mcthings will be extended in the app used by the system with the plugins installed. The plugin will reuse the mcthings framework and extend it with new things.

from mcthings.

acs avatar acs commented on May 28, 2024

Let's create a new package mcthings-drawings that it will add a new Thing called Sphere implemented using https://minecraft-stuff.readthedocs.io/en/latest/minecraftdrawing.html#minecraftstuff.MinecraftDrawing.drawSphere

If everything goes ok, we will add several new Things created using MinecraftDrawing. With it, we can create richer scenes!

from mcthings.

acs avatar acs commented on May 28, 2024

https://github.com/martinohanlon/minecraft-stuff/blob/master/LICENSE is MIT so great to reuse it!

from mcthings.

acs avatar acs commented on May 28, 2024

There are samples which you can use it as reference as https://pypi.org/project/flask-talisman/ With this plugin, when you are using Flask, it protects you against some attacks:

from flask import Flask
from flask_talisman import Talisman

app = Flask(__name__)
Talisman(app)

So the plugin changes the Flask behaviour, extending it. In our case, the code must be something like:

from mcthings.scene import Scene
from mcthings_drawing import Sphere

def main():
    try:
        mc = mcpi.minecraft.Minecraft.create(address=MC_SEVER_HOST, port=MC_SEVER_PORT)
        Scene.server = mc

        mc.postToChat("Building a scene with several things")
        pos = mc.entity.getTilePos(mc.getPlayerEntityId(BUILDER_NAME))
        pos.x += 1

        sphere = Spehre(pos)
        sphere.build()

from mcthings.

acs avatar acs commented on May 28, 2024

We have it: https://pypi.org/project/mcthings-drawing/0.0.1/

I am going to try to use all in a notebook!

from mcthings.

acs avatar acs commented on May 28, 2024

All have worked from a notebook as expected:

Screenshot from 2020-04-19 23-59-20

from mcthings.

acs avatar acs commented on May 28, 2024

And also the persistence works! We can load the scene from a file:

Screenshot from 2020-04-20 00-04-05

from mcthings.

acs avatar acs commented on May 28, 2024

The plan is to have another repository called mcthings_extra in which includes Things from the samples in:

https://github.com/arpruss/raspberryjammod-minetest/tree/master/raspberryjammod/mcpipy

We need to debug all of them, because for example, the castle.py example needs some fixes to work. And it does all block by block, which is pretty slow. But the result is great!

Screenshot from 2020-04-20 00-31-07

from mcthings.

acs avatar acs commented on May 28, 2024

Mostly done, I will close it once the mcthings-extra repo with some example is created.

from mcthings.

acs avatar acs commented on May 28, 2024

Probably the best thing is to merge mcthings_drawing in mcthings_extra, in order to have just one repo for third party Things! But it is a nice sample on howto create a library to extend McThings. So not sure yet. Let's think about it.

from mcthings.

acs avatar acs commented on May 28, 2024

Extra Things repository working!

Screenshot from 2020-04-20 23-57-21

from mcthings.

acs avatar acs commented on May 28, 2024

So in order to extend McThings there are two repository samples doing it. And using the extra things is as easy as included both libraries. So time to close this ticket!

from mcthings.

acs avatar acs commented on May 28, 2024

McThings Drawing has been included in McThings and removed the repository. So we have two repositories now, the core and the extras.

from mcthings.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.