simon816 / Command-Block-Assembly

Compile high-level code into Minecraft commands
https://www.simon816.com/minecraft/assembler
MIT License
271 stars 29 forks source link

Couple of missing features, 1.16 integration, and wiki pages #25

Closed hexadecimal-chocolate closed 3 years ago

hexadecimal-chocolate commented 3 years ago

Some QOL features:

if (exists) { // If true }



- Basic `boolean` keywords like `true` and `false` don't exist
- A `null` or `nullptr` keyword for comparing `Entity`s to check if they exist
- More ways to filter entity by `nbt`, name, position, scores, and teams
- Support for 1.16 `execute in` and maybe a keyword as well
- `as` keyword for `execute as`
- Overworld, Nether, and End variables defined in `Game`, builtins, or somewhere else
- A way to get a world by namespace id. eg. `minecraft:end`

I looked in the ir wiki page and I could not find any definition for `forceload`. You have other commands, but not forceload.

Wiki pages:

- Add `intrinsic_extension` to the CBL syntax page
- Add `const` to the CBL syntax page
- Add a page for using the builtin types like `World`, `Entity`, and `NBT`

I also noticed that
https://github.com/simon816/Command-Block-Assembly/blob/b54c2afee3ea7bdfddfe619b9b207ce30d160e45/examples/carpet_on_stairs.c#L89
`PikcupDelay` is a typo.

I could be missing something, but using `sender` gives me an error saying that it doesn't exist.
hexadecimal-chocolate commented 3 years ago

Oh, and error messages show 0:0 as the coords every time, macros in other files don't list them as such, and Failed to find funtion overload of is a typo.

Also, I cannot seem to pass custom types in constexpr functions. StrVec2 compiles fine, but calling the function doesn't.


Failed to find funtion overload of StrVec2::constructor
Unable to satisfy arguments types: (StrVec2)
Tried candidates:
  StrVec2::constructor(StrVec2 &this, string a, string c)
  StrVec2::constructor(StrVec2 &this, StrVec2 other)
hexadecimal-chocolate commented 3 years ago

Just realized that I can make a pr whoops

simon816 commented 3 years ago

Thanks for the suggestions :) I agree with most of these, I didn't want to introduce a null value, I created Maybe<T> to represent a value that may or may not exist. intrinsic_extension is really just for internal usage (I hope that most things can be replaced with ir statements eventually).

Definitely need to improve error messages and reporting. Most errors are to guide me to iron out bugs in the compiler, rather than to point out errors in input code.

Regarding your StrVec2, it sounds like you've added overloaded constructors, which means the implicit "default constructor" is not created (consistent with C++: https://en.cppreference.com/w/cpp/language/default_constructor) see: https://github.com/simon816/Command-Block-Assembly/blob/b54c2afee3ea7bdfddfe619b9b207ce30d160e45/cbl/cbl_type.py#L219-L222

You'll either need to create a default constructor, or ensure StrVec2 is not default-constructed. examples of where default construction can occur are:

void main() {
    StrVec2 foo; // default constructor
}
type MyType {
    StrVec2 foo;
    // implicitly defined default constructor for MyType calls the default constructor for type StrVec2
}

PRs are welcome, apologies that the code isn't well documented!

hexadecimal-chocolate commented 3 years ago

Sorry for the late reply. I really enjoyed looking through the code to add a couple of things. I was able to do forceload (kind of) as an ir instruction. I think that with a little tweaking, this could be a very good tool. It already is. I think that CBL and c/asm need a little work by adding commands, but the ir just needs a couple of instructions like forceload.