Add bucket register function
This commit is contained in:
parent
1c86092894
commit
a93ef1db2c
@ -3,7 +3,7 @@
|
|||||||
TechAge
|
TechAge
|
||||||
=======
|
=======
|
||||||
|
|
||||||
Copyright (C) 2019-2020 Joachim Stolberg
|
Copyright (C) 2019-2023 Joachim Stolberg
|
||||||
|
|
||||||
AGPL v3
|
AGPL v3
|
||||||
See LICENSE.txt for more information
|
See LICENSE.txt for more information
|
||||||
@ -24,13 +24,10 @@ local BLOCKING_TIME = 0.3 -- 300ms
|
|||||||
techage.boiler = {}
|
techage.boiler = {}
|
||||||
|
|
||||||
local IsWater = {
|
local IsWater = {
|
||||||
["bucket:bucket_river_water"] = true,
|
["bucket:bucket_river_water"] = "bucket:bucket_empty",
|
||||||
["bucket:bucket_water"] = true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local IsBucket = {
|
local IsBucket = {}
|
||||||
["bucket:bucket_empty"] = true,
|
|
||||||
}
|
|
||||||
|
|
||||||
local function node_description(name)
|
local function node_description(name)
|
||||||
name = string.split(name, " ")[1]
|
name = string.split(name, " ")[1]
|
||||||
@ -126,12 +123,12 @@ function techage.boiler.on_punch(pos, node, puncher, pointed_thing)
|
|||||||
if IsWater[wielded_item] and nvm.num_water < MAX_WATER then
|
if IsWater[wielded_item] and nvm.num_water < MAX_WATER then
|
||||||
mem.blocking_time = techage.SystemTime + BLOCKING_TIME
|
mem.blocking_time = techage.SystemTime + BLOCKING_TIME
|
||||||
nvm.num_water = nvm.num_water + 1
|
nvm.num_water = nvm.num_water + 1
|
||||||
puncher:set_wielded_item(ItemStack("bucket:bucket_empty"))
|
puncher:set_wielded_item(ItemStack(IsWater[wielded_item]))
|
||||||
M(pos):set_string("formspec", techage.boiler.formspec(pos, nvm))
|
M(pos):set_string("formspec", techage.boiler.formspec(pos, nvm))
|
||||||
elseif IsBucket[wielded_item] and nvm.num_water > 0 then
|
elseif IsBucket[wielded_item] and nvm.num_water > 0 then
|
||||||
if item_count > 1 then
|
if item_count > 1 then
|
||||||
local inv = puncher:get_inventory()
|
local inv = puncher:get_inventory()
|
||||||
local item = ItemStack("bucket:bucket_water")
|
local item = ItemStack(IsBucket[wielded_item])
|
||||||
if inv:room_for_item("main", item) then
|
if inv:room_for_item("main", item) then
|
||||||
inv:add_item("main", item)
|
inv:add_item("main", item)
|
||||||
puncher:set_wielded_item({name=wielded_item, count = item_count - 1})
|
puncher:set_wielded_item({name=wielded_item, count = item_count - 1})
|
||||||
@ -141,8 +138,13 @@ function techage.boiler.on_punch(pos, node, puncher, pointed_thing)
|
|||||||
else
|
else
|
||||||
mem.blocking_time = techage.SystemTime + BLOCKING_TIME
|
mem.blocking_time = techage.SystemTime + BLOCKING_TIME
|
||||||
nvm.num_water = nvm.num_water - 1
|
nvm.num_water = nvm.num_water - 1
|
||||||
puncher:set_wielded_item(ItemStack("bucket:bucket_water"))
|
puncher:set_wielded_item(ItemStack(IsBucket[wielded_item]))
|
||||||
end
|
end
|
||||||
M(pos):set_string("formspec", techage.boiler.formspec(pos, nvm))
|
M(pos):set_string("formspec", techage.boiler.formspec(pos, nvm))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function techage.register_water_bucket(empty_bucket, full_bucket)
|
||||||
|
IsWater[full_bucket] = empty_bucket
|
||||||
|
IsBucket[empty_bucket] = full_bucket
|
||||||
|
end
|
||||||
|
@ -101,6 +101,9 @@ function techage.register_liquid(full_container, empty_container, container_size
|
|||||||
ContainerDef[empty_container] = ContainerDef[empty_container] or {}
|
ContainerDef[empty_container] = ContainerDef[empty_container] or {}
|
||||||
ContainerDef[empty_container][inv_item] = full_container
|
ContainerDef[empty_container][inv_item] = full_container
|
||||||
IsLiquid[inv_item] = true
|
IsLiquid[inv_item] = true
|
||||||
|
if inv_item == "techage:water" and container_size == 1 then
|
||||||
|
techage.register_water_bucket(empty_container, full_container)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_liquid_def(full_container)
|
local function get_liquid_def(full_container)
|
||||||
|
Loading…
Reference in New Issue
Block a user