Fix some errors

master
Jordan Irwin 2021-05-05 06:39:10 -07:00
parent 3f7b1bff0b
commit a6b5acf195
3 changed files with 10 additions and 7 deletions

13
api.lua
View File

@ -31,10 +31,10 @@
--- Adds a craft recipe for an egg. --- Adds a craft recipe for an egg.
-- --
-- @function as.addEggRecipe -- @function asm.addEggRecipe
-- @param name Name of spawnegg that will be created from recipe. -- @param name Name of spawnegg that will be created from recipe.
-- @param ingredients Items used for recipe in addition to `spawneggs:egg`. Can be string or list. -- @param ingredients Items used for recipe in addition to `spawneggs:egg`. Can be string or list.
asm.addEggRecipe = function(name, spawn, ingredients) asm.addEggRecipe = function(name, ingredients)
if type(ingredients) == "string" then if type(ingredients) == "string" then
ingredients = {ingredients,} ingredients = {ingredients,}
end end
@ -58,7 +58,7 @@ asm.registerEgg = function(def)
img = def.inventory_image img = def.inventory_image
end end
core.register_craftitem(":spawneggs:" .. def.name, { core.register_craftitem(":spawneggs:" .. def.name:lower(), {
description = def.name:gsub("^%l", string.upper) .. " Spawn Egg", description = def.name:gsub("^%l", string.upper) .. " Spawn Egg",
inventory_image = img, inventory_image = img,
@ -81,10 +81,12 @@ asm.registerEgg = function(def)
end end
}) })
asm.addEggRecipe(name, spawn, ingredients) if def.ingredients then
asm.addEggRecipe(def.name:lower(), def.ingredients)
end
-- DEBUG -- DEBUG
asm.log("action", "Registered spawnegg for " .. spawn) asm.log("action", "Registered spawnegg for " .. def.spawn)
end end
--- Alias for `asm.registerEgg`. --- Alias for `asm.registerEgg`.
@ -99,3 +101,4 @@ asm.addEgg = asm.registerEgg
-- @field name Human readable name. -- @field name Human readable name.
-- @field inventory_image Image displayed in inventory. -- @field inventory_image Image displayed in inventory.
-- @field spawn Entity that will be spawned from egg. -- @field spawn Entity that will be spawned from egg.
-- @field ingredients Ingredients to us, in addition to `spawneggs:egg`, to register craft recipe (optional).

View File

@ -38,7 +38,7 @@ asm.log = function(lvl, msg)
if lvl then if lvl then
core.log(lvl, "[" .. asm.modname .. "] " .. msg) core.log(lvl, "[" .. asm.modname .. "] " .. msg)
else else
core.log("[" ams.modname .. "] " .. msg) core.log("[" .. ams.modname .. "] " .. msg)
end end
end end

View File

@ -28,4 +28,4 @@
core.register_craftitem(":spawneggs:egg", { core.register_craftitem(":spawneggs:egg", {
description = "Spawning Egg", description = "Spawning Egg",
inventory_image = "spawneggs_egg.png", inventory_image = "spawneggs_egg.png",
} })