Fix LuaDoc sections
This commit is contained in:
parent
3486dcbdcc
commit
adbaf2887b
@ -70,7 +70,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||||
<i style="float:right;">Last updated 2021-05-24 22:52:24 </i>
|
<i style="float:right;">Last updated 2021-05-25 21:52:58 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -244,7 +244,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||||
<i style="float:right;">Last updated 2021-05-24 22:52:24 </i>
|
<i style="float:right;">Last updated 2021-05-25 21:52:58 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -94,7 +94,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||||
<i style="float:right;">Last updated 2021-05-24 22:52:24 </i>
|
<i style="float:right;">Last updated 2021-05-25 21:52:58 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -65,6 +65,10 @@
|
|||||||
<td class="name" ><a href="#cmer.register_mob">cmer.register_mob (def)</a></td>
|
<td class="name" ><a href="#cmer.register_mob">cmer.register_mob (def)</a></td>
|
||||||
<td class="summary">Registers a new mob.</td>
|
<td class="summary">Registers a new mob.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" ><a href="#cmer.register_alias">cmer.register_alias (old_mob, new_mob)</a></td>
|
||||||
|
<td class="summary">Registers an alias for other mob, e.g.</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<h2><a href="#Tables">Tables</a></h2>
|
<h2><a href="#Tables">Tables</a></h2>
|
||||||
<table class="function_list">
|
<table class="function_list">
|
||||||
@ -146,10 +150,6 @@
|
|||||||
<td class="name" ><a href="#CreatureDef.get_staticdata">CreatureDef.get_staticdata (self)</a></td>
|
<td class="name" ><a href="#CreatureDef.get_staticdata">CreatureDef.get_staticdata (self)</a></td>
|
||||||
<td class="summary">Must return a table to save mob data (serialization is done by MOB-Engine).</td>
|
<td class="summary">Must return a table to save mob data (serialization is done by MOB-Engine).</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td class="name" ><a href="#cmer.register_alias">cmer.register_alias (old_mob, new_mob)</a></td>
|
|
||||||
<td class="summary">Registers an alias for other mob, e.g.</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
@ -187,6 +187,39 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "cmer.register_alias"></a>
|
||||||
|
<strong>cmer.register_alias (old_mob, new_mob)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Registers an alias for other mob, e.g. from other mods or removed ones.
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">old_mob</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
|
||||||
|
Name of mob to be replaced. E.g. "creatures:oerrki"
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">new_mob</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
|
||||||
|
Name of mob that will replace instances old one. E.g. "creatures:oerkki"
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
<code>true</code> if successful.
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
|
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
|
||||||
@ -1078,39 +1111,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "cmer.register_alias"></a>
|
|
||||||
<strong>cmer.register_alias (old_mob, new_mob)</strong>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Registers an alias for other mob, e.g. from other mods or removed ones.
|
|
||||||
|
|
||||||
</ul>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Parameters:</h3>
|
|
||||||
<ul>
|
|
||||||
<li><span class="parameter">old_mob</span>
|
|
||||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
|
|
||||||
Name of mob to be replaced. E.g. "creatures:oerrki"
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">new_mob</span>
|
|
||||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
|
|
||||||
Name of mob that will replace instances old one. E.g. "creatures:oerkki"
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Returns:</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<span class="types"><span class="type">bool</span></span>
|
|
||||||
<code>true</code> if successful.
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
@ -1119,7 +1119,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||||
<i style="float:right;">Last updated 2021-05-24 22:52:24 </i>
|
<i style="float:right;">Last updated 2021-05-25 21:52:58 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -234,7 +234,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||||
<i style="float:right;">Last updated 2021-05-24 22:52:24 </i>
|
<i style="float:right;">Last updated 2021-05-25 21:52:58 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
498
register.lua
498
register.lua
@ -270,11 +270,6 @@ local function translate_def(def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Registers a new mob.
|
|
||||||
--
|
|
||||||
-- @function cmer.register_mob
|
|
||||||
-- @tparam CreatureDef def Creature definition table.
|
|
||||||
-- @treturn bool `true` if successfule.
|
|
||||||
function cmer.register_mob(def) -- returns true if sucessfull
|
function cmer.register_mob(def) -- returns true if sucessfull
|
||||||
if not def or not def.name then
|
if not def or not def.name then
|
||||||
throw_error("Can't register mob. No name or Definition given.")
|
throw_error("Can't register mob. No name or Definition given.")
|
||||||
@ -307,242 +302,6 @@ function cmer.register_mob(def) -- returns true if sucessfull
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Creature definition table.
|
|
||||||
--
|
|
||||||
-- @table CreatureDef
|
|
||||||
-- @tfield string name E.g. "creatures:sheep".
|
|
||||||
-- @tfield[opt] string nametag String to be displayed in entity's nametag.
|
|
||||||
-- @tfield[opt] bool ownable Flag for defining if entity is ownable by players (default: *false*).
|
|
||||||
-- @tfield StatsDef stats Stats definitions.
|
|
||||||
-- @tfield ModeDef modes Entity bahavior defintions.
|
|
||||||
-- @tfield ModelDef model Model definitions.
|
|
||||||
-- @tfield[opt] table sounds Table of `SoundDef`. Additionally, `play_default_hit` can be set to `false` here to disable default "hit" sound.
|
|
||||||
-- @tfield[opt] table drops List of item `DropDef`. Can also be a function. receives "self" reference.
|
|
||||||
-- @tfield[opt] CombatDef combat Specifies behavior of hostile mobs in "attack" mode.
|
|
||||||
-- @tfield[opt] SpawnDef spawning Defines spawning in world.
|
|
||||||
-- @tfield callback on_activate see: `CreatureDef.on_activate`
|
|
||||||
-- @tfield callback on_step see: `CreatureDef.on_step`
|
|
||||||
-- @tfield callback on_punch see: `CreatureDef.on_punch`
|
|
||||||
-- @tfield callback on_rightclick see: `CreatureDef.on_rightclick`
|
|
||||||
-- @tfield callback on_death see: `CreatureDef.on_death`
|
|
||||||
-- @tfield callback get_staticdata see: `CreatureDef.get_staticdata`
|
|
||||||
|
|
||||||
|
|
||||||
--- Definition Tables
|
|
||||||
--
|
|
||||||
-- @section defs
|
|
||||||
|
|
||||||
--- Stats definition table.
|
|
||||||
--
|
|
||||||
-- @table StatsDef
|
|
||||||
-- @tparam int hp Full health level (1 HP = 1/2 player heart).
|
|
||||||
-- @tparam[opt] bool hostile Is mob hostile (required for mode "attack") (default: `false`).
|
|
||||||
-- @tparam[opt] int lifetime After which time mob despawns, in seconds.
|
|
||||||
-- @tparam[opt] bool dies_when_tamed Stop despawn when tamed (default: `false`).
|
|
||||||
-- @tparam[opt] int can_jump Height in nodes (default: 0).
|
|
||||||
-- @tparam[opt] bool can_swim Can mob swim or will it drown (default: `false`).
|
|
||||||
-- @tparam[opt] bool can_fly Allows to fly (requires mode "fly") and disable step sounds (default: `false`).
|
|
||||||
-- @tparam[opt] bool can_burn Takes damage of lava (default: `false`).
|
|
||||||
-- @tparam[opt] bool can_panic Runs fast around when hit (requires mode "walk") (default: `false`).
|
|
||||||
-- @tparam[opt] bool has_falldamage Deals damage if falling more than 3 blocks (default: `false`).
|
|
||||||
-- @tparam[opt] bool has_knockback Get knocked back when hit (default: `false`).
|
|
||||||
-- @tparam[opt] bool sneaky Disables step sounds if `true` (default: `false`).
|
|
||||||
-- @tparam[opt] table light Which light level will burn creature (requires can_burn = true).
|
|
||||||
--
|
|
||||||
-- Example:
|
|
||||||
--
|
|
||||||
-- light = {min=10, max=15}
|
|
||||||
|
|
||||||
--- Modes definition table.
|
|
||||||
--
|
|
||||||
-- Entity behavior definition. Behavior types are ***idle***, ***walk***, ***attack***, ***follow***, ***eat***, ***death***, & ***panic***. The sum of all modes must be 1.0.
|
|
||||||
--
|
|
||||||
-- Example:
|
|
||||||
--
|
|
||||||
-- modes = {
|
|
||||||
-- idle = {chance=0.3,},
|
|
||||||
-- walk = {chance=0.7, moving_speed=1,},
|
|
||||||
-- }
|
|
||||||
--
|
|
||||||
-- @table ModeDef
|
|
||||||
-- @tfield float chance Number between 0.0 and 1.0 (***NOTE:** sum of all modes MUST be 1.0*). If chance is 0 then mode is not chosen automatically.
|
|
||||||
-- @tfield int duration Time in seconds until the next mode is chosen (depending on chance).
|
|
||||||
-- @tfield[opt] int moving_speed Moving speed (walking/flying/swimming).
|
|
||||||
-- @tfield[opt] int update_yaw Timer in seconds until the looking dir is changed. If moving_speed > 0 then the moving direction is also changed.
|
|
||||||
-- @tfield int radius *(follow & eat modes only)* Search distance in blocks/nodes for player.
|
|
||||||
-- @tfield int timer *(follow & eat modes only)* Time in seconds between each check for player.
|
|
||||||
-- @tfield table items *(follow & eat modes only)* Table of items to make mob follow in format {<Itemname>, <Itemname>}; e.g. {"farming:wheat"}.
|
|
||||||
-- @tfield table nodes *(eat mode only)* Eatable nodes in format {<Itemname>, <Itemname>}; e.g. {"default:dirt\_with\_grass"}.
|
|
||||||
|
|
||||||
--- Model definition table.
|
|
||||||
--
|
|
||||||
-- @table ModelDef
|
|
||||||
-- @tfield string mesh Mesh name (see Minetest Documentation for supported filetypes).
|
|
||||||
-- @tfield table textures Table of textures (see Minetest Documentation).
|
|
||||||
-- @tfield[opt] NodeBox collisionbox Defines mesh collision box (see Minetest Documentation).
|
|
||||||
-- @tfield[opt] table scale Sets visual scale (default: {x=1, y=1}).
|
|
||||||
-- @tfield[opt] float rotation Sets rotation offset when moving (default: 0.0).
|
|
||||||
-- @tfield[opt] bool backface_culling Set to `true` to enable backface culling.
|
|
||||||
-- @tfield[opt] table animations Table of `AnimationDef` used if defined.
|
|
||||||
-- @tfield[opt] bool collide_with_objects Collide with other objects (default: `true`).
|
|
||||||
|
|
||||||
--- Animations defiintion table.
|
|
||||||
--
|
|
||||||
-- Animations coincide with modes. E.g. ***idle***, ***walk***, etc.
|
|
||||||
--
|
|
||||||
-- Example:
|
|
||||||
--
|
|
||||||
-- animations = {
|
|
||||||
-- idle = {start=25, stop=75, speed=15,},
|
|
||||||
-- walk = {start=75, stop=100, speed=15,},
|
|
||||||
-- }
|
|
||||||
--
|
|
||||||
-- @table AnimationDef
|
|
||||||
-- @tfield int start Start frame.
|
|
||||||
-- @tfield int stop End frame.
|
|
||||||
-- @tfield int speed Animation speed.
|
|
||||||
-- @tfield[opt] bool loop If `false`, animation if just played once (default: `true`).
|
|
||||||
-- @tfield[opt] int duration *(death mode only)* Sets time the animation needs until mob is removed.
|
|
||||||
|
|
||||||
--- Sounds definition table.
|
|
||||||
--
|
|
||||||
-- Sounds can be defined for these actions: ***on_damage***, ***on_death***, ***swim***, & ***random***.
|
|
||||||
--
|
|
||||||
-- ***random*** is a table of `SoundDef` that will be played randomly during the modes for which they are set.
|
|
||||||
--
|
|
||||||
-- Example:
|
|
||||||
--
|
|
||||||
-- sounds = {
|
|
||||||
-- on_damage = {name="creatures_horse_neigh_02", gain=1.0},
|
|
||||||
-- on_death = {name="creatures_horse_snort_02", gain=1.0},
|
|
||||||
-- random = {
|
|
||||||
-- idle = {name="creatures_horse_snort_01", gain=1.0},
|
|
||||||
-- follow = {name="creatures_horse_neigh_01", gain=1.0, time_min=10},
|
|
||||||
-- },
|
|
||||||
-- }
|
|
||||||
--
|
|
||||||
-- @table SoundsDef
|
|
||||||
-- @tparam[opt] SoundDef on_damage Sound played when entity is hit.
|
|
||||||
-- @tparam[opt] SoundDef on_death Sound played when entity dies.
|
|
||||||
-- @tparam[opt] SoundDef swim Sound played while entity is swimming.
|
|
||||||
-- @tparam[opt] table Random Sounds that will play randomly during specified modes. E.g. ***idle***, ***walk***, etc.
|
|
||||||
|
|
||||||
--- Sound definition.
|
|
||||||
--
|
|
||||||
-- @table SoundDef
|
|
||||||
-- @tfield string name Sound file name without file type extension (e.g. "my_sound", not "my_sound.ogg") (see Minetest documentation).
|
|
||||||
-- @tfield float gain Sound gain (see Minetest documentation).
|
|
||||||
-- @tfield[opt] int distance Distance in blocks/nodes at which sound can be heard.
|
|
||||||
-- @tfield[opt] int time_min *(random mode only)* Minimum time in seconds between sounds.
|
|
||||||
-- @tfield[opt] int time_max *(random mode only)* Maximum time in seconds between sounds.
|
|
||||||
|
|
||||||
--- Item drops definition table.
|
|
||||||
--
|
|
||||||
-- Example:
|
|
||||||
--
|
|
||||||
-- drops = {
|
|
||||||
-- {"default:wood"}, -- 1 item with 100% chance
|
|
||||||
-- {"default:wool", 1, chance=0.3}, -- 1 item with 30% chance
|
|
||||||
-- {"default:stick", {min=2, max=3}, chance=0.2}, -- between 2-3 items with 20% chance
|
|
||||||
-- }
|
|
||||||
--
|
|
||||||
-- @table DropDef
|
|
||||||
|
|
||||||
--- Combat definition table.
|
|
||||||
--
|
|
||||||
-- @table CombatDef
|
|
||||||
-- @tfield int attack_damage How much damage is dealt on each hit.
|
|
||||||
-- @tfield[opt] float attack_speed Time in seconds between hits (default: 1.0).
|
|
||||||
-- @tfield float attack_radius Distance in blocks mob can reach to hit.
|
|
||||||
-- @tfield bool search_enemy `true` to search enemies to attack.
|
|
||||||
-- @tfield[opt] int search_timer Time in seconds to search an enemy (only if none found yet) (default: 2).
|
|
||||||
-- @tfield int search_radius Radius in blocks within enemies are searched.
|
|
||||||
-- @tfield string search_type What enemy is being searched (see types at `cmer.findTarget`).
|
|
||||||
|
|
||||||
--- Spawning definition table.
|
|
||||||
--
|
|
||||||
-- @table SpawnDef
|
|
||||||
-- @tfield ABMNodesDef abm_nodes On what nodes mob can spawn.
|
|
||||||
-- @tfield int abm_interval Time in seconds until Minetest tries to find a node with set specs.
|
|
||||||
-- @tfield int abm_chance Chance is 1/<chance>.
|
|
||||||
-- @tfield int max_number Maximum mobs of this kind per mapblock (16x16x16).
|
|
||||||
-- @tfield int number How many mobs are spawned if found suitable spawn position. Can be `int` or `table`: number = {min=<value>, max=<value>}
|
|
||||||
-- @tfield[opt] table time_range Time range in time of day format (0-24000) (table with *min* & *max* values).
|
|
||||||
-- @tfield[opt] table light Min and max lightvalue at spawn position (table with *min* & *max* values).
|
|
||||||
-- @tfield[opt] table height_limit Min and max height (world Y coordinate) (table with *min* & *max* values).
|
|
||||||
-- @tfield[opt] SpawnerDef spawner Is set a spawner_node is added to creative inventory.
|
|
||||||
|
|
||||||
--- ABM nodes definition table.
|
|
||||||
--
|
|
||||||
-- @table ABMNodesDef
|
|
||||||
-- @tfield[opt] table spawn_on List of nodes on which the mob can spawn.
|
|
||||||
-- @tfield table neighbors List of nodes that should be neighbors where mob can spawn. Can be nil or table as above. "air" is forced always as neighbor.
|
|
||||||
|
|
||||||
--- Spawner definition table.
|
|
||||||
--
|
|
||||||
-- @table SpawnerDef
|
|
||||||
-- @tfield int range Defines an area (in blocks/nodes) within mobs are spawned.
|
|
||||||
-- @tfield int number Maxmimum number of mobs spawned in area defined via range.
|
|
||||||
-- @tfield[opt] string description Item description as string.
|
|
||||||
-- @tfield[opt] table light Min and max lightvalue at spawn position.
|
|
||||||
|
|
||||||
|
|
||||||
--- Callbacks
|
|
||||||
--
|
|
||||||
-- @section callbacks
|
|
||||||
|
|
||||||
--- Called when mob (re-)activated.
|
|
||||||
--
|
|
||||||
-- Note: staticdata is deserialized by MOB-Engine (including custom values).
|
|
||||||
--
|
|
||||||
-- @function CreatureDef.on_activate
|
|
||||||
-- @param self
|
|
||||||
-- @tparam string staticdata Formatted string data to be deserialized.
|
|
||||||
-- @tparam int dtime_s The time passed since the object was unloaded, which can be used for updating the entity state.
|
|
||||||
|
|
||||||
--- Called each server step, after movement and collision processing.
|
|
||||||
--
|
|
||||||
-- @function CreatureDef.on_step
|
|
||||||
-- @param self
|
|
||||||
-- @tparam float dtime Usually 0.1 seconds, as per the `dedicated_server_step` setting in `minetest.conf`.
|
|
||||||
-- @treturn bool Prevents default action when returns `true`.
|
|
||||||
|
|
||||||
--- Called when mob is punched.
|
|
||||||
--
|
|
||||||
-- @function CreatureDef.on_punch
|
|
||||||
-- @param self
|
|
||||||
-- @tparam ObjectRef puncher
|
|
||||||
-- @param time_from_last_punch Meant for disallowing spamming of clicks.
|
|
||||||
-- @tparam table tool_capabilities See: http://minetest.gitlab.io/minetest/tools.html
|
|
||||||
-- @param dir Unit vector of direction of punch. Always defined. Points from the puncher to the punched.
|
|
||||||
-- @tparam int damage Damage that will be done to entity.
|
|
||||||
-- @treturn bool Prevents default action when returns `true`.
|
|
||||||
|
|
||||||
--- Called when mob is right-clicked.
|
|
||||||
--
|
|
||||||
-- @function CreatureDef.on_rightclick
|
|
||||||
-- @param self
|
|
||||||
-- @tparam ObjectRef clicker Entity that did the punching.
|
|
||||||
-- @treturn bool Prevents default action when returns `true`.
|
|
||||||
|
|
||||||
--- Called when mob dies.
|
|
||||||
--
|
|
||||||
-- @function CreatureDef.on_death
|
|
||||||
-- @param self
|
|
||||||
-- @tparam ObjectRef killer (can be `nil`)
|
|
||||||
|
|
||||||
--- Must return a table to save mob data (serialization is done by MOB-Engine).
|
|
||||||
--
|
|
||||||
-- e.g:
|
|
||||||
--
|
|
||||||
-- return {
|
|
||||||
-- custom_mob_data = self.my_value,
|
|
||||||
-- }
|
|
||||||
--
|
|
||||||
-- @function CreatureDef.get_staticdata
|
|
||||||
-- @param self
|
|
||||||
-- @treturn table
|
|
||||||
|
|
||||||
|
|
||||||
local function inRange(min_max, value)
|
local function inRange(min_max, value)
|
||||||
if not value or not min_max or not min_max.min or not min_max.max then
|
if not value or not min_max or not min_max.min or not min_max.max then
|
||||||
@ -856,12 +615,6 @@ local function register_alias_entity(old_mob, new_mob)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Registers an alias for other mob, e.g. from other mods or removed ones.
|
|
||||||
--
|
|
||||||
-- @function cmer.register_alias
|
|
||||||
-- @tparam string old_mob Name of mob to be replaced. E.g. "creatures:oerrki"
|
|
||||||
-- @tparam string new_mob Name of mob that will replace instances old one. E.g. "creatures:oerkki"
|
|
||||||
-- @treturn bool `true` if successful.
|
|
||||||
function cmer.register_alias(old_mob, new_mob)
|
function cmer.register_alias(old_mob, new_mob)
|
||||||
local def = core.registered_entities[new_mob]
|
local def = core.registered_entities[new_mob]
|
||||||
if not def then
|
if not def then
|
||||||
@ -878,3 +631,254 @@ function cmer.register_alias(old_mob, new_mob)
|
|||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Registers a new mob.
|
||||||
|
--
|
||||||
|
-- @function cmer.register_mob
|
||||||
|
-- @tparam CreatureDef def Creature definition table.
|
||||||
|
-- @treturn bool `true` if successfule.
|
||||||
|
|
||||||
|
--- Registers an alias for other mob, e.g. from other mods or removed ones.
|
||||||
|
--
|
||||||
|
-- @function cmer.register_alias
|
||||||
|
-- @tparam string old_mob Name of mob to be replaced. E.g. "creatures:oerrki"
|
||||||
|
-- @tparam string new_mob Name of mob that will replace instances old one. E.g. "creatures:oerkki"
|
||||||
|
-- @treturn bool `true` if successful.
|
||||||
|
|
||||||
|
|
||||||
|
--- Creature definition table.
|
||||||
|
--
|
||||||
|
-- @table CreatureDef
|
||||||
|
-- @tfield string name E.g. "creatures:sheep".
|
||||||
|
-- @tfield[opt] string nametag String to be displayed in entity's nametag.
|
||||||
|
-- @tfield[opt] bool ownable Flag for defining if entity is ownable by players (default: *false*).
|
||||||
|
-- @tfield StatsDef stats Stats definitions.
|
||||||
|
-- @tfield ModeDef modes Entity bahavior defintions.
|
||||||
|
-- @tfield ModelDef model Model definitions.
|
||||||
|
-- @tfield[opt] table sounds Table of `SoundDef`. Additionally, `play_default_hit` can be set to `false` here to disable default "hit" sound.
|
||||||
|
-- @tfield[opt] table drops List of item `DropDef`. Can also be a function. receives "self" reference.
|
||||||
|
-- @tfield[opt] CombatDef combat Specifies behavior of hostile mobs in "attack" mode.
|
||||||
|
-- @tfield[opt] SpawnDef spawning Defines spawning in world.
|
||||||
|
-- @tfield callback on_activate see: `CreatureDef.on_activate`
|
||||||
|
-- @tfield callback on_step see: `CreatureDef.on_step`
|
||||||
|
-- @tfield callback on_punch see: `CreatureDef.on_punch`
|
||||||
|
-- @tfield callback on_rightclick see: `CreatureDef.on_rightclick`
|
||||||
|
-- @tfield callback on_death see: `CreatureDef.on_death`
|
||||||
|
-- @tfield callback get_staticdata see: `CreatureDef.get_staticdata`
|
||||||
|
|
||||||
|
|
||||||
|
--- Definition Tables
|
||||||
|
--
|
||||||
|
-- @section defs
|
||||||
|
|
||||||
|
--- Stats definition table.
|
||||||
|
--
|
||||||
|
-- @table StatsDef
|
||||||
|
-- @tparam int hp Full health level (1 HP = 1/2 player heart).
|
||||||
|
-- @tparam[opt] bool hostile Is mob hostile (required for mode "attack") (default: `false`).
|
||||||
|
-- @tparam[opt] int lifetime After which time mob despawns, in seconds.
|
||||||
|
-- @tparam[opt] bool dies_when_tamed Stop despawn when tamed (default: `false`).
|
||||||
|
-- @tparam[opt] int can_jump Height in nodes (default: 0).
|
||||||
|
-- @tparam[opt] bool can_swim Can mob swim or will it drown (default: `false`).
|
||||||
|
-- @tparam[opt] bool can_fly Allows to fly (requires mode "fly") and disable step sounds (default: `false`).
|
||||||
|
-- @tparam[opt] bool can_burn Takes damage of lava (default: `false`).
|
||||||
|
-- @tparam[opt] bool can_panic Runs fast around when hit (requires mode "walk") (default: `false`).
|
||||||
|
-- @tparam[opt] bool has_falldamage Deals damage if falling more than 3 blocks (default: `false`).
|
||||||
|
-- @tparam[opt] bool has_knockback Get knocked back when hit (default: `false`).
|
||||||
|
-- @tparam[opt] bool sneaky Disables step sounds if `true` (default: `false`).
|
||||||
|
-- @tparam[opt] table light Which light level will burn creature (requires can_burn = true).
|
||||||
|
--
|
||||||
|
-- Example:
|
||||||
|
--
|
||||||
|
-- light = {min=10, max=15}
|
||||||
|
|
||||||
|
--- Modes definition table.
|
||||||
|
--
|
||||||
|
-- Entity behavior definition. Behavior types are ***idle***, ***walk***, ***attack***, ***follow***, ***eat***, ***death***, & ***panic***. The sum of all modes must be 1.0.
|
||||||
|
--
|
||||||
|
-- Example:
|
||||||
|
--
|
||||||
|
-- modes = {
|
||||||
|
-- idle = {chance=0.3,},
|
||||||
|
-- walk = {chance=0.7, moving_speed=1,},
|
||||||
|
-- }
|
||||||
|
--
|
||||||
|
-- @table ModeDef
|
||||||
|
-- @tfield float chance Number between 0.0 and 1.0 (***NOTE:** sum of all modes MUST be 1.0*). If chance is 0 then mode is not chosen automatically.
|
||||||
|
-- @tfield int duration Time in seconds until the next mode is chosen (depending on chance).
|
||||||
|
-- @tfield[opt] int moving_speed Moving speed (walking/flying/swimming).
|
||||||
|
-- @tfield[opt] int update_yaw Timer in seconds until the looking dir is changed. If moving_speed > 0 then the moving direction is also changed.
|
||||||
|
-- @tfield int radius *(follow & eat modes only)* Search distance in blocks/nodes for player.
|
||||||
|
-- @tfield int timer *(follow & eat modes only)* Time in seconds between each check for player.
|
||||||
|
-- @tfield table items *(follow & eat modes only)* Table of items to make mob follow in format {<Itemname>, <Itemname>}; e.g. {"farming:wheat"}.
|
||||||
|
-- @tfield table nodes *(eat mode only)* Eatable nodes in format {<Itemname>, <Itemname>}; e.g. {"default:dirt\_with\_grass"}.
|
||||||
|
|
||||||
|
--- Model definition table.
|
||||||
|
--
|
||||||
|
-- @table ModelDef
|
||||||
|
-- @tfield string mesh Mesh name (see Minetest Documentation for supported filetypes).
|
||||||
|
-- @tfield table textures Table of textures (see Minetest Documentation).
|
||||||
|
-- @tfield[opt] NodeBox collisionbox Defines mesh collision box (see Minetest Documentation).
|
||||||
|
-- @tfield[opt] table scale Sets visual scale (default: {x=1, y=1}).
|
||||||
|
-- @tfield[opt] float rotation Sets rotation offset when moving (default: 0.0).
|
||||||
|
-- @tfield[opt] bool backface_culling Set to `true` to enable backface culling.
|
||||||
|
-- @tfield[opt] table animations Table of `AnimationDef` used if defined.
|
||||||
|
-- @tfield[opt] bool collide_with_objects Collide with other objects (default: `true`).
|
||||||
|
|
||||||
|
--- Animations defiintion table.
|
||||||
|
--
|
||||||
|
-- Animations coincide with modes. E.g. ***idle***, ***walk***, etc.
|
||||||
|
--
|
||||||
|
-- Example:
|
||||||
|
--
|
||||||
|
-- animations = {
|
||||||
|
-- idle = {start=25, stop=75, speed=15,},
|
||||||
|
-- walk = {start=75, stop=100, speed=15,},
|
||||||
|
-- }
|
||||||
|
--
|
||||||
|
-- @table AnimationDef
|
||||||
|
-- @tfield int start Start frame.
|
||||||
|
-- @tfield int stop End frame.
|
||||||
|
-- @tfield int speed Animation speed.
|
||||||
|
-- @tfield[opt] bool loop If `false`, animation if just played once (default: `true`).
|
||||||
|
-- @tfield[opt] int duration *(death mode only)* Sets time the animation needs until mob is removed.
|
||||||
|
|
||||||
|
--- Sounds definition table.
|
||||||
|
--
|
||||||
|
-- Sounds can be defined for these actions: ***on_damage***, ***on_death***, ***swim***, & ***random***.
|
||||||
|
--
|
||||||
|
-- ***random*** is a table of `SoundDef` that will be played randomly during the modes for which they are set.
|
||||||
|
--
|
||||||
|
-- Example:
|
||||||
|
--
|
||||||
|
-- sounds = {
|
||||||
|
-- on_damage = {name="creatures_horse_neigh_02", gain=1.0},
|
||||||
|
-- on_death = {name="creatures_horse_snort_02", gain=1.0},
|
||||||
|
-- random = {
|
||||||
|
-- idle = {name="creatures_horse_snort_01", gain=1.0},
|
||||||
|
-- follow = {name="creatures_horse_neigh_01", gain=1.0, time_min=10},
|
||||||
|
-- },
|
||||||
|
-- }
|
||||||
|
--
|
||||||
|
-- @table SoundsDef
|
||||||
|
-- @tparam[opt] SoundDef on_damage Sound played when entity is hit.
|
||||||
|
-- @tparam[opt] SoundDef on_death Sound played when entity dies.
|
||||||
|
-- @tparam[opt] SoundDef swim Sound played while entity is swimming.
|
||||||
|
-- @tparam[opt] table Random Sounds that will play randomly during specified modes. E.g. ***idle***, ***walk***, etc.
|
||||||
|
|
||||||
|
--- Sound definition.
|
||||||
|
--
|
||||||
|
-- @table SoundDef
|
||||||
|
-- @tfield string name Sound file name without file type extension (e.g. "my_sound", not "my_sound.ogg") (see Minetest documentation).
|
||||||
|
-- @tfield float gain Sound gain (see Minetest documentation).
|
||||||
|
-- @tfield[opt] int distance Distance in blocks/nodes at which sound can be heard.
|
||||||
|
-- @tfield[opt] int time_min *(random mode only)* Minimum time in seconds between sounds.
|
||||||
|
-- @tfield[opt] int time_max *(random mode only)* Maximum time in seconds between sounds.
|
||||||
|
|
||||||
|
--- Item drops definition table.
|
||||||
|
--
|
||||||
|
-- Example:
|
||||||
|
--
|
||||||
|
-- drops = {
|
||||||
|
-- {"default:wood"}, -- 1 item with 100% chance
|
||||||
|
-- {"default:wool", 1, chance=0.3}, -- 1 item with 30% chance
|
||||||
|
-- {"default:stick", {min=2, max=3}, chance=0.2}, -- between 2-3 items with 20% chance
|
||||||
|
-- }
|
||||||
|
--
|
||||||
|
-- @table DropDef
|
||||||
|
|
||||||
|
--- Combat definition table.
|
||||||
|
--
|
||||||
|
-- @table CombatDef
|
||||||
|
-- @tfield int attack_damage How much damage is dealt on each hit.
|
||||||
|
-- @tfield[opt] float attack_speed Time in seconds between hits (default: 1.0).
|
||||||
|
-- @tfield float attack_radius Distance in blocks mob can reach to hit.
|
||||||
|
-- @tfield bool search_enemy `true` to search enemies to attack.
|
||||||
|
-- @tfield[opt] int search_timer Time in seconds to search an enemy (only if none found yet) (default: 2).
|
||||||
|
-- @tfield int search_radius Radius in blocks within enemies are searched.
|
||||||
|
-- @tfield string search_type What enemy is being searched (see types at `cmer.findTarget`).
|
||||||
|
|
||||||
|
--- Spawning definition table.
|
||||||
|
--
|
||||||
|
-- @table SpawnDef
|
||||||
|
-- @tfield ABMNodesDef abm_nodes On what nodes mob can spawn.
|
||||||
|
-- @tfield int abm_interval Time in seconds until Minetest tries to find a node with set specs.
|
||||||
|
-- @tfield int abm_chance Chance is 1/<chance>.
|
||||||
|
-- @tfield int max_number Maximum mobs of this kind per mapblock (16x16x16).
|
||||||
|
-- @tfield int number How many mobs are spawned if found suitable spawn position. Can be `int` or `table`: number = {min=<value>, max=<value>}
|
||||||
|
-- @tfield[opt] table time_range Time range in time of day format (0-24000) (table with *min* & *max* values).
|
||||||
|
-- @tfield[opt] table light Min and max lightvalue at spawn position (table with *min* & *max* values).
|
||||||
|
-- @tfield[opt] table height_limit Min and max height (world Y coordinate) (table with *min* & *max* values).
|
||||||
|
-- @tfield[opt] SpawnerDef spawner Is set a spawner_node is added to creative inventory.
|
||||||
|
|
||||||
|
--- ABM nodes definition table.
|
||||||
|
--
|
||||||
|
-- @table ABMNodesDef
|
||||||
|
-- @tfield[opt] table spawn_on List of nodes on which the mob can spawn.
|
||||||
|
-- @tfield table neighbors List of nodes that should be neighbors where mob can spawn. Can be nil or table as above. "air" is forced always as neighbor.
|
||||||
|
|
||||||
|
--- Spawner definition table.
|
||||||
|
--
|
||||||
|
-- @table SpawnerDef
|
||||||
|
-- @tfield int range Defines an area (in blocks/nodes) within mobs are spawned.
|
||||||
|
-- @tfield int number Maxmimum number of mobs spawned in area defined via range.
|
||||||
|
-- @tfield[opt] string description Item description as string.
|
||||||
|
-- @tfield[opt] table light Min and max lightvalue at spawn position.
|
||||||
|
|
||||||
|
|
||||||
|
--- Callbacks
|
||||||
|
--
|
||||||
|
-- @section callbacks
|
||||||
|
|
||||||
|
--- Called when mob (re-)activated.
|
||||||
|
--
|
||||||
|
-- Note: staticdata is deserialized by MOB-Engine (including custom values).
|
||||||
|
--
|
||||||
|
-- @function CreatureDef.on_activate
|
||||||
|
-- @param self
|
||||||
|
-- @tparam string staticdata Formatted string data to be deserialized.
|
||||||
|
-- @tparam int dtime_s The time passed since the object was unloaded, which can be used for updating the entity state.
|
||||||
|
|
||||||
|
--- Called each server step, after movement and collision processing.
|
||||||
|
--
|
||||||
|
-- @function CreatureDef.on_step
|
||||||
|
-- @param self
|
||||||
|
-- @tparam float dtime Usually 0.1 seconds, as per the `dedicated_server_step` setting in `minetest.conf`.
|
||||||
|
-- @treturn bool Prevents default action when returns `true`.
|
||||||
|
|
||||||
|
--- Called when mob is punched.
|
||||||
|
--
|
||||||
|
-- @function CreatureDef.on_punch
|
||||||
|
-- @param self
|
||||||
|
-- @tparam ObjectRef puncher
|
||||||
|
-- @param time_from_last_punch Meant for disallowing spamming of clicks.
|
||||||
|
-- @tparam table tool_capabilities See: http://minetest.gitlab.io/minetest/tools.html
|
||||||
|
-- @param dir Unit vector of direction of punch. Always defined. Points from the puncher to the punched.
|
||||||
|
-- @tparam int damage Damage that will be done to entity.
|
||||||
|
-- @treturn bool Prevents default action when returns `true`.
|
||||||
|
|
||||||
|
--- Called when mob is right-clicked.
|
||||||
|
--
|
||||||
|
-- @function CreatureDef.on_rightclick
|
||||||
|
-- @param self
|
||||||
|
-- @tparam ObjectRef clicker Entity that did the punching.
|
||||||
|
-- @treturn bool Prevents default action when returns `true`.
|
||||||
|
|
||||||
|
--- Called when mob dies.
|
||||||
|
--
|
||||||
|
-- @function CreatureDef.on_death
|
||||||
|
-- @param self
|
||||||
|
-- @tparam ObjectRef killer (can be `nil`)
|
||||||
|
|
||||||
|
--- Must return a table to save mob data (serialization is done by MOB-Engine).
|
||||||
|
--
|
||||||
|
-- e.g:
|
||||||
|
--
|
||||||
|
-- return {
|
||||||
|
-- custom_mob_data = self.my_value,
|
||||||
|
-- }
|
||||||
|
--
|
||||||
|
-- @function CreatureDef.get_staticdata
|
||||||
|
-- @param self
|
||||||
|
-- @treturn table
|
||||||
|
Loading…
x
Reference in New Issue
Block a user