Add method to retrieve registered eggs by entity name
This commit is contained in:
parent
8579eac823
commit
5a72143d90
@ -1,4 +1,8 @@
|
||||
|
||||
1.2
|
||||
- Added method to retrieve registered egg by entity name.
|
||||
|
||||
|
||||
1.1
|
||||
- Egg names are titleized & underscores are replaced with space.
|
||||
|
||||
|
19
api.lua
19
api.lua
@ -29,6 +29,18 @@
|
||||
-- @module api.lua
|
||||
|
||||
|
||||
local registered_eggs = {}
|
||||
|
||||
--- Retrieves egg that spawns specified entity.
|
||||
--
|
||||
-- @function asm.getEgg
|
||||
-- @tparam string entity Entity name spawned by egg.
|
||||
-- @treturn string Egg name or `nil`.
|
||||
function asm.getEgg(entity)
|
||||
return registered_eggs[entity]
|
||||
end
|
||||
|
||||
|
||||
--- Adds a craft recipe for an egg.
|
||||
--
|
||||
-- Alias: *asm.addEggRecipe*
|
||||
@ -83,7 +95,9 @@ asm.registerEgg = function(def)
|
||||
title = formatTitle(def.name)
|
||||
end
|
||||
|
||||
core.register_craftitem(":spawneggs:" .. def.name:lower(), {
|
||||
local egg_name = "spawneggs:" .. def.name:lower()
|
||||
|
||||
core.register_craftitem(":" .. egg_name, {
|
||||
description = title,
|
||||
inventory_image = img,
|
||||
|
||||
@ -106,6 +120,9 @@ asm.registerEgg = function(def)
|
||||
end
|
||||
})
|
||||
|
||||
-- store registration
|
||||
registered_eggs[def.spawn] = egg_name
|
||||
|
||||
if def.ingredients then
|
||||
asm.registerEggRecipe(def.name:lower(), def.ingredients)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user