herobrine_settings.register_setting(name, def, hidden)
Returns true
for success and false
for failure.
name
is a string.def
includes:type
= Could be"table", "boolean", "string", "number"
- Some extra things about the
number
type.min
= Smallest value the number can be. Defaults to0
.max
= Largest value the number can be. Defaults to65536
.
- Some extra things about the
description
= Description of the setting. Defaults to""
value
= Initial value to be registered. The value has to be equal to the type, otherwise it will not be registered.
hidden
is a boolean.- If true, the setting will not show up in
/herobrine settings
. - Default value is false.
- If true, the setting will not show up in
EXAMPLE:
herobrine_settings.register_setting("stalking_timer", {
type = "number",
description = "Interval between when Herobrine stalks a player.",
value = 120,
})
herobrine_settings.get_setting(name)
- Returns a setting's value ornil
herobrine_settings.get_setting_def(name)
- Returns the definition of settingname
ornil
. Definition is the equivalent of thedef
inherobrine_settings.register_setting
.herobrine_settings.get_settings_list()
- Returns a table with all of the registered settings.herobrine_settings.set_setting(name, val)
- Sets a settingname
toval
. Returnstrue
for success andfalse
for failure.herobrine_settings.convert_value(val, to_type)
- Convertsval
to whatever is states into_type
. Returnsnil
if nothing is found. Returns anything butnil
for success.to_type
could be"table", "string", "boolean", "number"
- Might replaced for better functionality.
herobrine_settings.load_settings()
- Loads all of the settings inherobrine_settings.conf
in your worldpath toherobrine_settings
.herobrine_settings.save_settings()
- Savesherobrine_settings
toherobrine_settings.conf
.herobrine_settings.nearest_value(tbl, number)
- Returnsindex, val
.- Calculates the closest index to
number
intbl
. tbl
should be an array.index
is an numerical index from an array.val
is the value found usingtbl[index]
.
- Calculates the closest index to
herobrine_settings.random(min, max, num)
- Returnsnum
orboolean
.- Pretty much equivalent to
math.random()
, but usesPcgRandom
for a stronger randomness. min, max
are integers.num
can be any number.- If
num
is notnil
, it returns a boolean based on if the number generated in themin, max
range is less than or equal tonum
.
- If
- Pretty much equivalent to
herobrine_settings.get_setting_val_from_day_count(name, days)
- Returnsval, success
- Calculated the output from a specific setting.
name
is a string, but must be a valid setting name, whether hidden or not.days
is a number.val
could be"table", "string", "boolean", "number"
.success
is a boolean.true
for success andfalse
for failure.- This function is super specific. See example below.
EXAMPLE:
herobrine_settings.register_setting("ambience_chance", {
type = "table",
description = "The chance of a random sound playing.",
value = {
days = {0, 2, 5, 10},
vals = {0, 10, 15, 20}
}
}, true)
local chance, success = herobrine_settings.get_setting_val_from_day_count("ambience_chance", 3) --> 3 is closest to 2, so it will return whatever the second index is in the vals table.
print(chance) --> 10
print(success) --> true
herobrine_ambience.register_sound(name)
- Registers a sound name. Returnstrue
for success.herobrine_ambience.unregister_sound(name)
- Unregisters a sound. Returnstrue
for success andfalse
for failure.herobrine_ambience.get_ambience_list()
- Get all the registered sounds.herobrine_ambience.get_random_sound()
- Gets a random sound from the registered list.herobrine_ambience.play_sound(spec, duration, parameters)
- Returnssound
andjob
, respectively.- Plays a sound for
duration
seconds. spec
- Can be aSimpleSoundSpec
table or just a sound name.parameters
- A sound parameter table.sound
- a handle returned byminetest.sound_play
job
- Returns a job table fromminetest.after
- Plays a sound for
herobrine_ambience.fade_sound(handle, step, gain)
- Returns a boolean.- Inputs are the same as
minetest.sound_fade
.
- Inputs are the same as
herobrine.signs.register_text(lang_table, text_table)
- Registers all the strings intext_table
into every single language inlang_table
.herobrine.signs.get_full_lang_table()
- Returns all of the languages in a key-value table.herobrine.signs.get_lang_table(lang)
- Returns all the text values in a specific language,lang
. Returnsnil
if language not found.herobrine.signs.generate_random_text(lang)
- Returns a random string from a specific language.herobrine.signs.find_position_near(pos, radius)
- Similar function toherobrine.find_position_near(pos, radius)
.- Uses the setting
signs_spawnable_on
. - Returns an AIR NODE that is ONE BLOCK above the original position.
- Uses the setting
herobrine.signs.place_sign(pos, text)
- Places a sign atpos
withtext
as a string on it.- Supports
signs_lib
.
- Supports
EXAMPLE:
herobrine.signs.register_text({"en"}, {
"I am watching you...",
"On your six!",
})
herobrine.stalk_player(pname, pos)
- Spawnsherobrine:herobrine_stalker
atpos
facingpname
. Returns a boolean.true
for success andfalse
for failure.
herobrine.find_position_near(pos, radius)
- This function is used inherobrine/functions/stalking.lua
. Finds a position that meets the standards ofspawnable_on
. Returnsnewpos
andtrue
for success. Otherwise returnspos
andfalse
.- The node returned is an AIR NODE that is TWO BLOCKS above the original position.
radius
is a number. Must be less than or equal to 79 to stop an overflow.
herobrine.jumpscare_player(player, duration, sound)
- Jumpscares a player.player
is anObjectRef
duration
- How long the jumpscare photo will be shown on the player's screen.sound
- Iftrue
, a sound will go off when a player has been jumpscared.
herobrine.line_of_sight(pos1, pos2)
- Returnsboolean, pos
- Checks if there are any opaque blocks between
pos1
andpos2
. - Returns false if unsuccessful.
- Returns the position of the blocking node when
false
.
- Checks if there are any opaque blocks between
herobrine.lighting_strike(pos)
- Spawns a lightning strike atpos
, only if the modlightning
by sofar is enabled.herobrine.get_day_count()
- Returns a number.- Independent from what is returned in
minetest.get_day_count()
. - Used for internal calculations within the mod.
- Independent from what is returned in
herobrine.set_day_count(num)
- Sets the daycount.
num
is a number.
herobrine.spawnHerobrine(name, pos)
- Returnsboolean, table
- Spawns a Herobrine at position
pos
. - Activates callbacks.
boolean
-true
for success andfalse
for failure.table
is a luaentity table for the mob only ifboolean
istrue
.
- Spawns a Herobrine at position
herobrine.despawnHerobrine(luaentity)
- Despawns a luaentity.
- Activates callbacks.
herobrine_commands.register_subcommand(name, def, hidden)
- Registers a subcommand under theherobrine
command.name
anddef
are both the equivalent toname
anddef
from lib_chatcmdbuilder.hidden
is a boolean. If set to true, the command will not be shown when/herobrine help
is executed. Default is false.
EXAMPLE:
herobrine_commands.register_subcommand("save_settings", {
description = "Saves the current settings to a config file.",
privs = herobrine_commands.default_privs,
func = function(name)
local success = herobrine_settings.save_settings()
if success then
minetest.chat_send_player(name, "Able to save to config file.")
else
minetest.chat_send_player(name, "Was not able to save to config file,")
end
end,
})
The command can then be accessed using /herobrine save_settings
.
herobrine.register_on_day_change(function(daycount))
- Called when the internal daycount has changed.
daycount
is a number.
herobrine.register_on_spawn(function(luaentity))
- Called when a Herobrine mob is spawned.
luaentity
is a table.- Must return
true
otherwise the mob will not spawn.
herobrine.register_on_despawn(function(luaentity))
- Called when a Herobrine mob has been despawned.
luaentity
is a table.
herobrine_commands.default_privs
- Returns a table with the default privileges.- Can be used in both
minetest.register_subcommand
andherobrine_commands.register_subcommand
. server, interact, shout, herobrine_admin
are the default privileges.
- Can be used in both
herobrine_settings.conf_modpath
- Returns a filepath used in order to help store herobrine_settings.conf.- Defaults to what is returned from
minetest.get_worldpath()
.
- Defaults to what is returned from