sbrl / Minetest-WorldEditAdditions

Extra tools and commands to extend WorldEdit for Minetest
https://worldeditadditions.mooncarrot.space/
Mozilla Public License 2.0
16 stars 3 forks source link

//for ... do ...{}... #53

Closed VorTechnix closed 2 years ago

VorTechnix commented 3 years ago

Like //many except it will iterate through the arguments before do and insert them into the argument after do at the {}.

Example: //for 2 3 4 5 do //overlay air 6 default:grass_{}

sbrl commented 3 years ago

Perhaps to specify a range you have some special syntax. The question is what syntax to pick.

Maybe CSS-esque (though to clarify CSS doesn't support ranges in this sense)?

//for 2 to 5 //overlay air 6 default:grass_{}

Or perhaps like Git commits?

//for 2..5 //overlay air 6 default:grass_{}

I recommend to avoid confusion in the documentation picking only 1 of these shorthands to implement.

VorTechnix commented 3 years ago

I do like the .. idea however I'd also like to be able to do item lists such as //for red green blue do //multi //set wool:{} //shift y 1 and I'd rather not have to implement more than one parsing scheme. At least not at first.

sbrl commented 3 years ago

Ah, ok. Let's keep that out of scope for now - we can always come back to it later and improve iteratively.

I also thought I'd implement an improvement to //multi to allow deeper nesting of commands:

//multi //1 //2 //outset 50 {//many 5 //multi //fixlight //clearcut}

What do you think? To make it compatible with //for I intend to disallow empty braces, but perhaps $$ or something could be used in //for instead of {}?

VorTechnix commented 3 years ago

$$ would be fine or even %% like dos. (I just used {} cause it was the first thing I thought of)

sbrl commented 3 years ago

Oh, I like %%. Not a DOS user, but that would be more semantic, since $$ is the shortcut for the current shell's PID in Bash.

VorTechnix commented 3 years ago

%% it is then.

VorTechnix commented 3 years ago

I want to include command clustering in //for. What should I use instead of {}?

sbrl commented 3 years ago

What do you mean command clustering? If you mean execute multiple commands, wouldn't that already be possible using //multi?

//for 2..5 do multi //overlay air 6 default:grass_%% //fixlight
VorTechnix commented 2 years ago

I think this feature can be considered done for now.