Laid the framework to brew potions...TODO make it actually swap for the potion.
parent
0df8bb94f9
commit
b5b0020997
|
@ -71,12 +71,37 @@ local function swap_node(pos, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function brewable(inv)
|
||||||
|
|
||||||
|
local ingredient = inv:get_stack("input",1):get_name()
|
||||||
|
local stands = {"","",""}
|
||||||
|
|
||||||
|
for i=1,3 do
|
||||||
|
|
||||||
|
local bottle = inv:get_stack("stand", i):get_name()
|
||||||
|
|
||||||
|
if ingredient == "mcl_nether:nether_wart_item" and bottle == "mcl_potions:potion_river_water" or "mcl_potions:potion_water" then
|
||||||
|
stands[i] = "mcl_potions:potion_awkward"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
for i=1,3 do
|
||||||
|
if stands[i] then return stands end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local function brewing_stand_timer(pos, elapsed)
|
local function brewing_stand_timer(pos, elapsed)
|
||||||
-- Inizialize metadata
|
-- Inizialize metadata
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
|
||||||
local fuel_time = meta:get_float("fuel_time") or 0
|
local fuel_time = meta:get_float("fuel_time") or 0
|
||||||
local fuel_totaltime = meta:get_float("fuel_totaltime") or 0
|
local fuel_totaltime = meta:get_float("fuel_totaltime") or 0
|
||||||
|
local BREW_TIME = 10
|
||||||
|
|
||||||
local input_item = meta:get_string("input_item") or ""
|
local input_item = meta:get_string("input_item") or ""
|
||||||
|
|
||||||
|
@ -87,7 +112,6 @@ local function brewing_stand_timer(pos, elapsed)
|
||||||
|
|
||||||
local input_list, stand_list, fuel_list
|
local input_list, stand_list, fuel_list
|
||||||
|
|
||||||
local brewable, brewed
|
|
||||||
local fuel
|
local fuel
|
||||||
|
|
||||||
local update = true
|
local update = true
|
||||||
|
@ -109,11 +133,21 @@ local function brewing_stand_timer(pos, elapsed)
|
||||||
-- end
|
-- end
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
|
local brew_output = brewable(inv)
|
||||||
|
|
||||||
if fuel_time < fuel_totaltime then
|
if fuel_time < fuel_totaltime then
|
||||||
|
|
||||||
fuel_time = fuel_time + elapsed
|
fuel_time = fuel_time + elapsed
|
||||||
|
|
||||||
--TODO check to see if we can brew
|
-- Replace the stand item with the brew result
|
||||||
|
if brew_output and (stand_timer >= BREW_TIME) then
|
||||||
|
for i=1, inv:get_size("stand", i) do
|
||||||
|
if brew_output[i] then
|
||||||
|
inv:set_stack("stand", i, brew_output[i])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
else --get more fuel from fuel_list
|
else --get more fuel from fuel_list
|
||||||
|
|
||||||
|
@ -139,7 +173,6 @@ local function brewing_stand_timer(pos, elapsed)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
elapsed = 0
|
elapsed = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -160,11 +193,12 @@ local function brewing_stand_timer(pos, elapsed)
|
||||||
|
|
||||||
if fuel_totaltime ~= 0 then
|
if fuel_totaltime ~= 0 then
|
||||||
local fuel_percent = math.floor(fuel_time/fuel_totaltime*100)
|
local fuel_percent = math.floor(fuel_time/fuel_totaltime*100)
|
||||||
formspec = active_brewing_formspec(fuel_percent, 60)
|
local brew_percent = math.floor(stand_timer/BREW_TIME*100) % 100
|
||||||
swap_node(pos, "mcl_brewing:stand_active")
|
formspec = active_brewing_formspec(fuel_percent, stand_timer)
|
||||||
|
-- swap_node(pos, "mcl_brewing:stand_active")
|
||||||
result = true
|
result = true
|
||||||
else
|
else
|
||||||
swap_node(pos, "mcl_brewing:stand")
|
-- swap_node(pos, "mcl_brewing:stand")
|
||||||
minetest.get_node_timer(pos):stop()
|
minetest.get_node_timer(pos):stop()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -280,12 +280,6 @@ minetest.register_craftitem("mcl_potions:potion_mundane", {
|
||||||
on_secondary_use = minetest.item_eat(0, "mcl_potions:glass_bottle"),
|
on_secondary_use = minetest.item_eat(0, "mcl_potions:glass_bottle"),
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
type = "cooking",
|
|
||||||
output = "mcl_potions:potion_awkward",
|
|
||||||
recipe = "mcl_nether:nether_wart_item", --"mcl_potions:potion_river_water"},
|
|
||||||
cooktime = 10,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craftitem("mcl_potions:potion_thick", {
|
minetest.register_craftitem("mcl_potions:potion_thick", {
|
||||||
description = S("Thick Potion"),
|
description = S("Thick Potion"),
|
||||||
|
@ -328,3 +322,13 @@ minetest.register_craftitem("mcl_potions:dragon_breath", {
|
||||||
groups = { brewitem = 1, not_in_creative_inventory = 1 },
|
groups = { brewitem = 1, not_in_creative_inventory = 1 },
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_craftitem("mcl_potions:healing", {
|
||||||
|
description = S("Healing Potion"),
|
||||||
|
_doc_items_longdesc = brewhelp,
|
||||||
|
wield_image = "mcl_potions_healing.png",
|
||||||
|
inventory_image = "mcl_potions_healing.png",
|
||||||
|
-- TODO: Reveal item when it's actually useful
|
||||||
|
groups = { brewitem = 1, food=5},
|
||||||
|
stack_max = 64,
|
||||||
|
})
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Loading…
Reference in New Issue