OpenNBS / OpenNoteBlockStudio

An open-source Minecraft music maker.
https://noteblock.studio
MIT License
757 stars 50 forks source link

More generic datapack export #90

Open Marcono1234 opened 5 years ago

Marcono1234 commented 5 years ago

Is your feature request related to a problem? Please describe. The current datapack export covers a specific use case, however the created commands are not easily customizable by the player and do not allow adding additional functionality, e.g. visuals.

A popular variant of note block songs is using "wireless note blocks": Placing the noteblocks at predefined spots to play the sounds (mostly for visuals). Previously this was done by exporting the schematic and applying an MCEdit filter. However, the filters are no longer updated and MCEdit is also not supporting the latest Minecraft versions. Additionally it should be possible to perform this in one step. Though this is only one use case, I can imagine there being others as well, for example players who want to show the respective note particles (or similar) while playing a song.

The goal is however not to replace / remove the currently existing datapack export, because it will have better performance than anything else.

Describe the enhancement you'd like I am not quite sure what the best / most performant way to solve this would be. Neither do I know if such a feature would really be that useful. So if you don't mind, I would use this issue as place for a discussion about this.

Most of the current datapack export code can be reused for this. Instead of executing /playsound commands, scores representing the layer (to support multiple layers with the same instrument), the pitch, the stereo values and the volume could be set and then functions (which the user defines after the export) representing the instruments are executed. For example if layer 1 plays a harp note: Instead of directly calling /playsound, the scores would be set layer=1 pitch=... And then /function my_song:instrument/harp would be executed.

By default the instrument functions would be empty. The user can then edit them to behave as they desire, e.g. place a note block at a specific location, use /playsound and show particles, ...

The performance will be worse than directly running /playsound and since you currently cannot use scoreboard scores within commands dynamically using the pitch or stereo score is not possible. However, it will make it easier for the user to customize the behavior.

Let me know what you think about this, if you have change suggestions and also if you don't think this feature is needed.

Bentroen commented 5 years ago

I've been thinking about the same thing for a while now. The datapack export feature in its current form, despite very useful, is also quite limited, since it offers no wiggle room for customization. The problem with adding more code to customize what it can do is that each new "rendition" we add (i.e. a visualizer, the "wireless note block" concept or any new export format besides the current one) will be, again, limited only to what it was coded to do. With that in mind, I've been thinking of ways to make something that could be used more generally, i.e. some sort of scripting language. This way the user could create their own scripts, iterating over the note blocks, layers or ticks in the song and running any particular command for each of those.

The problem that arises this time is, the engine we're using has very limited capabilities. The first version of the program was written in GameMaker 8, and since the update to GameMaker Studio, it was never properly ported. So the current code is a hack on top of a hack on top of a hack. That makes it very difficult to implement something this big, at least in a way that's straight-forward and maintainable. Due to how stuff is implemented in the background, adding a feature implies creating tons of scripts for dealing with every single detail. Simply setting something to a variable doesn't work properly; we have to add another script to deal with X and at the same time make sure it doesn't break Y, and so on. So even making something simple can become very complicated.

The most appropriate solution to this would be rewriting the program from scratch, using modern tools with fewer limitations. However, since no one currently in the team has the expertise to do that, we're limited to what GameMaker allows us to do. I'm sure we can pull off something cool though!

Marcono1234 commented 5 years ago

Adding a scripting language for this might be overkill. I was not clear enough about this, my idea is to call Minecraft functions when playing a note. These functions would be created by the user in a regular text editor (or any other applicable tool) after they exported the song as datapack. This would definitely make it possible to have "wireless note blocks" or visualization using particles.

However, I though about my initial idea again and I think I approached it the wrong way. Instead of creating a new export tool, the current one could be expanded.

So the new idea would be to have the following settings when exporting a song as datapack:

Section "/playsound"

Section "Customization function"


A user could then

export the datapack. Then add their own function (lets call it set_note_block) which places a note block with the respective note value depending on the nbs_customization_key score. And then write in the note_blocks:my_song/customization/any_instrument function commands to execute this set_note_block function, offset depending on the nbs_customization_layer score.

This would in the end create a "wireless note block" setup.


I know that by only describing the functionality, it is difficult to understand. I might try to create a prototype, though I don't have any experience with GameMaker Studio yet.

ShinkoNet commented 4 years ago

This seems very complicated.

I'm implementing visuals for the next update. I think the simplest thing to do (and the most customizable) is to just give an option for the user to type in their own Minecraft command string, with variable wildcards for each property of the song (like volume, pan, note, instrument).

I was able to create tons of different visualizers with the /summon fallingblock command, just altering the parameters depending on what variables are read.