Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
Create simple table (e.g. "OPTIONS"), where keys are option names (ids).
Then you have to notify Mod Options Mod about your options. To do this you need to call function ModOptions:getInstance().
Definition:
This minimal code should be in the folder media/lua/client, so your options will appear in options in main menu. If you put it in media/lua/server, it won't appear in main menu, and user can't set it before loading the game.
NB: This is for the client side only! It's ok for single player, but in multiplayer every player can change it. Be careful, if your options affect gameplay.
Let's call this "settings".
Remember that this is the syntactic sugar[en.wikipedia.org] only. You can use either the first way, or the second, or the third, but they are the same.
MOD SETTINGS = OPTIONS + OPTION PROPERTIES
More precisely, SETTINGS is a table that contains OPTIONS table and other properties such as names.
Link to the settings is just the result of ModOptions:getInstance(). Also, if you are using Way 2, variable SETTINGS is exacly what you want.
Then you can add names:
Note that if you are using Way 2, you can implement properties directly in SETTINGS because it's the same table.
Actually, names should be translated to all languages. And you can specify not names but IGUIs. Ofc there should be proper txt file in shared/Translate/EN.
To do this, call the function ModOptions:loadFile()
Check this path:
This is the file for all mods, so each mod has its own section.
Example:
What if your mod is server only? Client files won't be loaded on dedicated server. In this case you have to put your default options into media/lua/shared. It gives you the following advantages:
1) Server admin can tune mod options BEFORE loading coop game.
2) Options will be accessible in server lua files.
But you have to provide a link between your files (using a global variable e.g. a table).
In media/lua/shared/yourmod_options.lua:
In media/lua/server/:
Of course, we are talking about cleint options, not private admin host options.
Don't forget to add strings to the txt file in your mod.
Create the file IG_UI_EN.txt in media/lua/shared/Translate/EN :
Example from the mod Fair Traits Cost:
For settings in general you can use: OnApply, OnApplyMainMenu, OnApplyInGame:
For separate options you can use the same listeners. But it will be triggered only if the value is changed:
Also you can use onUpdate listener. It will be triggered when the user changed an option before Apply button. This is not the final value, because the user may leave the options without applying it ("back" button).
To make an option using this framework, you have to make a table with default key and its name:
Then you can use this data to tell framework that you want to make an option:
That's it!
Last thing that you should remember is to give a name to your option. It's in the txt file that you should create in your mod folder:
/media/lua/shared/Translate/EN/UI_EN.txt
Example mod: Fast Keys
NB: There are some unsolved issues. I don't recommend using it.
Okay, as usual, there are few ways to make your options as sanbox options. Let's take a look at Way 1:
Example code:
Use section name (sandbox_path) from this list:
- PopulationOptions
- TimeOptions
- WorldOptions
- NatureOptions
- SadisticAIDirector
- Meta
- LootRarity
- Character
- Vehicle
- ZombieLore
- ZombieAdvanced
Otherwise this mod will create new section for you. For example, name it "MyModSection". Also you should add language string "IGUI_Sandbox_MyModSection".Sandboxed options won't appear in Options Menu. No events for it. It can't be changed during the game or after saving the game. In MP clients (without cheats) will get it as readonly values.