Total Miner > Creative Features

[Scripts] Considering a new script syntax

(1/6) > >>

Craig:
The current script syntax is problematic, so I've been considering a new one.

There are 4 main problems with the current syntax:

1. Everything has to be surrounded by square brackets so the script interpreter can distinguish separate parameters.

2. Parameters have to be in a fixed order and in a lot of cases can't be omitted/defaulted.

3. To accommodate #2, I have to make several versions of the same command to help script writers not have to worry about parameters they're not interested in.

4. Parameters are mostly unnamed so it's harder for script writers to remember what each parameter is, and it makes the script interpreter code more complex.

I've considered various other syntax formats, and I think the most suitable one for our scripts is the standard command line syntax most operating system command shells use.

e.g.
> command [name] [/a[=attributes]] [/b] [/c]..

where /a, /b, /c are named parameters, usually followed by some value, but not always

e.g.

rain /point=x,y,z /radius=value /duration=value /intensity=value /color=r,g,b

parameter names can be shorted to the least significant characters, e.g:

rain /p=x,y,z /r=value /d=value /i=value /c=r,g,b

any non mandatory parameters can be easily omitted, e.g:

rain /p=x,y,z /r=value
or
rain /p=x,y,z /i=value

an example of params that don't need values:

sound brook /p=x,y,z /delete
sound brook /p=x,y,z /d
or
sound brook /p=x,y,z /loop
sound brook /p=x,y,z /l

the /delete and /loop params don't need values

Parameters can be entered for the command in any order, you won't have to remember the fixed order again. e.g.

rain /p=x,y,z /r=value /d=value /i=value /c=r,g,b
and
rain /d=value /c=r,g,b /p=x,y,z /i=value /r=value

are both (the same) valid commands.

The syntax might seem a little cryptic at first, but I think once you get used to it, you'll find it much easier to write and understand scripts, and you won't have to refer to the documentation so much.

Naturally if I was to do something like this, I'd convert existing scripts to the new syntax, so you wouldn't have to worry it'll break your scripts and you wouldn't have to write them again.

In general, because you won't need square brackets anymore and you'll be able to omit unused parameters, the number of characters you'll need to type to write scripts should be reduced, speeding up the process.

Thoughts?



Zone:
I never really had a problem with this, Would be nice to see a change in it for the new players.

Dryym:
Would this allow for the parameters to be in any order aswell?

What would you do in the event that 2 parameter names share the same first letter, Or is the chance that the two would end up in the same script so minute that you wouldn't need to worry?

Craig:

--- Quote from: Dryym on May 12, 2015, 08:13:02 PM ---Would this allow for the parameters to be in any order aswell?

--- End quote ---


--- Quote from: Craig on May 12, 2015, 09:00:18 AM ---Parameters can be entered for the command in any order, you won't have to remember the fixed order again. e.g.

rain /p=x,y,z /r=value /d=value /i=value /c=r,g,b
and
rain /d=value /c=r,g,b /p=x,y,z /i=value /r=value

are both (the same) valid commands.

--- End quote ---


--- Quote from: Dryym on May 12, 2015, 08:13:02 PM ---What would you do in the event that 2 parameter names share the same first letter, Or is the chance that the two would end up in the same script so minute that you wouldn't need to worry?

--- End quote ---


--- Quote from: Craig on May 12, 2015, 09:00:18 AM ---parameter names can be shorted to the least significant characters, e.g:

--- End quote ---
My example wasn't great because each parameter had a different first letter, but what least significant characters mean is if there are two or more parameters that start with the same letters, you just need to use enough to differentiate them

e.g.

command /point=x,y,z /player /power=5

least significant would be

command /poi=x,y,z /pl /pow=5

Dryym:

--- Quote from: Craig on May 12, 2015, 08:17:37 PM ---My example wasn't great because each parameter had a different first letter, but what least significant characters mean is if there are two or more parameters that start with the same letters, you just need to use enough to differentiate them

e.g.

command /point=x,y,z /player /power=5

least significant would be

command /poi=x,y,z /pl /pow=5

--- End quote ---

This makes a lot more sense, Thanks for clearing this up.

Navigation

[0] Message Index

[#] Next page

Go to full version
Powered by Advanced Topic Prefix Pro