_NickCore v2.7.5
Centralized core functions and tables for use in mods by the author or other authors.
Mod users only need to install this mod using Fluffy Mod Manager and confirm that the text log at the bottom left says it was installed.
Required mods:
Installation
- Install this mod using Fluffy Mod Manager.
- Make sure the text log at the bottom left tells you it has actually been installed.
- If it says no files were installed, download this mod again and reinstall it.
Features
- Better print behavior
- Installed mods tracking
- File list
- Startup tools
- Shared properties table
- Timer handling
- Shared functions table with hooks
- Best way of changing game params on startup
- A way around the
thread.get_hook_storagebug - Useful info on script reset
- A note on script naming
Better print behavior
After running the mod once, go to data/_NickCore/PrintBehavior.json and change the contents to "true" to enable the better print behavior feature. This makes the global log level "error", so the console does not get spammed with useless info messages. It also modifies the print function so it prints to the debug console.
Installed mods tracking
If you add a ModName.json file to data/_NickCore/Installed, a global variable called ModName_installed will be set to true and available to all scripts in your autorun folder. This should streamline compatibility between mods.
File list
_NickCore/Files returns fs.glob(".*"), which is a Lua table with the paths to all files in the data folder. Having this accessible globally means no other mods should need to call fs.glob, which is extremely performance intensive. Note that you need to then filter the file paths, but this is orders of magnitude faster than fs.glob.
Startup tools
_NickCore/Startup gives you access to two functions for when you want to modify data when the game starts.
is_startup(): returns true so long as a script reset has not been performed yet. Use it to modify game data only when the game starts and not on successive script resets.is_game_data_ready(delay): returns true if all the game data has finished loading so you can modify it. Ifdelayis provided, it will wait that additional amount of time, in seconds, before returning true.
Shared properties table
_NickCore/Properties gives you a table of game and player properties. Dozens of mods collect these, sometimes every frame. _NickCore does all of that for you, which means it only needs to be done once. Check the articles section for which properties are collected.
Timer handling
_NickCore/Timers gives you the following functions to streamline setting timers:
set_timer(delay,fn): callsfnafterdelayin seconds, and returns the timer key. The timer accounts for differences in FPS automatically, and will not run while the game is paused.cancel_timer(key): cancels the timer associated withkey.end_timer(key): ends the timer associated withkey, triggering the corresponding function early.
Shared functions table with hooks
_NickCore/Functions gives you a table of tables of functions that are run in different hooks. Dozens of mods hook methods like requestActionCore and calcDamageValue. Having dozens of hooks like that doing calculations can cause performance issues. _NickCore centralizes those hooks: it hooks the methods and runs all functions in a shared functions table each time the method gets called. The hooks also collect some data beforehand and pass it down the line, so you do not have to set that up each time and performance is improved. Check the articles section for which hooks are currently included and which function tables you have to use, along with the data that gets passed.
You can also use this functions table to run functions every frame, adding and removing them dynamically.
Changing game params on startup
Any function added to the run_once table will be deleted if the function returns true. You can use this to modify game params on startup, return true once you are done, and the function will be deleted as if it was never there.
Hook storage workaround
REF hooks have a bug where, if you call a method that has been hooked elsewhere, subsequent calls to thread.get_hook_storage will return nil. NickCore gets around this by passing the storage table as an argument to the hook functions.
Script reset
By default, every time you reset scripts, the mod will print some lines indicating that a script reset has happened, and it will also print how many seconds the game has been running for. You can disable this feature by opening data/_NickCore/ScriptReset.json and changing "true" to "false".
Script naming
The main script starts with "aaa" so it loads first. It has to be the very first script that gets loaded, so make sure you do not have any other scripts loading before it. Note that Windows places scripts starting with _ at the top, but REFramework will actually load those last. _NickCore.lua would not work.





