This repository has been archived by the owner on Dec 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
API.txt
210 lines (182 loc) · 10 KB
/
API.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
Creatures MOB-Engine API
------------------------
creatures.register_mob(#Creature definition)
-registers a mob at MOB-Engine; returns true when sucessfull
creatures.register_alias(old_mob, new_mob) -- returns true if sucessfull
-registers an alias for other mob, e.g. from other mods or removed ones.
existent entities (MOBs), Spawners and Spawn Eggs are converted;
returns true when sucessfull
^ old_mob: name as string, e.g. "creatures:oerrki"
^ new_mob: name as string, e.g. "creatures:oerkki"
^ example: creatures.register_alias("creatures:oerrki", "creatures:oerkki")
creatures.rnd(chance_table)
-returns a weighted random table element; chance_sum of table must be 1
^ example: creatures.rnd({elem1 = {chance = 0.7}, {elem2 = {chance = 0.3}})
creatures.compare_pos(pos1, pos2)
-returns true if pos1 == pos2
creatures.findTarget(search_obj, pos, radius, search_type, mob_name, xray, no_count)
-returns table of found objects (as ObjectRef) and boolean player_near
^ search_obj is searching object; can be nil
^ pos is starting position for search radius
^ radius for searching in blocks/node
^ search_type that specifies returned object requirements
^ "all" -- returns every object except dropped Items
^ "hostile" -- returns every object(creature) that has hostile setting or is player
^ ignores "mob_type" if specified
^ "nonhostile" -- returns every object that is not hostile or player
^ "player" -- returns all players
^ "mates" -- returns all objects(creatures) that are of same kind
^ requires "mob_type" specifies
^ mob_type specifies creature that is ignored or searched, depending on search_type
^ xray allows searching through blocks/nodes (default == false)
^ no_count skips collecting loop and returns just the boolean player_near
^ table is empty
creatures.dropItems(pos, drops)
-drops items at position pos
^ pos where to drop Items
^ drops table in #ItemDrops format
#ItemDrops
----------
{
{
<Itemname>, -- e.g. "default:wood"
<amount>, -- either a <number> or table in format {min = <number>, max = <number>}; optional
<rarity> -- "chance = <value>": <value> between 0.0 and 1.0
},
}
Example:
Will drop with a chance of 30% 1 to 3 items of type "default:wood"
and with a chance of 100% 2 items of type "default:stone"
{
{"default:wood", {min = 1, max = 3}, chance = 0.3},
{"default:stone", 2}
}
#Creature definition
--------------------
{
name = "", -- e.g. "creatures:sheep"
stats = {
hp = 1, -- 1 HP = "1/2 player heart"
hostile = false, -- is mob hostile (required for mode "attack") <optional>
lifetime = 300, -- after which time mob despawns, in seconds <optional>
dies_when_tamed = false, -- stop despawn when tamed <optional>
can_jump = 1, -- height in nodes <optional>
can_swim = false, -- can mob swim or will it drown <optional>
can_fly = false, -- allows to fly (requires mode "fly") and disable step sounds <optional>
can_burn = false, -- takes damage of lava <optional>
can_panic = false, -- runs fast around when hit (requires mode "walk") <optional>
has_falldamage = false, -- deals damage if falling more than 3 blocks <optional>
has_kockback = false, -- get knocked back when hit <optional>
sneaky = false, -- disables step sounds <optional>
light = {min, max}, -- which light level will burn creature (requires can_burn = true) <optional>
},
modes = {
idle = {chance = <part of 1.0>, duration = <time>, moving_speed = <number>, update_yaw = <yawtime>},
^ 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
^ duration -- time in seconds until the next mode is chosen (depending on chance)
^ moving_speed -- moving speed(flying/walking) <optional>
^ update_yaw -- timer in seconds until the looking dir is changed <optional>
^ if moving_speed > 0 then the moving direction is also changed
-- special modes
attack = {<same as above>}
follow = {<same as above>, radius = <number>, timer = <time>, items = <table>},
^ same as above -- all possible values like specified above
^ radius -- search distance in blocks/nodes for player
^ timer -- time in seconds between each check for player
^ items -- table of items to make mob follow in format {<Itemname>, <Itemname>}; e.g. {"farming:wheat"}
eat = {<same as above>, nodes = <table>},
^ same as above -- all possible values like specified above
^ items -- eatable nodes in format {<Itemname>, <Itemname>}; e.g. {"default:dirt_with_grass"}
},
model = {
mesh = "creatures_sheep.x", -- mesh name; see Minetest Documentation for supported filetypes
textures = {"creatures_sheep.png"}, -- table of textures; see Minetest Documentation
collisionbox = <NodeBox>, -- defines mesh collision box; see Minetest Documentation
rotation = 0.0, -- sets rotation offset when moving
backface_culling = false, -- set true to enable backface culling
animations = { -- animation used if defined <optional>
idle = {#AnimationDef}, -- see #AnimationDef
... -- depends on modes (must correspond to be used);
^ supported "special modes": eat, follow, attack, death, swim, panic
},
},
sounds = {
on_damage = {#SoundDef}, -- see #SoundDef <optional>
on_death = {#SoundDef}, -- see #SoundDef <optional>
swim = {#SoundDef}, -- see #SoundDef <optional>
random = { -- depends on mode <optional>
idle = {#SoundDef}, -- <optional>
... -- depends on modes (must correspond to be used); supports "special modes": eat, follow, attack
},
},
drops = {#ItemDrops}, -- see #ItemDrops definition <optional>
^ can also be a function; receives "self" reference
combat = { -- specifies behavior of hostile mobs in "attack" mode
attack_damage = 1, -- how much damage deals each hit
attack_speed = 0.6, -- time in seconds between hits
attack_radius = 1.1, -- distance in blocks mob can reach to hit
search_enemy = true, -- true to search enemies to attack
search_timer = 2, -- time in seconds to search an enemy (only if none found yet)
search_radius = 12, -- radius in blocks within enemies are searched
search_type = "player", -- what enemy is being searched (see types at creatures.findTarget())
}
spawning = { -- defines spawning in world <optional>
abm_nodes = {
spawn_on = {<table>}, -- on what nodes mob can spawn <optional>
^ table -- nodes and groups in table format; e.g. {"group:stone", "default:stone"}
neighbors = {}, -- what node should be neighbors to spawnnode <optional>
^ can be nil or table as above; "air" is forced always as neighbor
},
abm_interval = <interval>, -- time in seconds until Minetest tries to find a node with set specs
abm_chance = <chance>, -- chance is 1/<chance>
max_number = <number>, -- maximum mobs of this kind per mapblock(16x16x16)
number = <amount>, -- how many mobs are spawned if found suitable spawn position
^ amount -- number or table {min = <value>, max = <value>}
time_range = <range>, -- time range in time of day format (0-24000) <optional>
^ range -- table {min = <value>, max = <value>}
light = <range>, -- min and max lightvalue at spawn position <optional>
^ range -- table {min = <value>, max = <value>}
height_limit = <range>, -- min and max height (world Y coordinate) <optional>
^ range -- table {min = <value>, max = <value>}
spawn_egg = { -- is set a spawn_egg is added to creative inventory <optional>
description = <desc>, -- Item description as string
texture = <name>, -- texture name as string
},
spawner = { -- is set a spawner_node is added to creative inventory <optional>
range = <number>, -- defines an area (in blocks/nodes) within mobs are spawned
number = <number>, -- maxmimum number of mobs spawned in area defined via range
description = <desc>, -- Item description as string <optional>
light = <range>, -- min and max lightvalue at spawn position <optional>
^ range -- table {min = <value>, max = <value>}
}
},
on_rightclick = func(self, clicker) -- called when mob is rightclicked
^ prevents default action when returns boolean true
on_punch = func(self, puncher) -- called when mob is punched (puncher can be nil)
^ prevents default action when returns boolean true
on_step = func(self, dtime) -- called each server step
^ prevents default action when returns boolean true
on_activate = func(self, staticdata) -- called when mob (re-)actived
^ Note: staticdata is deserialized by MOB-Engine (including costum values)
get_staticdata = func(self) -- called when mob is punched (puncher can be nil)
^ must return a table to save mob data (serialization is done by MOB-Engine)
^ e.g:
return {
costum_mob_data = self.my_value,
}
}
#AnimationDef {
start = 0, -- animation start frame
stop = 80, -- animation end frame
speed = 15, -- animation speed
loop = true, -- if false, animation if just played once <optional>
duration = 1 -- only supported in "death"-Animation, sets time the animation needs until mob is removed <optional>
}
#SoundDef {
name = <name>, -- sound name as string; see Minetest documentation
gain = 1.0, -- sound gain; see Minetest documentation
distance = <number>, -- hear distance in blocks/nodes <optional>
time_min = <time> -- minimum time in seconds between sounds (random only) <optional>
time_max = <time> -- maximum time in seconds between sounds (random only) <optional>
}