SkriptLang / Skript

Skript is a Spigot plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them.
https://docs.skriptlang.org
GNU General Public License v3.0
1.07k stars 369 forks source link

Sections in effect commands #6156

Open CerialPvP opened 1 year ago

CerialPvP commented 1 year ago

Suggestion

Basically, make sections become available in effect commands. An example for this is the Python live interpreter, where if you type something like:

for i in range(10):

it allows you to enter more code in there, for example:

for i in range(10):
..print(i)

I suggest the same thing to be available within effect commands, if you enter for example:

!loop 10 times:

it will allow you to continue the code, like this:

!loop 10 times:
!..broadcast loop-number

Obviously, only sections are allowed, you shouldn't be able to make an event or command using that.

To end a section, just put a ; with the effect command prefix. This is a FizzBuzz example in Skript, which includes what I said.

!loop 100 times:
!..if:
!....mod(loop-value, 3) = 0
!....mod(loop-value, 5) = 0
!..then:
!....broadcast "FizzBuzz"
!..else if mod(loop-value, 3) = 0:
!....broadcast "Fizz"
!..else if mod(loop-value, 5) = 0:
!....broadcast "Buzz"
!..else:
!....broadcast loop-value
!;

As you can tell, this is a generic FizzBuzz, but in Skript. You can also see you indent using periods, one indentation is .., two is ...., ect.

Why?

Currently, the only way to test code which requires a section is to make a test skript, which can be tedious. This suggestion will help people like me and anyone else which is interested to test code.

Other

No response

Agreement

Fusezion commented 1 year ago

There's a pr along the lines of adding inline loops #5244, however due to it being a draft I'm very unsure how long it would take for it to actually release anymore.

I'm not super in favor of how the example looks as it's basically a file without the file

CerialPvP commented 1 year ago

There's a pr along the lines of adding inline loops #5244, however due to it being a draft I'm very unsure how long it would take for it to actually release anymore.

I'm not super in favor of how the example looks as it's basically a file without the file

Well again, it can be improved to Skript standards, but it was my suggestion. The inline PR looks better than mine but it doesn't allow for multiple effects in one line, which is also what I would hope would get added.

sovdeeth commented 1 year ago

Personally I think the process of writing a section out in effect commands would be far more tedious than a test skript. That said, it's still a valid suggestion!

CerialPvP commented 1 year ago

Personally I think the process of writing a section out in effect commands would be far more tedious than a test skript. That said, it's still a valid suggestion!

Agree, but it doesn't have to be loops, it can be any section like the spawn section.

CerialPvP commented 1 year ago

bump

sovdeeth commented 1 year ago

bump

Please don't add useless comments to issues. This is not a forum, "bumping" has no effect on whether your suggestion will be implemented. If you want it to be added more quickly, consider contributing it to the project yourself!

Pikachu920 commented 1 year ago

using a book UI could be an option. i'd agree with sovde that chat would be too tedious to warrant the feature

Moderocky commented 7 months ago

I don't think encouraging over-reliance on effect commands like this is healthy. They're not very safe to begin with, being completely untethered code, but this is even worse because you will end up with floating loops taking up space in the background silently that belong to nothing with no clear way to identify them or get rid of them.