Jump to content

Command system?


Longor

Recommended Posts

Heya! If you are asking from a minecraft-style-command-system standpoint:

There's currently no commands available that would let you interact (setblock/testfor/etc styled) with the world and there's no command block. What we do have is:

  • A lot of commands to help you administer the server and player privileges as well as commands useful during development
  • A macro manager on the Client that let's you execute several commands at once using a keyboard shortcut. So you can e.g. map /time set day to CTRL+D - The idea is borrowed from World of Warcrafts Macro System, thats kind of the direction i want to go with this - as ways to automate your character (/equip, /say, /spell, /use, etc.)
  • Server mods can freely register new commands and handle their response

I'm also undecided if a minecraft-style command system is something I should implement - the whole idea of it feels like an excuse for not having a mod api which Vintagestory has however. Conceptually it is also kinda ambiguous. I would rather go for either fully programmable blocks through Lua code or have let such commands be the actual blocks (teleport block, testfor block, setblock block, etc.). 

Link to comment
Share on other sites

Well if that is the case, I would like to recommend something:

Use a custom LISP dialect for commands; that gives you a ton of power, versatility and possibilities, while still keeping the commands simple which is, in my personal opinion, the best thing about commands: You don't need to learn a entire scripting language for them, only bits and pieces and a brutally simple syntax.

Using something like a custom LISP dialect here makes things more streamlined, so the parsing of commands is never really ambiguous. This in turn can make auto-completion simpler, since you have a unified form of how commands are structured. Also, the syntax of LISP actually looks like the command syntax you can find everywhere, so there's no need to change your habits.

A simple dialect could be (here as EBNF):

command ::= EXPRESSION

EXPRESSION ::= OPERATOR (WORD | STRING | NUMBER | JSON | ENTITYSELECTOR | BLOCKSELECTOR | SUBEXPRESSION)

OPERATOR   ::= WORD
WORD       ::= ?Any sequence of characters, terminated by whitespace?
STRING     ::= '"' (?Sequence of characters without '"'?) '"'
NUMBER     ::= ?Insert Grammar for Numbers here?
JSON       ::= ?Insert Grammar for JSON Object here?

ENTITYSELECTOR ::= '@' SUBEXPRESSION
BLOCKSELECTOR  ::= '#' POSCOMP POSCOMP POSCOMP
POSCOMP        ::= (SUBEXPRESSION | ['~'] NUMBER)
SUBEXPRESSION  ::= '(' EXPRESSION ')'

I just wrote that grammar up, so don't throw that blindly into a parser generator!

Oh and before I forget: Vintage Story looks darn beautiful for being in the alpha stage

Link to comment
Share on other sites

Oh wow, haven't seen an EBNF for a few years now :D

If we go that far, wouldn't it make sense to just go all the way and use lua/c# expressions as commands? i.e. /command SetBlock("water", GetPlayerPosition(FindNearestPlayer()));
Thats more powerful, still pretty simple syntax and perhaps even less effort than implementing a custom parser.

 

14 minutes ago, Longor said:

Oh and before I forget: Vintage Story looks darn beautiful for being in the alpha stage

The magic of shaders and consistency ^_^ Thanks!

Link to comment
Share on other sites

Well... lets compare the command you provided:

SetBlock("water", GetPlayerPosition(FindNearestPlayer()));

With a LISP-style variant (entity selector syntax just invented):

setblock @(type: "player", count: 1) "water"

Which one is simpler, and which one is faster to type, taking into account that you would have basic understandings of both variants?

Link to comment
Share on other sites

To be quite honest, the C# variant is simpler to read and understand. It immediately gives you an understanding what it does. With your lisp syntax command its not immediately clear what it does. I can also make the C# variant faster to type at the cost of intuitivness: setBlock("water", PlrPos(NearestPlr()))

I don't really see the gain of a LISP Syntax here :(

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.