Cleanup brewing stand code. Add lingering base structure add splash river water and water.

This commit is contained in:
Brandon 2020-06-18 07:43:50 -04:00
parent 3a361d4418
commit 64cd19218f
4 changed files with 208 additions and 41 deletions

View File

@ -134,6 +134,7 @@ local function brewing_stand_timer(pos, elapsed)
-- return 1
-- end
-- end
local brew_output = brewable(inv)
if fuel ~= 0 and brew_output then
@ -286,13 +287,9 @@ if minetest.get_modpath("screwdriver") then
end
local doc_string =
S("To use an brewing_stand, rightclick it. An brewing_stand has 2 input slots (on the left) and one output slot.").."\n"..
S("To rename items, put an item stack in one of the item slots while keeping the other input slot empty. Type in a name, hit enter or “Set Name”, then take the renamed item from the output slot.").."\n"..
S("There are two possibilities to repair tools (and armor):").."\n"..
S("• Tool + Tool: Place two tools of the same type in the input slots. The “health” of the repaired tool is the sum of the “health” of both input tools, plus a 12% bonus.").."\n"..
S("• Tool + Material: Some tools can also be repaired by combining them with an item that it's made of. For example, iron pickaxes can be repaired with iron ingots. This repairs the tool by 25%.").."\n"..
S("Armor counts as a tool. It is possible to repair and rename a tool in a single step.").."\n\n"..
S("The brewing_stand has limited durability and 3 damage levels: undamaged, slightly damaged and very damaged. Each time you repair or rename something, there is a 12% chance the brewing_stand gets damaged. brewing_stand also have a chance of being damaged when they fall by more than 1 block. If a very damaged brewing_stand is damaged again, it is destroyed.")
S("To use an brewing_stand, rightclick it.").."\n"
S("To brew, place fuel first and/or your ingredient last!")
local tiles = {"mcl_brewing_top.png", --top
"mcl_brewing_base.png", --bottom
"mcl_brewing_side.png", --right
@ -424,8 +421,6 @@ minetest.register_node("mcl_brewing:stand_000", {
inv:set_size("input", 1)
inv:set_size("fuel", 1)
inv:set_size("stand", 3)
-- inv:set_size("stand2", 1)
-- inv:set_size("stand3", 1)
local form = brewing_formspec
meta:set_string("formspec", form)
end,
@ -511,8 +506,6 @@ minetest.register_node("mcl_brewing:stand_100", {
inv:set_size("input", 1)
inv:set_size("fuel", 1)
inv:set_size("stand", 3)
-- inv:set_size("stand2", 1)
-- inv:set_size("stand3", 1)
local form = brewing_formspec
meta:set_string("formspec", form)
end,
@ -597,8 +590,6 @@ minetest.register_node("mcl_brewing:stand_010", {
inv:set_size("input", 1)
inv:set_size("fuel", 1)
inv:set_size("stand", 3)
-- inv:set_size("stand2", 1)
-- inv:set_size("stand3", 1)
local form = brewing_formspec
meta:set_string("formspec", form)
end,
@ -683,8 +674,6 @@ minetest.register_node("mcl_brewing:stand_001", {
inv:set_size("input", 1)
inv:set_size("fuel", 1)
inv:set_size("stand", 3)
-- inv:set_size("stand2", 1)
-- inv:set_size("stand3", 1)
local form = brewing_formspec
meta:set_string("formspec", form)
end,
@ -769,8 +758,6 @@ minetest.register_node("mcl_brewing:stand_110", {
inv:set_size("input", 1)
inv:set_size("fuel", 1)
inv:set_size("stand", 3)
-- inv:set_size("stand2", 1)
-- inv:set_size("stand3", 1)
local form = brewing_formspec
meta:set_string("formspec", form)
end,
@ -855,8 +842,6 @@ minetest.register_node("mcl_brewing:stand_101", {
inv:set_size("input", 1)
inv:set_size("fuel", 1)
inv:set_size("stand", 3)
-- inv:set_size("stand2", 1)
-- inv:set_size("stand3", 1)
local form = brewing_formspec
meta:set_string("formspec", form)
end,
@ -941,8 +926,6 @@ minetest.register_node("mcl_brewing:stand_011", {
inv:set_size("input", 1)
inv:set_size("fuel", 1)
inv:set_size("stand", 3)
-- inv:set_size("stand2", 1)
-- inv:set_size("stand3", 1)
local form = brewing_formspec
meta:set_string("formspec", form)
end,
@ -1027,8 +1010,6 @@ minetest.register_node("mcl_brewing:stand_111", {
inv:set_size("input", 1)
inv:set_size("fuel", 1)
inv:set_size("stand", 3)
-- inv:set_size("stand2", 1)
-- inv:set_size("stand3", 1)
local form = brewing_formspec
meta:set_string("formspec", form)
end,
@ -1052,15 +1033,3 @@ minetest.register_craft({
{ "mcl_core:stone_smooth", "mcl_core:stone_smooth", "mcl_core:stone_smooth" },
}
})
-- Legacy
minetest.register_lbm({
label = "Update brewing_stand formspecs (0.60.0",
name = "mcl_brewing:update_formspec_0_60_0",
--nodenames = { "group:brewing_stand" },
run_at_every_load = false,
action = function(pos, node)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", brewing_formspec)
end,
})

View File

@ -4,6 +4,7 @@ mcl_potions = {}
local modpath = minetest.get_modpath("mcl_potions")
dofile(modpath .. "/functions.lua")
dofile(modpath .. "/splash.lua")
dofile(modpath .. "/lingering.lua")
dofile(modpath .. "/potions.lua")
local brewhelp = S("Put this item in an item frame for decoration. It's useless otherwise.")
@ -93,9 +94,9 @@ minetest.register_craftitem("mcl_potions:glass_bottle", {
-- place the water potion at a place where's space
local water_bottle
if river_water then
water_bottle = ItemStack("mcl_potions:potion_river_water")
water_bottle = ItemStack("mcl_potions:river_water")
else
water_bottle = ItemStack("mcl_potions:potion_water")
water_bottle = ItemStack("mcl_potions:water")
end
local inv = placer:get_inventory()
if creative then
@ -166,7 +167,7 @@ end
-- Itemstring of potions is “mcl_potions:potion_<NBT Potion Tag>”
minetest.register_craftitem("mcl_potions:potion_water", {
minetest.register_craftitem("mcl_potions:water", {
description = S("Water Bottle"),
_tt_help = S("No effect"),
_doc_items_longdesc = S("Water bottles can be used to fill cauldrons. Drinking water has no effect."),
@ -211,7 +212,7 @@ minetest.register_craftitem("mcl_potions:potion_water", {
on_secondary_use = minetest.item_eat(0, "mcl_potions:glass_bottle"),
})
minetest.register_craftitem("mcl_potions:potion_river_water", {
minetest.register_craftitem("mcl_potions:river_water", {
description = S("River Water Bottle"),
_tt_help = S("No effect"),
_doc_items_longdesc = S("River water bottles can be used to fill cauldrons. Drinking it has no effect."),
@ -306,8 +307,8 @@ local awkward_table = {
}
local output_table = {
["mcl_potions:potion_river_water"] = water_table,
["mcl_potions:potion_water"] = water_table,
["mcl_potions:river_water"] = water_table,
["mcl_potions:water"] = water_table,
["mcl_potions:awkward"] = awkward_table,
}
@ -366,6 +367,12 @@ for i, potion in ipairs(potions) do
lingering_table["mcl_potions:"..potion.."_splash"] = "mcl_potions:"..potion.."_lingering"
end
splash_table["mcl_potions:water"] = "mcl_potions:water_splash"
splash_table["mcl_potions:river_water"] = "mcl_potions:river_water_splash"
lingering_table["mcl_potions:water_splash"] = "mcl_potions:lingering"
lingering_table["mcl_potions:river_water_splash"] = "mcl_potions:lingering"
local mod_table = {
["mesecons:wire_00000000_off"] = extension_table,
["mcl_potions:fermented_spider_eye"] = inversion_table,

View File

@ -0,0 +1,183 @@
local lingering_image = function(colorstring, opacity)
if not opacity then
opacity = 127
end
return "mcl_potions_splash_overlay.png^[colorize:"..colorstring..":"..tostring(opacity).."^mcl_potions_splash_bottle.png"
end
local function register_lingering(name, descr, color, def)
local id = "mcl_potions:"..name.."_lingering"
minetest.register_craftitem(id, {
description = descr,
inventory_image = lingering_image(color),
on_use = function(item, placer, pointed_thing)
--weapons_shot(itemstack, placer, pointed_thing, def.velocity, name)
local velocity = 10
local dir = placer:get_look_dir();
local pos = placer:getpos();
local obj = minetest.env:add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying")
obj:setvelocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity})
obj:setacceleration({x=0, y=-9.8, z=0})
item:take_item()
return item
end,
stack_max = 1,
})
local w = 0.7
minetest.register_entity(id.."_flying",{
textures = {lingering_image(color)},
hp_max = 1,
visual_size = {x=w/2,y=w/2},
collisionbox = {0,0,0,0,0,0},
on_step = function(self, dtime)
local pos = self.object:getpos()
local node = minetest.get_node(pos)
local n = node.name
local d = 2
local redux_map = {7/8,0.5,0.25}
if n ~= "air" then
minetest.sound_play("mcl_potions_breaking_glass")
minetest.add_particlespawner({
amount = 100,
time = 30,
minpos = {x=pos.x-d, y=pos.y, z=pos.z-d},
maxpos = {x=pos.x+d, y=pos.y+1, z=pos.z+d},
minvel = {x=-0.5, y=0, z=-0.5},
maxvel = {x=0.5, y=0.5, z=0.5},
minacc = {x=-0.25, y=0, z=-0.25},
maxacc = {x=0.25, y=.1, z=0.25},
minexptime = 1,
maxexptime = 5,
minsize = 2,
maxsize = 4,
collisiondetection = false,
vertical = false,
texture = "mcl_potions_sprite.png^[colorize:"..color..":127",
})
self.object:remove()
for i, obj in ipairs(minetest.get_objects_inside_radius(pos, 4)) do
if minetest.is_player(obj) then
pos2 = obj:get_pos()
local rad = math.floor(math.sqrt((pos2.x-pos.x)^2 + (pos2.y-pos.y)^2 + (pos2.z-pos.z)^2))
if rad > 0 then def.potion_fun(obj, redux_map[rad]) else def.potion_fun(obj, 1) end
end
end
end
end,
})
end
register_lingering("water", "Lingering Water", "#0000FF", {
potion_fun = function(player, redx) end,
})
register_lingering("river_water", "Lingering River Water", "#0000FF", {
potion_fun = function(player, redx) end,
})
register_lingering("awkward", "Lingering Awkward Potion", "#0000FF", {
potion_fun = function(player, redx) end,
})
register_lingering("mundane", "Lingering Mundane Potion", "#0000FF", {
potion_fun = function(player, redx) end,
})
register_lingering("thick", "Lingering Thick Potion", "#0000FF", {
potion_fun = function(player, redx) end,
})
register_lingering("healing", "Lingering Healing", "#AA0000", {
potion_fun = function(player, redx) player:set_hp(player:get_hp() + 3*redx) end,
})
register_lingering("healing_2", "Lingering Healing II", "#DD0000", {
potion_fun = function(player, redx) player:set_hp(player:get_hp() + 6*redx) end,
})
register_lingering("harming", "Lingering Harming", "#660099", {
potion_fun = function(player, redx) mcl_potions.healing_func(player, -4*redx) end,
})
register_lingering("harming_2", "Lingering Harming II", "#330066", {
potion_fun = function(player, redx) mcl_potions.healing_func(player, -6*redx) end,
})
register_lingering("leaping", "Lingering Leaping", "#00CC33", {
potion_fun = function(player, redx) mcl_potions.leaping_func(player, 1.2, 135*redx) end
})
register_lingering("leaping_2", "Lingering Leaping II", "#00EE33", {
potion_fun = function(player, redx) mcl_potions.leaping_func(player, 1.4, 135*redx) end
})
register_lingering("leaping_plus", "Lingering Leaping +", "#00DD33", {
potion_fun = function(player, redx) mcl_potions.leaping_func(player, 1.2, 360*redx) end
})
register_lingering("swiftness", "Lingering Swiftness", "#009999", {
potion_fun = function(player, redx) mcl_potions.swiftness_func(player, 1.2, 135*redx) end
})
register_lingering("swiftness_2", "Lingering Swiftness II", "#00BBBB", {
potion_fun = function(player, redx) mcl_potions.swiftness_func(player, 1.4, 135*redx) end
})
register_lingering("swiftness_plus", "Lingering Swiftness +", "#00BBBB", {
potion_fun = function(player, redx) mcl_potions.swiftness_func(player, 1.2, 360*redx) end
})
register_lingering("slowness", "Lingering Slowness ", "#000080", {
potion_fun = function(player, redx) mcl_potions.swiftness_func(player, 0.85, 68*redx) end
})
register_lingering("slowness_plus", "Lingering Slowness +", "#000066", {
potion_fun = function(player, redx) mcl_potions.swiftness_func(player, 0.85, 180*redx) end
})
register_lingering("poison", "Lingering Poison", "#335544", {
potion_fun = function(player, redx) mcl_potions.poison_func(player, 0.85, 180*redx) end
})
register_lingering("poison_2", "Lingering Poison II", "#446655", {
potion_fun = function(player, redx) mcl_potions.poison_func(player, 0.85, 180*redx) end
})
register_lingering("poison_plus", "Lingering Poison +", "#557766", {
potion_fun = function(player, redx) mcl_potions.poison_func(player, 0.85, 180*redx) end
})
register_lingering("regeneration", "Lingering Regeneration", "#A52BB2", {
potion_fun = function(player, redx) mcl_potions.regeneration_func(player, 0.85, 180*redx) end
})
register_lingering("regeneration_2", "Lingering Regeneration II", "#B52CC2", {
potion_fun = function(player, redx) mcl_potions.regeneration_func(player, 0.85, 180*redx) end
})
register_lingering("regeneration_plus", "Lingering Regeneration +", "#C53DD3", {
potion_fun = function(player, redx) mcl_potions.regeneration_func(player, 0.85, 300*redx) end
})
register_lingering("invisibility", "Lingering Invisibility", "#B0B0B0", {
potion_fun = function(player, redx) mcl_potions.invisiblility_func(player, 135*redx) end
})
register_lingering("invisibility_plus", "Lingering Invisibility +", "#A0A0A0", {
potion_fun = function(player, redx) mcl_potions.invisiblility_func(player, 300*redx) end
})
register_lingering("weakness", "Lingering Weakness", "#6600AA", {
potion_fun = function(player, redx) mcl_potions.weakness_func(player, 1.2, 68*redx) end
})
register_lingering("weakness_plus", "Lingering Weakness +", "#7700BB", {
potion_fun = function(player, redx) mcl_potions.weakness_func(player, 1.4, 180*redx) end
})

View File

@ -74,6 +74,14 @@ local function register_splash(name, descr, color, def)
})
end
register_splash("water", "Splash Water", "#0000FF", {
potion_fun = function(player, redx) end,
})
register_splash("river_water", "Splash River Water", "#0000FF", {
potion_fun = function(player, redx) end,
})
register_splash("awkward", "Splash Awkward Potion", "#0000FF", {
potion_fun = function(player, redx) end,
})