1
0
Fork 0

add flavor text, code clean up

Changed to have the flavor text to give it character.
Fixed misspellings.
Cleaned up the code from the initial commit.
Changed from API to single item.
Fixed the mod name, so that it matches "mcl_" format.

Added comments.
This commit is contained in:
Michieal 2022-11-16 00:34:38 +00:00 committed by cora
parent ce95f034b4
commit 83b40f8cff
1 changed files with 37 additions and 42 deletions

View File

@ -7,17 +7,18 @@
if not minetest.settings:get_bool("mcl_enable_hamburger",true) then return end if not minetest.settings:get_bool("mcl_enable_hamburger",true) then return end
local S = minetest.get_translator("hamburger_mod") local S = minetest.get_translator("mcl_hamburger")
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname) local modpath = minetest.get_modpath(modname)
local table = table local table = table
local DEBUG = false local DEBUG = false
hamburger_mod = {}
-- quick api for hamburgers. call to register your hamburger. mcl_hamburger = {}
function hamburger_mod.register_burger_craft( hamburger_item, cooked_meat, use_alt)
-- call to register your hamburger.
function mcl_hamburger.register_burger_craft(cooked_meat, use_alt)
if use_alt == nil or use_alt == "" then if use_alt == nil or use_alt == "" then
use_alt = false use_alt = false
@ -25,63 +26,57 @@ function hamburger_mod.register_burger_craft( hamburger_item, cooked_meat, use_a
minetest.register_craft({ minetest.register_craft({
type = "fuel", type = "fuel",
recipe = "hamburger_mod:hamburger" .. hamburger_item, recipe = "mcl_hamburger:hamburger",
burntime = 2, burntime = 2,
}) })
-- register crafts (actual recipe) -- register crafts (actual recipe)
if minetest.get_modpath(modname) then if minetest.get_modpath(modname) then
local itemstring = "hamburger_mod:hamburger" local itemstring = "mcl_hamburger:hamburger"
minetest.register_craft({ minetest.register_craft({
output = itemstring .. hamburger_item, output = itemstring,
recipe = { recipe = {
{ "mcl_farming:bread"}, { "mcl_farming:bread"},
{ cooked_meat }, -- "mcl_mobitems:cooked_beef" for a reg hamburger. grind up clowns for a McDonald's hambeurger { cooked_meat }, -- "mcl_mobitems:cooked_beef" for a reg hamburger. Grind up clowns for a Big Mac.
{ "mcl_farming:bread" }, { "mcl_farming:bread" },
}, },
}) })
end end
if use_alt == false then local hamburger_def = {
minetest.register_craftitem("hamburger_mod:hamburger" .. hamburger_item, { description = S("A Hamburger"),
description = S("Hamburger"), _doc_items_longdesc = S("A tasty hamburger that is sure to lure villagers around like a lead. Can be eaten."),
_doc_items_longdesc = S("A tasty hamburger that is sure to lure villagers around like a LEASH. Can be eaten."), _doc_items_usagehelp = S("wield this item to pull villagers to you."),
_doc_items_usagehelp = S("wield this item to pull villagers to you."), _tt_help = S("A tasty hamburger that is sure to lure villagers.\n'I'll gladly pay you Tuesday, for a hamburger today.' - Wimpy."),
_tt_help = S("A tasty hamburger that is sure to lure villagers"), inventory_image = "hamburger.png",
inventory_image = "hamburger.png", wield_image = "hamburger.png",
wield_image = "hamburger.png", on_place = minetest.item_eat(8),
on_place = minetest.item_eat(8), on_secondary_use = minetest.item_eat(8),
on_secondary_use = minetest.item_eat(8), groups = { food = 2, eatable = 8 },
groups = { food = 2, eatable = 8 }, _mcl_saturation = 12.8,
_mcl_saturation = 12.8, stack_max = 64,
stack_max = 64, }
})
else if use_alt == false then
minetest.register_craftitem("hamburger_mod:hamburger" .. hamburger_item, { minetest.register_craftitem("mcl_hamburger:hamburger", hamburger_def)
description = S("Hamburger"), else
_doc_items_longdesc = S("A tasty hamburger that is sure to lure villagers around like a LEASH. Can be eaten."), local hamburger_alt = table.copy(hamburger_def)
_doc_items_usagehelp = S("wield this item to pull villagers to you."), hamburger_alt.inventory_image = "mcl_hamburger_hamburger_alt.png"
_tt_help = S("A tasty hamburger that is sure to lure villagers"), hamburger_alt.wield_image = "mcl_hamburger_hamburger_alt.png"
inventory_image = "hamburger_alt.png", minetest.register_craftitem("mcl_hamburger:hamburger", hamburger_alt)
wield_image = "hamburger_alt.png", end
on_place = minetest.item_eat(8),
on_secondary_use = minetest.item_eat(8),
groups = { food = 2, eatable = 8 },
_mcl_saturation = 12.8,
stack_max = 64,
})
end
end -- make the villagers follow the item
minetest.registered_entities["mobs_mc:villager"].nofollow = false
-- make the villagers follow the hamburger item -- register the item and crafting recipe.
minetest.registered_entities["mobs_mc:villager"].nofollow = nil mcl_hamburger.register_burger_craft( "", "mcl_mobitems:cooked_beef")
hamburger_mod.register_burger_craft( "", "mcl_mobitems:cooked_beef") -- add it to the follow items.
table.insert(minetest.registered_entities["mobs_mc:villager"].follow,"hamburger_mod:hamburger") table.insert(minetest.registered_entities["mobs_mc:villager"].follow,"mcl_hamburger:hamburger")
if DEBUG then if DEBUG then
minetest.log (dump(minetest.registered_entities["mobs_mc:villager"].follow)) minetest.log (dump(minetest.registered_entities["mobs_mc:villager"].follow))