176 lines
10 KiB
Plaintext

storage = minetest.get_mod_storage()
hb.settings.max_bar_length = 230 -- hudbars is a bit broken
if false -- moreores support, seems to have been fixed by new submodule
toolranks.add_tool "moreores:pick_mithril"
toolranks.add_tool "moreores:shovel_mithril"
toolranks.add_tool "moreores:sword_mithril"
toolranks.add_tool "moreores:axe_mithril"
toolranks.add_tool "moreores:pick_silver"
toolranks.add_tool "moreores:shovel_silver"
toolranks.add_tool "moreores:sword_silver"
toolranks.add_tool "moreores:axe_silver"
if true -- nssm doesn't know about toolranks
-- literally generated using: grep register_tool nssm/nssm_materials.lua
-- and search+replace
toolranks.add_tool "nssm:sun_sword"
toolranks.add_tool "nssm:masticone_fang_sword"
toolranks.add_tool "nssm:night_sword"
toolranks.add_tool "nssm:crab_light_mace"
toolranks.add_tool "nssm:crab_heavy_mace"
toolranks.add_tool "nssm:mantis_battleaxe"
toolranks.add_tool "nssm:stoneater_pick"
toolranks.add_tool "nssm:mantis_sword"
toolranks.add_tool "nssm:little_ice_tooth_knife"
toolranks.add_tool "nssm:manticore_spine_knife"
toolranks.add_tool "nssm:felucco_knife"
toolranks.add_tool "nssm:ant_sword"
toolranks.add_tool "nssm:ant_shovel"
toolranks.add_tool "nssm:duck_beak_shovel"
toolranks.add_tool "nssm:mantis_axe"
toolranks.add_tool "nssm:ant_billhook"
toolranks.add_tool "nssm:duck_beak_pick"
toolranks.add_tool "nssm:ant_pick"
toolranks.add_tool "nssm:mantis_pick"
toolranks.add_tool "nssm:tarantula_warhammer"
toolranks.add_tool "nssm:axe_of_pride"
toolranks.add_tool "nssm:gratuitousness_battleaxe"
toolranks.add_tool "nssm:sword_of_eagerness"
toolranks.add_tool "nssm:falchion_of_eagerness"
toolranks.add_tool "nssm:sword_of_envy"
toolranks.add_tool "nssm:sword_of_gluttony"
toolranks.add_tool "nssm:death_scythe"
-- can't use toolranks.add_tool for those because hoes handle their own ranking callback
minetest.override_item "farming:ant_hoe", {
original_description: "Ant Hoe",
description: toolranks.create_description "Ant Hoe"}
minetest.override_item "farming:felucco_hoe", {
original_description: "Felucco Hoe",
description: toolranks.create_description "Felucco Hoe"}
if true -- allow cactus damage by shrinking its collision box and enabling "immersed" dps
cactus = WSU.registered "node", "default:cactus"
cactus.collision_box={
type: "fixed",
fixed: {
{-0.1875, -0.5, -0.1875, 0.1875, 0.375, 0.1875},
}
}
cactus.damage_per_second=1
minetest.register_node ":default:cactus", cactus
if true -- fooditems via ugly debug hack, but surprisingly efficient!
ie = minetest.request_insecure_environment!
debug = ie.require 'debug'
scan_item=(name)->
if _hunger_ng
return
ou = minetest.registered_craftitems[name].on_use
if not ou
return
ups = {}
i=1
while true
n, v = debug.getupvalue ou, i
if not n
break
ups[n] = v
i = i + 1
if not ups.hp_change
return
minetest.log 'action','[WBG:modcompat] registering scanned fooditem "%s" with hunger_ng'\format name
hunger_ng.add_hunger_data name, {
heals: math.floor(ups.hp_change/4)
satiates: ups.hp_change
returns: ups.replace_with_item
}
for n,v in pairs minetest.registered_craftitems
scan_item n
if false -- fooditems for nssm
nssm_craftitem_eat=(name,_desc,satiates)->
heals = math.floor(satiates/4)
minetest.log 'action','[WBG:modcompat] registering nssm fooditem "%s" with hunger_ng'\format name
hunger_ng.add_hunger_data "nssm:"..name, {
heals: heals
satiates: satiates
}
nssm_craftitem_eat 'werewolf_leg','Werewolf Leg',3
nssm_craftitem_eat 'felucco_steak','Felucco Steak',3
nssm_craftitem_eat 'roasted_felucco_steak','Roasted Felucco Steak',6
nssm_craftitem_eat 'heron_leg','Moonheron Leg',2
nssm_craftitem_eat 'chichibios_heron_leg',"Chichibio's Moonheron Leg",4
nssm_craftitem_eat 'crocodile_tail','Crocodile Tail',3
nssm_craftitem_eat 'roasted_crocodile_tail','Roasted Crocodile Tail',6
nssm_craftitem_eat 'roasted_werewolf_leg','Roasted_Werewolf Leg',6
nssm_craftitem_eat 'duck_legs','Duck Legs',1
nssm_craftitem_eat 'roasted_duck_legs','Roasted Duck Leg',3
nssm_craftitem_eat 'ant_leg','Ant Leg',-1
nssm_craftitem_eat 'roasted_ant_leg','Roasted Ant Leg',4
nssm_craftitem_eat 'spider_leg','Spider Leg',-1
nssm_craftitem_eat 'roasted_spider_leg','Roasted Spider Leg',4
nssm_craftitem_eat 'tentacle','Tentacle',2
nssm_craftitem_eat 'roasted_tentacle','Roasted Tentacle',5
nssm_craftitem_eat 'worm_flesh','Worm Flesh',-2
nssm_craftitem_eat 'roasted_worm_flesh','Roasted Worm Flesh',4
nssm_craftitem_eat 'amphibian_heart','Amphibian Heart',1
nssm_craftitem_eat 'roasted_amphibian_heart','Roasted Amphibian Heart',8
nssm_craftitem_eat 'raw_scrausics_wing','Raw Scrausics Wing',1
nssm_craftitem_eat 'spicy_scrausics_wing','Spicy Scrausics Wing',6
nssm_craftitem_eat 'phoenix_nuggets','Phoenix Nuggets',20
nssm_craftitem_eat 'phoenix_tear','Phoenix Tear',20
nssm_craftitem_eat 'frosted_amphibian_heart','Frosted Amphibian Heart',-1
nssm_craftitem_eat 'surimi','Surimi',4
nssm_craftitem_eat 'amphibian_ribs','Amphibian Ribs',2
nssm_craftitem_eat 'roasted_amphibian_ribs','Roasted Amphibian Ribs',6
nssm_craftitem_eat 'dolidrosaurus_fin','Dolidrosaurus Fin',-2
nssm_craftitem_eat 'roasted_dolidrosaurus_fin','Roasted Dolidrosaurus Fin',4
nssm_craftitem_eat 'larva_meat','Larva Meat',-1
nssm_craftitem_eat 'larva_juice','Larva Juice',-3
nssm_craftitem_eat 'larva_soup','Larva Soup',10
nssm_craftitem_eat 'mantis_meat','Mantis Meat',1
nssm_craftitem_eat 'roasted_mantis_meat','Roasted Mantis Meat',4
nssm_craftitem_eat 'spider_meat','Spider Meat',-1
nssm_craftitem_eat 'roasted_spider_meat','Roasted Spider Meat',3
nssm_craftitem_eat 'silk_gland','Silk Gland',-1
nssm_craftitem_eat 'roasted_silk_gland','Roasted Silk Gland',3
nssm_craftitem_eat 'super_silk_gland','Super Silk Gland',-8
nssm_craftitem_eat 'roasted_super_silk_gland','Roasted Super Silk Gland',2
if false -- register hunger data for any other items, undoing the "keep out of other mods' way" policy of hunger_ng
-- don't ask, srsly...
--file = io.open minetest.get_modpath('wbg_modcompat')..'/loaditems.txt', 'w'
--file\write storage\get_string 'fallback_hunger_items'
--file\close!
bbqitems={["bbq:smoked_pepper"]: {["heals"]: 1, ["satiates"]: 5}, ["bbq:pickled_peppers"]: {["heals"]: 1, ["satiates"]: 5}, ["bbq:stuffed_chop"]: {["heals"]: 2, ["satiates"]: 8}, ["bbq:bacon"]: {["heals"]: 1, ["satiates"]: 7}, ["bbq:pepper_steak_raw"]: {["heals"]: 1, ["satiates"]: 4}, ["bbq:leg_lamb"]: {["heals"]: 2, ["satiates"]: 9}, ["bbq:ham"]: {["heals"]: 2, ["satiates"]: 9}, ["bbq:rack_lamb_raw"]: {["heals"]: 1, ["satiates"]: 5}, ["bbq:sugar"]: {["heals"]: 0, ["satiates"]: 2}, ["bbq:bbq_chicken_raw"]: {["heals"]: 1, ["satiates"]: 4}, ["bbq:veggie_kebab_raw"]: {["heals"]: 1, ["satiates"]: 4}, ["bbq:stuffed_mushroom_raw"]: {["heals"]: 1, ["satiates"]: 5}, ["bbq:beef"]: {["heals"]: 2, ["satiates"]: 8}, ["bbq:pepper_steak"]: {["heals"]: 2, ["satiates"]: 10}, ["bbq:bacon_cheeseburger"]: {["heals"]: 2, ["satiates"]: 9}, ["bbq:corned_beef_raw"]: {["heals"]: 1, ["satiates"]: 5}, ["bbq:hamburger_patty_raw"]: {["heals"]: 0, ["satiates"]: 3}, ["bbq:stuffed_chop_raw"]: {["heals"]: 0, ["satiates"]: 3}, ["bbq:grilled_tomato"]: {["heals"]: 1, ["satiates"]: 5}, ["bbq:grilled_pizza"]: {["heals"]: 2, ["satiates"]: 8}, ["bbq:veggie_packet_raw"]: {["heals"]: 1, ["satiates"]: 4}, ["bbq:grilled_pizza_raw"]: {["heals"]: 1, ["satiates"]: 5}, ["bbq:bbq_beef_ribs_raw"]: {["heals"]: 1, ["satiates"]: 4}, ["bbq:brisket_raw"]: {["heals"]: 1, ["satiates"]: 4}, ["bbq:beef_raw"]: {["heals"]: 0, ["satiates"]: 3}, ["bbq:stuffed_pepper"]: {["heals"]: 2, ["satiates"]: 9}, ["bbq:stuffed_mushroom"]: {["heals"]: 2, ["satiates"]: 9}, ["bbq:hot_wings_raw"]: {["heals"]: 0, ["satiates"]: 3}, ["bbq:beef_jerky_raw"]: {["heals"]: 0, ["satiates"]: 2}, ["bbq:stuffed_pepper_raw"]: {["heals"]: 1, ["satiates"]: 4}, ["bbq:cheese_steak"]: {["heals"]: 2, ["satiates"]: 8}, ["bbq:rack_lamb"]: {["heals"]: 2, ["satiates"]: 10}, ["bbq:pulled_pork"]: {["heals"]: 2, ["satiates"]: 8}, ["bbq:london_broil_raw"]: {["heals"]: 0, ["satiates"]: 3}, ["bbq:beef_jerky"]: {["heals"]: 1, ["satiates"]: 5}, ["bbq:corned_beef"]: {["heals"]: 2, ["satiates"]: 10}, ["bbq:hotdog_cooked"]: {["heals"]: 1, ["satiates"]: 7}, ["bbq:london_broil"]: {["heals"]: 1, ["satiates"]: 7}, ["bbq:hotdog_raw"]: {["heals"]: 0, ["satiates"]: 3}, ["bbq:hamburger_patty"]: {["heals"]: 2, ["satiates"]: 8}, ["bbq:bacon_raw"]: {["heals"]: 0, ["satiates"]: 3}, ["bbq:veggie_kebab"]: {["heals"]: 2, ["satiates"]: 8}, ["bbq:portebello_steak_raw"]: {["heals"]: 1, ["satiates"]: 5}, ["bbq:tomato_sauce"]: {["heals"]: 0, ["satiates"]: 2}, ["bbq:bbq_beef_ribs"]: {["heals"]: 2, ["satiates"]: 9}, ["bbq:lamb_kebab_raw"]: {["heals"]: 0, ["satiates"]: 2}, ["bbq:hamburger"]: {["heals"]: 2, ["satiates"]: 9}, ["bbq:veggie_packet"]: {["heals"]: 1, ["satiates"]: 5}, ["bbq:bbq_chicken"]: {["heals"]: 2, ["satiates"]: 8}, ["bbq:lamb_kebab"]: {["heals"]: 1, ["satiates"]: 4}, ["bbq:ham_raw"]: {["heals"]: 1, ["satiates"]: 4}, ["bbq:hotdog"]: {["heals"]: 2, ["satiates"]: 8}, ["bbq:beer"]: {["heals"]: 1, ["satiates"]: 6}, ["bbq:hot_wings"]: {["heals"]: 2, ["satiates"]: 8}, ["bbq:grilled_corn"]: {["heals"]: 2, ["satiates"]: 8}, ["bbq:grilled_corn_raw"]: {["heals"]: 1, ["satiates"]: 5}, ["bbq:portebello_steak"]: {["heals"]: 2, ["satiates"]: 9}, ["bbq:brisket"]: {["heals"]: 2, ["satiates"]: 9}, ["bbq:leg_lamb_raw"]: {["heals"]: 1, ["satiates"]: 4}}
loaditems = minetest.deserialize storage\get_string 'fallback_hunger_items'
if not loaditems
loaditems = {}
for name, data in pairs bbqitems
loaditems[name]=data
for name, data in pairs loaditems
minetest.log 'action','[WBG:modcompat] registering loaded fooditem "%s" with hunger_ng'\format name
hunger_ng.add_hunger_data name, data
minetest.register_on_item_eat (hp_change, replace_with_item, itemstack, user, pointed_thing)->
definition = itemstack\get_definition!._hunger_ng
if definition
return false
name = itemstack\get_name!
data = {
heals: math.floor(hp_change / 4)
satiates: hp_change
}
loaditems[name]=data
hunger_ng.add_hunger_data name, data
minetest.log 'warning','[WBG:modcompat] registering new fooditem "%s" with hunger_ng'\format name
storage\set_string 'fallback_hunger_items', minetest.serialize loaditems