Reference external files inside of scripts

Want to request or discuss ModTweaker features? Post it here!

Reference external files inside of scripts

Postby BookerTheGeek » Tue Aug 04, 2015 4:40 am

Hello good sirs and madams. I have an interesting thought. But first, a little background

With the plethora of Thaumcraft mods, their comes a time when it becomes necessary to do a little cleanup of the thaumcraft research tabs. Removing recipes and pages, re-adding recipes and all the new pages. More importantly, add descriptions that make sense to all those re-added recipes.

Now here is where we com into an issue, file size and the amount of text inside the scripts for the localization of researches. I propose a solution to this. The ability to refrence a text file from, wait for it... inside the script!

Yes, you heard me right! Pull the text for the localization from an external location of the script itself, and insert it during the loading of the scripts into the script itself!

"What do you mean?" you might be asking. Well, let me show you my idea!


Inside of the scripts for Thaumcraft we have this little tidbit.
: [Select all] [/] [] ()
game.setLocalization("en_US", "tc.research_page.TCWAND_wood1", "Insert description Here");
GeSHi © Codebox Plus

The sad part is that the description can span multiple pages, and when you start having one script for each page... You can see where this is going. THOUSANDS of lines of code. This leads to very easily making mistakes and/or just plain missing things.

My solution:
: [Select all] [/] [] ()
game.setLocalization("en_US", "tc.research_page.TCWAND_wood1", "TCWAND_wood1.txt");
GeSHi © Codebox Plus

Where the file that is named "TCWAND_wood1.txt" would contain the actual description that is going there.

An example you say? Ok, but only a short one.
: [Select all] [/] [] ()
game.setLocalization("en_US", "tc.research_page.TCWAND_wood1", "TCWAND_wood1.txt");
GeSHi © Codebox Plus

with the "TCWAND_wood1.txt" containing:
: [Select all] [/] [] ()
Here is the description. As short or as long as you like
[b]Maybe it could support formatting [/b]
GeSHi © Codebox Plus

Would function the same as:
: [Select all] [/] [] ()
game.setLocalization("en_US", "tc.research_page.TCWAND_wood1", "Here is the description. As short or as long as you like, [b]Maybe it could support formatting [/b]");
GeSHi © Codebox Plus



So... :D

Cross posted to https://github.com/jaredlll08/ModTweaker2/issues/218
BookerTheGeek
 
Posts: 1
Joined: Tue Aug 04, 2015 3:43 am

Return to ModTweaker Feature Discussions

Who is online

Users browsing this forum: No registered users and 1 guest

cron