Jump to content

[1.8] Registering commands good practices


DJD

Recommended Posts

If I have a lot of commands (some with variable parameters), what is the most efficient way of registering them ?

 

In other words, say I've got a base command Do (its dumb but its simple like me :D). It can have variable parameters associated with it such as:

 

Do

Do Something

Do Something ToSomethingElse

Do Help

 

Or in other words, is there I way I can register just the single "Do" command and pass it parameters for which "Do" to "do" ?

 

What is the best way to implement this ?

 

I don't keep an open mind lest someone try to fill it with garbage - Mark Twain

Link to comment
Share on other sites

Thank you !

 

That helps a lot knowing I can encapsulate my commands for my mod with one register.

 

Or should I break each command out seperately ?

 

e.g I say i've got a Do command and a Go command. Register them seperately or as one "mega command" (e.g. say "mod"

and handle the Do and Go commands in there ?)

I don't keep an open mind lest someone try to fill it with garbage - Mark Twain

Link to comment
Share on other sites

So if I have say 40 commands I should register each one individually ? Seems kind of archaic.....

 

Each command does only one thing.

 

My thinking is I have a base command (telling to use my mod) followed by a space followed by the command and any parameters I can create a centralized command handling system that won't mung up anyone else's mod commands....

 

mod Do something

mod Do something toSomething

mod Help

 

etc...

 

I register mod (or whatever I will call it) as a single command but handle the 1st parameter as the command and anything else entered as a parameter.  Is this a bad thing (e.g. will the engine balk at this) or am I overthinking this whole thing ?

I don't keep an open mind lest someone try to fill it with garbage - Mark Twain

Link to comment
Share on other sites

I guess its also a question of if when you register a command with MC,

 

A) does it have to re-instantiate itself whenever a command is executed or

B) does it reside out there when registered to be waiting to be used until MC shuts down.

 

If A then a bunch a smaller footprint (individual commands) would be better

 

If B then a central command handler seems would be fine (and it simplifies error trapping, messaging etc etc).....

 

I don't keep an open mind lest someone try to fill it with garbage - Mark Twain

Link to comment
Share on other sites

Think Diablo 3 and how it handles its "randomness".  it only has a few sections it uses over and over again with a few things changed to create a sense randomness.

 

I've got the design for storage handling, buffering etc down, so without getting into more boring details, my thoughts are like this:

 

The mod allows the generation of geomorphic sections with variations amongst the internal elements of each geomorph (e.g. a length of corridor with mostly cobblestone but sometimes will generate with a cracked cobblestone or whatever)....

 

To do so requires 3 types of files:

Structures: which blocks go where),

Themes: groups of blocks with similar properties (e.g. cobblestone dungeon)

Plans: The "how to" place the geomorphs so that they make sense (corridors things connect etc) and the randomness of it all.

 

These files are editable by hand, but some of the things that would be better to do inside Minecraft to ease the design burden.

(such as grab a section of blocks and save to a buffer for later output)....

 

A buffered structure (there can be more than one) can be "placed" and individual blocks "modified" and saved to the buffer. Which of course can be saved off (and hand edited later if desired instead of clunking around typing commands when one sees what needs to be done).

 

So there will be commands for:

Getting/Setting structures

Getting/Setting plans

Managing the buffer a little (e.g. structures and plans currently loaded) without having to save the whole thing, edit it in a text file and bring it back in.

 

All of this is done in creative mode.

 

For generation and actually playing, the Plans files are used to generate random geomorphic things (can be dungeon, town or whatever).

 

So... maybe that wasn't so short after all :D

 

It would be nice to handle the commands centrally (e.g. for error trapping and messaging purposes (e.g. output to player's chat)) rather than have a bunch of commands that each have to have their own error handling/messaging/IO etc.....

I don't keep an open mind lest someone try to fill it with garbage - Mark Twain

Link to comment
Share on other sites

I'll probably go with the central idea first, because the way this thing has been created it would be easier to split it up later than try to put it all in one. Would be a good test anyway :D

I don't keep an open mind lest someone try to fill it with garbage - Mark Twain

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.