Coder Social home page Coder Social logo

Proper documentation would be nice. about mcipc HOT 14 CLOSED

conqp avatar conqp commented on August 16, 2024
Proper documentation would be nice.

from mcipc.

Comments (14)

conqp avatar conqp commented on August 16, 2024 1

I guess you need to support lists? If not then you can type hint for a 3 element Tuple only.

That's actually a good idea. I'll keep the list support regarding the conversion to str, but will adjust the type hints to Tuple[int, int, int] only.

from mcipc.

conqp avatar conqp commented on August 16, 2024

I just won't comment.

Well, you just did.

As there isn't even documentation at all

So what would you call the content of the README.md?

I am not saying that the current documentation isn't poor. But this is free software that I developed in my free time and give to you for free. If I find the time, I'll write some documentation on https://readthedocs.org/.

from mcipc.

conqp avatar conqp commented on August 16, 2024

Documentation is currently being developed on readthedocs.
You're welcome to contribute.

from mcipc.

gilesknap avatar gilesknap commented on August 16, 2024

@conqp this library is just what I've been looking for - it is great for educating kids on python since you have typed everything and IDE auto completion becomes very handy in exploring the possibilities.

Re documentation: I have as yet been unable to work out how to use data and execute from reading the code. Could you provide a couple of hints? I would contribute to your documentation on this subject if I could get it working.

Thanks.

from mcipc.

gilesknap avatar gilesknap commented on August 16, 2024

got data working
data = client.data.get(TargetType.ENTITY, "@p", "Pos")

(unfortunately the type hints can't autocomplete this)

from mcipc.

conqp avatar conqp commented on August 16, 2024

Thank you for the positive feedback.
The new methods introduced with mcipc-2.0 are a bit complex.
In general, I tried to preserve the structure from the official commands.
In cases where there is a signature like

command subcommand <value> [optional]

You'll need to run

client.command.subcommand(value, optional=optional)

A list of commands is available in the official Minecraft Wiki.

The execute command is a bit special in the way, that it is self-recursive. I.e. you can chain execute commands.
So if you're done, you either invoke run(command, *args) to execute another Minecraft command with the set environment or just run the chained command by calling it with ().

E.g. for the command /execute align xz you'll run client.execute.align('xz')().

from mcipc.

gilesknap avatar gilesknap commented on August 16, 2024

Thanks, that is a helpful explanation. I've been having fun with this API today. When I have some nice working examples I could add them to your docs if you think that is useful.

By the way, I find I'm doing lots of vector math and that the built in Vec3 Tuple does not make this easy. Am I missing something? At present I keep converting back and forth to another type to do transformations etc.

from mcipc.

conqp avatar conqp commented on August 16, 2024

I'd appreciate any use case examples.
In all cases where the mcipc.rcon.types.Vec3 is expected within the RCON API, you can also use tuple or list objects of length 3 or any subclasses thereof: https://github.com/conqp/mcipc/blob/master/mcipc/rcon/functions.py#L72
You can also use instances of str like "x y z", but this won't be useful for vector operations, I think.
In any case, the type hints I provided are no more than that: hints.
You can also always provide any other types that can be converted using str(value) in a way so that the signature of the original Minecraft command is met.

from mcipc.

gilesknap avatar gilesknap commented on August 16, 2024

OK, again thanks. I've changed my vector math class to be a Named Tuple of 3 int and it works. BUT it grates on me because pylance (linter) complains I'm passing an incompatible type :-)

e.g.
image

from mcipc.

conqp avatar conqp commented on August 16, 2024

I'll consider adjusting the type annotation to Union[tuple, list] then. However, the original idea was to remind the user to pass in a tuple (or list) with length 3.
What type is vector anyway? If it's a list or tuple like iterable, you can just convert it using Vec3(*start).

from mcipc.

gilesknap avatar gilesknap commented on August 16, 2024

I guess you need to support lists? If not then you can type hint for a 3 element Tuple only.

from mcipc.

conqp avatar conqp commented on August 16, 2024

Implemented in e9f663c.

from mcipc.

gilesknap avatar gilesknap commented on August 16, 2024

I see that you ended up hinting Vec3 as Union[Tuple[IntOrStr, IntOrStr, IntOrStr], str], allowing for coordinates of the form '~123'

I have also found myself using float coordinates, for example for exact positioning in the teleport command.

Is there merit in changing IntOrStr to NumOrStr = IntOrStr = Union[float, int, str] ?

EDIT: this does mean that Vec3 then needs to support floats and becomes a little complicated .

( I also see that Vec3 now has the functionality I needed anyway so I can use your class directly )

from mcipc.

conqp avatar conqp commented on August 16, 2024

I allowed floats for Vec2 and Vec3 in adcd02c.

from mcipc.

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.