How to make a config file!

Started by DerexXD on

Topic category: User side tutorials

Joined Jan 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make a config file!
Mon, 03/22/2021 - 01:16 (edited)

Yes! It's finally possible and here's a guide on how! This is a guide on how to make a CONFIG, not a guide on Goldorion's file plugin. I'm assuming you already know the basics the self explanatory blocks in the procedure (file tab) say. 

 

Now without further ado...

 

First get Goldorion's file creator plugin: (https://mcreator.net/forum/64639/file-creator-plugin?page=2%2C0) 

Or if you know java, it's just some simple write to file lines 

 

Next, you should start with the creation of a file variable block obviously as if you don't have it in a procedure the file object won't exist. When it asks for directory, here comes the cool part.

 

We're going to concatenate two strings. First, grab the "get the game directory" string block from the "File Manager" procedure tab. Next, grab any empty string block (you can find them in the "text" procedure tab). Then, get a "create text with" block from the "text" procedure tab and then first put in the "get game directory" block then add below it "\config". Be sure that you're creating the file (check the box).

 

Run the game. You should find that your config is in your mcreator workspace directory! (To get here, go to your mcreator project and the minecraft simulated environment is in the "run" folder)

Config file in the run directory

From here, you can input your own values and variables into the config (like if a mob spawns). That part is up to you to do.

 

 

Edited by DerexXD on Mon, 03/22/2021 - 01:16
Joined Jan 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
EDIT: USE BACKSLASH NOT…
Mon, 03/22/2021 - 01:16

EDIT: USE BACKSLASH NOT SLASH IM SO SORRY

Joined Aug 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Nice tutorial :D However,…
Mon, 03/22/2021 - 16:07

Nice tutorial :D However, instead to write the / yourself, you should use the File separator block, so it will be compatible with all OS.

You could extend your tutorial to explain the JSON blocks (if you understand how they work) because it seems some users don't know how to use it. I

Joined Jan 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
ah yes i just wanted to make…
Mon, 03/22/2021 - 20:46

ah yes i just wanted to make a quick one but good idea 

Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hey man, can you give me a…
Tue, 05/04/2021 - 07:23

Hey man, can you give me a specific example, I still don't understand

Pretty sorry because my English is bad, I'm not from America

Joined Jan 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Wdym it's pretty self…
Mon, 05/10/2021 - 02:18

Wdym it's pretty self explanatory. What do you not understand? 

Joined Jul 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Is there any way I can read…
Sun, 09/12/2021 - 02:45

Is there any way I can read the files? There doesn't seem to be a way to access the files without overwriting them

Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Soo yeah it creates the…
Wed, 09/15/2021 - 12:37

Soo yeah it creates the Config but like now what, I can't edit them since they keep being overwritten and I can't access them since its a Local Variable lol

You can solve that…
Wed, 12/08/2021 - 21:05

You can solve that overrideness by adding global variable being set on "global map" (so it won't reset each time game is loaded, for example), and make it "false" by default. If variable is false, then config will be made - and change to "true". Then, everytime config is "true", it will only load the config, not write it.

There's one huge disadvantage of it tho - if player manually deletes the config, new one won't write, and game will crash.
Solutions?
1. Write that on mod's page, maybe even link example file of config for people to download and add back to their config folder
2. If you update your config, make use of already written values - write special .json value called "config_version" and make it use specific number (for example "0"), then everytime you check the file, you should also check which version of the config user use.
It will require you to make whole system of "update procedures" (with each new version of config, more elements), but it should fix the issue without your mod needing any deletions of config file

Also it's worth mentioning…
Thu, 12/09/2021 - 00:21

Also it's worth mentioning that I achieved to make working config with global trigger being "when player joins the world". Feels like "when loading the world" doesn't work correctly, maybe not reading global variables fast enough for procedure to process correctly or so.

So with my trigger, config would load each time player joins the world, meaning config would be reread during longer sessions. Not complaining though, it allows some nice customisation during game itself, I guess. The only issue I can find (except for what I wrote before) is that spawn chunks can generate without taking care of custom gen settings in config file, if we have any (since world loads first, chunks spawn, and then it's player joining, so config is set after chunkspawn).

Okay, actually this is more…
Thu, 12/09/2021 - 18:07

Okay, actually this is more sophisticated than I assumed. I will do precise, troubleshooting tutorial soon, because indeed the file management is much worse than it could look at first. A lot of things that File Manager don't solve at the moment, overwriting especially.
Watch out for "[Tutorial] Configuration file with File Manager" topic I will write once I finish updating my mod ^^