diff --git a/api/lava_furnace.lua b/api/lava_furnace.lua index 8c5792f..0d7e38e 100644 --- a/api/lava_furnace.lua +++ b/api/lava_furnace.lua @@ -7,10 +7,6 @@ local META_LAVA_USED = "ufuel" local get_meta = minetest.get_meta -local itemstrings = logistica.itemstrings - -local BUCKET_LAVA = itemstrings.lava_bucket -local BUCKET_EMPTY = itemstrings.empty_bucket local LAVA_UNIT = "logistica:lava_unit" local INV_FUEL = "fuel" @@ -22,14 +18,15 @@ local GUIDE_BTN = "guide" local UPDATE_INTERVAL = 1.0 +local function is_lava_bucket(itemstackName) + return logistica.reservoir_get_full_buckets_for_liquid(logistica.liquids.lava)[itemstackName] ~= nil +end + local function fill_lava_tank_from_fuel(pos, meta, inv) local itemstackName = inv:get_stack(INV_FUEL, 1):get_name() - if itemstackName ~= BUCKET_LAVA and itemstackName ~= LAVA_UNIT then return end + if not is_lava_bucket(itemstackName) and itemstackName ~= LAVA_UNIT then return end - local returnStack = ItemStack("") - if itemstackName == BUCKET_LAVA then - returnStack = ItemStack(BUCKET_EMPTY) - end + local returnStack = logistica.reservoir_get_empty_bucket_for_full_bucket(itemstackName) or ItemStack("") local currLevel = meta:get_int(META_LAVA_IN_TANK) local cap = logistica.lava_furnace_get_lava_capacity(pos) if cap - currLevel < 1000 then return end @@ -288,10 +285,11 @@ end local function lava_furnace_allow_metadata_inv_put(pos, listname, index, stack, player) if minetest.is_protected(pos, player:get_player_name()) then return 0 end + local stackName = stack:get_name() if listname == INV_INPT or listname == INV_ADDI then return stack:get_count() elseif listname == INV_FUEL - and (stack:get_name() == BUCKET_LAVA or stack:get_name() == LAVA_UNIT) then + and (is_lava_bucket(stackName) or stackName == LAVA_UNIT) then return 1 else return 0 diff --git a/api/reservoir.lua b/api/reservoir.lua index e1c2a50..15206b8 100644 --- a/api/reservoir.lua +++ b/api/reservoir.lua @@ -213,11 +213,13 @@ function logistica.register_reservoir(liquidName, liquidDesc, bucketItemName, li def.light_source = optLight def.inventory_image = make_inv_image(variantName, liquidTexture) - minetest.register_node(nodeName, def) - logistica.register_non_pushable(nodeName) - logistica.GROUPS.reservoirs.register(nodeName) + if not minetest.registered_nodes[nodeName] then + minetest.register_node(nodeName, def) + logistica.register_non_pushable(nodeName) + logistica.GROUPS.reservoirs.register(nodeName) - minetest.register_node(nodeName.."_disabled", get_disabled_def(def)) + minetest.register_node(nodeName.."_disabled", get_disabled_def(def)) + end logistica.reservoir_register_names(lname, bucketItemName, optEmptyBucketName, liquidDesc, liquidTexture, sourceNodeName) end diff --git a/logic/bucket_emptier.lua b/logic/bucket_emptier.lua index d0fd4a8..dac3960 100644 --- a/logic/bucket_emptier.lua +++ b/logic/bucket_emptier.lua @@ -30,10 +30,10 @@ function logistica.emptier_timer(pos, elapsed) repeat local stack = inv:get_stack(INV_INPUT, currSlot) local stackName = stack:get_name() - local liquidName = logistica.reservoir_get_liquid_name_for_bucket(stackName) + local liquidName = logistica.reservoir_get_liquid_name_for_filled_bucket(stackName) if liquidName then - local emptyBucket = logistica.reservoir_get_empty_bucket_for_liquid(liquidName) - if inv:room_for_item(INV_MAIN, ItemStack(emptyBucket)) then + local emptyBucket = logistica.reservoir_get_empty_bucket_for_full_bucket(stackName) + if emptyBucket and inv:room_for_item(INV_MAIN, ItemStack(emptyBucket)) then local newStack = logistica.empty_bucket_into_network(network, stack) if newStack then success = true diff --git a/logic/bucket_filler.lua b/logic/bucket_filler.lua index f0a7bae..b854e52 100644 --- a/logic/bucket_filler.lua +++ b/logic/bucket_filler.lua @@ -9,7 +9,7 @@ local buckets_to_names = nil local function get_all_buckets_to_names_list() if not buckets_to_names then buckets_to_names = logistica.table_to_list_indexed( - logistica.reservoir_get_all_buckets_to_names_map(), + logistica.reservoir_get_all_filled_buckets_to_names_map(), function (bucketName, liquidName) return { bucketName = bucketName, liquidName = liquidName } end @@ -59,15 +59,18 @@ function logistica.take_item_from_bucket_filler(pos, stackToTake, network, colle local originalRequestedBuckets = stackToTake:get_count() local stackToTakeName = stackToTake:get_name() - local liquidName = logistica.reservoir_get_liquid_name_for_bucket(stackToTakeName) + local liquidName = logistica.reservoir_get_liquid_name_for_filled_bucket(stackToTakeName) if not liquidName then return { remaining = stackToTake:get_count(), error = S("Unknown liquid: ")..liquidName } end local liquidInfo = logistica.get_liquid_info_in_network(pos, liquidName) local remainingRequest = math.min(liquidInfo.curr, originalRequestedBuckets) local unfillableBuckets = originalRequestedBuckets - remainingRequest - local filledBucketName = logistica.reservoir_get_full_bucket_for_liquid(liquidName) - local emptyBucketName = logistica.reservoir_get_empty_bucket_for_liquid(liquidName) + local filledBuckets = logistica.reservoir_get_full_buckets_for_liquid(liquidName) + if not filledBuckets[stackToTakeName] then return { remaining = stackToTake:get_count(), error = S("Unknown filled bucket requested: ")..stackToTakeName } end + local filledBucketName = stackToTakeName + local emptyBucketName = logistica.reservoir_get_empty_bucket_for_full_bucket(stackToTakeName) + if not emptyBucketName then return { remaining = stackToTake:get_count(), error = S("Unknown full bucket: ")..stackToTakeName } end -- first try to get the empty bucket from our internal inventory local inv = minetest.get_meta(pos):get_inventory() diff --git a/logic/lava_furnace_fueler.lua b/logic/lava_furnace_fueler.lua index 24a2b4d..c39676d 100644 --- a/logic/lava_furnace_fueler.lua +++ b/logic/lava_furnace_fueler.lua @@ -4,7 +4,7 @@ local META_TARGET_LAVA = "tarlava" local META_LAVA_IN_TANK = "lavam" local EMPTY_BUCKET = logistica.itemstrings.empty_bucket -local LAVA_LIQUID_NAME = "lava" +local LAVA_LIQUID_NAME = logistica.liquids.lava local function get_lava_furnace_lava_in_tank(meta) return meta:get_int(META_LAVA_IN_TANK) diff --git a/logic/network_storage.lua b/logic/network_storage.lua index a05ee4c..86b71ea 100644 --- a/logic/network_storage.lua +++ b/logic/network_storage.lua @@ -48,7 +48,7 @@ function logistica.empty_bucket_into_network(network, bucketItemStack, dryRun) if not logistica.reservoir_is_full_bucket(bucketItemStack:get_name()) then return nil end local bucketName = bucketItemStack:get_name() - local liquidName = logistica.reservoir_get_liquid_name_for_bucket(bucketName) + local liquidName = logistica.reservoir_get_liquid_name_for_filled_bucket(bucketName) local highestReservoirPos = nil local emptyReservoirPos = nil diff --git a/logic/pump.lua b/logic/pump.lua index 48fdb26..1d12ab9 100644 --- a/logic/pump.lua +++ b/logic/pump.lua @@ -1,3 +1,5 @@ +local EMPTY_BUCKET = logistica.itemstrings.empty_bucket -- sort of weird, but we move liquids around in buckets, so we need some known "empty" bucket + local PUMP_MAX_RANGE = logistica.settings.pump_max_range local PUMP_MAX_DEPTH = logistica.settings.pump_max_depth @@ -89,8 +91,12 @@ local function get_valid_source(targetPosition, ownerName) local nodeDef = minetest.registered_nodes[node.name] if nodeDef.liquidtype ~= "source" then return nil end - local bucketName = logistica.reservoir_get_full_bucket_for_liquid(liquidName) - if not bucketName then return nil end + local bucketsName = logistica.reservoir_get_full_buckets_for_liquid(liquidName) + local bucketName = nil + for potentialBucket, _ in pairs(bucketsName) do + -- basically, try to pick the EMPTY_BUCKET, but if not present for some weird reason, pick any valid filled bucket + if bucketName ~= EMPTY_BUCKET then bucketName = potentialBucket end + end -- otherwise its valid local isRenewable = nodeDef.liquid_renewable ; if isRenewable == nil then isRenewable = true end -- default value is true, per api docs @@ -126,7 +132,7 @@ end -- returns true if succeeded, false if not local function put_liquid_in_network_reservoirs(pumpPosition, bucketItemStack, network) if not network then return false end - local liquidName = logistica.reservoir_get_liquid_name_for_bucket(bucketItemStack:get_name()) + local liquidName = logistica.reservoir_get_liquid_name_for_filled_bucket(bucketItemStack:get_name()) if not liquidName then return false end local amountInNetwork = logistica.get_liquid_info_in_network(pumpPosition, liquidName) local maxAmount = get_max_level(minetest.get_meta(pumpPosition)) diff --git a/logic/reservoir.lua b/logic/reservoir.lua index 564ed24..ce13462 100644 --- a/logic/reservoir.lua +++ b/logic/reservoir.lua @@ -1,12 +1,14 @@ local S = logistica.TRANSLATOR -local BUCKET_TO_NAME = {} -local NAME_TO_BUCKET = {} -local NAME_TO_EMPTY_BUCKET = {} -local NAME_TO_DESC = {} -local NAME_TO_TEXTURE = {} -local NAME_TO_SOURCE = {} -local SOURCE_TO_NAME = {} +local FILLED_BUCKET_TO_NAME = {} -- { full_bucket_name = liquidName } +local NAME_TO_FILLED_BUCKETS = {} -- { liquidName = { full_bucket_name = true, ... } } +local FILLED_TO_EMPTY = {} -- { full_bucket_name = empty_bucket_name } +local EMPTY_TO_FILLED = {} -- { empty_bucket_name = { liquidName = full_bucket_name } } +local NAME_TO_EMPTY_BUCKETS = {} -- { liquidName = { emptyBucket = true, ... } } +local NAME_TO_DESC = {} -- { liquidName = "Description of liquid" } +local NAME_TO_TEXTURE = {} -- { liquidName = "texture_of_liquid" } +local NAME_TO_SOURCE = {} -- { liquidName = source_node_name } +local SOURCE_TO_NAME = {} -- { source_node_name = liquid_name } local EMPTY_BUCKET = logistica.itemstrings.empty_bucket local EMPTY_SUFFIX = "_empty" @@ -28,15 +30,29 @@ local function ends_with(str, ending) return ending == "" or string.sub(str, -#ending) == ending end -local function get_empty_bucket_needed_for(liquidName) - local savedBucket = NAME_TO_EMPTY_BUCKET[liquidName] - if savedBucket then return savedBucket - else return EMPTY_BUCKET end +local function get_empty_buckets_that_can_accept(liquidName) + local savedBuckets = NAME_TO_EMPTY_BUCKETS[liquidName] + if savedBuckets then return savedBuckets + else return {} end end -local function get_full_bucket_needed_for(liquidName) - if liquidName == LIQUID_NONE then return BUCKET_ANY end - return NAME_TO_BUCKET[liquidName] +local function does_full_bucket_match_liquid(fullBucketName, liquidName) + if liquidName == LIQUID_NONE then + return FILLED_BUCKET_TO_NAME[fullBucketName] ~= nil + end + local filledBuckets = NAME_TO_FILLED_BUCKETS[liquidName] + if not filledBuckets then return false end + return filledBuckets[fullBucketName] ~= nil +end + +-- returns full bucket itemstack name, or nil if there isn't one (because empty can't hold liquid) +local function get_filled_bucket_for_empty_and_liquid(emptyBucketName, liquidName) + local emptyBucketsForLiquid = NAME_TO_EMPTY_BUCKETS[liquidName] + if not emptyBucketsForLiquid then return nil end + if not emptyBucketsForLiquid[emptyBucketName] then return nil end + local potentialFilledBuckets = EMPTY_TO_FILLED[emptyBucketName] + if not potentialFilledBuckets then return nil end + return potentialFilledBuckets[liquidName] end local function get_empty_reservoir_name(nodeName, liquidName) @@ -79,11 +95,21 @@ function logistica.reservoir_get_description(currBuckets, maxBuckets, liquidName end function logistica.reservoir_register_names(liquidName, bucketName, emptyBucketName, liquidDesc, liquidTexture, sourceNodeName) - BUCKET_TO_NAME[bucketName] = liquidName - NAME_TO_BUCKET[liquidName] = bucketName - if emptyBucketName then - NAME_TO_EMPTY_BUCKET[liquidName] = emptyBucketName - end + if not emptyBucketName then emptyBucketName = EMPTY_BUCKET end + + FILLED_BUCKET_TO_NAME[bucketName] = liquidName + + if not NAME_TO_FILLED_BUCKETS[liquidName] then NAME_TO_FILLED_BUCKETS[liquidName] = {} end + NAME_TO_FILLED_BUCKETS[liquidName][bucketName] = true + + FILLED_TO_EMPTY[bucketName] = emptyBucketName + + if not EMPTY_TO_FILLED[emptyBucketName] then EMPTY_TO_FILLED[emptyBucketName] = {} end + EMPTY_TO_FILLED[emptyBucketName][liquidName] = bucketName + + if not NAME_TO_EMPTY_BUCKETS[liquidName] then NAME_TO_EMPTY_BUCKETS[liquidName] = {} end + NAME_TO_EMPTY_BUCKETS[liquidName][emptyBucketName] = true + NAME_TO_DESC[liquidName] = liquidDesc NAME_TO_TEXTURE[liquidName] = liquidTexture if sourceNodeName then @@ -106,15 +132,25 @@ function logistica.reservoir_use_item_on(pos, itemstack, optNode, dryRun) local maxBuckets = nodeDef.logistica.maxBuckets local liquidDesc = logistica.reservoir_get_description_of_liquid(liquidName) - local emptyBucket = get_empty_bucket_needed_for(liquidName) - local fullBucket = get_full_bucket_needed_for(liquidName) + local isReservoirFull = liquidName ~= LIQUID_NONE - if itemStackName == emptyBucket then + local tryToFillBucket = false + local tryToEmptyBucket = false + if isReservoirFull then + local emptyBucketsForLiquid = get_empty_buckets_that_can_accept(liquidName) + if emptyBucketsForLiquid[itemStackName] then tryToFillBucket = true end + end + if not tryToFillBucket then + tryToEmptyBucket = does_full_bucket_match_liquid(itemStackName, liquidName) + end + + if tryToFillBucket then if nodeLiquidLevel == 0 then -- make sure we swap this for the empty reservoir logistica.swap_node(pos, get_empty_reservoir_name(node.name, liquidName)) return nil end + local fullBucket = get_filled_bucket_for_empty_and_liquid(itemStackName, liquidName) if not fullBucket then return nil end nodeLiquidLevel = nodeLiquidLevel - 1 @@ -135,10 +171,10 @@ function logistica.reservoir_use_item_on(pos, itemstack, optNode, dryRun) end return ItemStack(fullBucket) - elseif fullBucket == BUCKET_ANY or itemStackName == fullBucket then - local newLiquidName = BUCKET_TO_NAME[itemStackName] + elseif tryToEmptyBucket then + local newLiquidName = FILLED_BUCKET_TO_NAME[itemStackName] if not newLiquidName then return nil end -- wasn't a bucket we can use - local newEmptyBucket = get_empty_bucket_needed_for(newLiquidName) + local newEmptyBucket = FILLED_TO_EMPTY[itemStackName] if not newEmptyBucket then return nil end nodeLiquidLevel = nodeLiquidLevel + 1 @@ -182,16 +218,11 @@ function logistica.reservoir_get_liquid_level(pos) end function logistica.reservoir_is_empty_bucket(bucketName) - if bucketName == EMPTY_BUCKET then return true end - for _, bucket in pairs(NAME_TO_EMPTY_BUCKET) do - if bucket == bucketName then return true end - end - return false + return EMPTY_TO_FILLED[bucketName] ~= nil end function logistica.reservoir_is_full_bucket(bucketName) - if BUCKET_TO_NAME[bucketName] ~= nil then return true end - return false + return FILLED_BUCKET_TO_NAME[bucketName] ~= nil end -- returns true if the itemname is a known empty or filled bucket that can be used in a reservoir @@ -199,23 +230,35 @@ function logistica.reservoir_is_known_bucket(bucketName) return logistica.reservoir_is_empty_bucket(bucketName) or logistica.reservoir_is_full_bucket(bucketName) end --- return the liquid name for the given bucket name, or nil if there's none registered -function logistica.reservoir_get_liquid_name_for_bucket(bucketName) - return BUCKET_TO_NAME[bucketName] +-- return the liquid name for the given filled bucket name, or nil if there's none registered +function logistica.reservoir_get_liquid_name_for_filled_bucket(bucketName) + return FILLED_BUCKET_TO_NAME[bucketName] end -function logistica.reservoir_get_all_buckets_to_names_map() - return table.copy(BUCKET_TO_NAME) +function logistica.reservoir_get_all_filled_buckets_to_names_map() + return table.copy(FILLED_BUCKET_TO_NAME) end function logistica.reservoir_get_all_sources_to_names_map() return table.copy(SOURCE_TO_NAME) end -function logistica.reservoir_get_empty_bucket_for_liquid(liquidName) - return get_empty_bucket_needed_for(liquidName) +-- returns a list of empty buckets that can accept this liquid +function logistica.reservoir_get_empty_buckets_that_can_accept(liquidName) + local emptyBuckets = NAME_TO_EMPTY_BUCKETS[liquidName] + if not emptyBuckets then return {} end + return table.copy(emptyBuckets) end -function logistica.reservoir_get_full_bucket_for_liquid(liquidName) - return get_full_bucket_needed_for(liquidName) +-- returns the empty bucket name corresponding to the filled bucket - or nil if the given filledBucketName isn't a full bucket +function logistica.reservoir_get_empty_bucket_for_full_bucket(filledBucketName) + return FILLED_TO_EMPTY[filledBucketName] +end + +-- returns a table {filledBucket = true, ...} of the filled buckets that can hold this liquid +-- or empty table if there are none +function logistica.reservoir_get_full_buckets_for_liquid(liquidName) + local filledBuckets = NAME_TO_FILLED_BUCKETS[liquidName] + if not filledBuckets then return {} end + return table.copy(filledBuckets) end diff --git a/mod.conf b/mod.conf index b7f4105..a05cfdd 100644 --- a/mod.conf +++ b/mod.conf @@ -1,5 +1,5 @@ name = logistica -optional_depends = default, bucket, i3, mcl_core, mcl_buckets, unified_inventory, mcl_mobitems, animalia, ethereal, mesecons_mvps +optional_depends = default, bucket, i3, mcl_core, mcl_buckets, unified_inventory, mcl_mobitems, animalia, ethereal, mesecons_mvps, bucket_wooden min_minetest_version = 5.4.0 author = ZenonSeth description = On-demand Item Transportation + Powerful Item and Liquid Storage diff --git a/registration/item_recipes.lua b/registration/item_recipes.lua index ecc19ca..351321f 100644 --- a/registration/item_recipes.lua +++ b/registration/item_recipes.lua @@ -91,11 +91,16 @@ minetest.register_craft({ } }) -minetest.register_craft({ - output = itemstrings.lava_bucket, - type = "shapeless", - recipe = { L("lava_unit"), "bucket:bucket_empty" } -}) +for filledBucket, _ in pairs(logistica.reservoir_get_full_buckets_for_liquid(logistica.liquids.lava)) do + local emptyBucket = logistica.reservoir_get_empty_bucket_for_full_bucket(filledBucket) + if minetest.registered_items[filledBucket] and minetest.registered_items[emptyBucket] then + minetest.register_craft({ + output = filledBucket, + type = "shapeless", + recipe = { L("lava_unit"), emptyBucket } + }) + end +end minetest.register_craft({ output = L("cobblegen_upgrade"), diff --git a/registration/machines_api_reg.lua b/registration/machines_api_reg.lua index 36d50f5..042378b 100644 --- a/registration/machines_api_reg.lua +++ b/registration/machines_api_reg.lua @@ -259,36 +259,7 @@ logistica.register_requester("Bulk Request Inserter\nInserts up to 64 items at a -- Reservoirs -------------------------------- -local mcla = minetest.get_game_info().id == "mineclonia" -local mcl2 = minetest.get_game_info().id == "mineclone2" - -local lava_texture = "default_lava.png" -local water_texture = "default_water.png" -local river_water_texture = "default_river_water.png" - -if mcla then - lava_texture = "default_lava_source_animated.png^[sheet:1x16:0,0" - water_texture = "default_water_source_animated.png^[sheet:1x16:0,0" - river_water_texture = "default_river_water_source_animated.png^[sheet:1x16:0,0" -elseif mcl2 then - lava_texture = "mcl_core_lava_source_animation.png^[sheet:1x16:0,0" - water_texture = "mcl_core_water_source_animation.png^[sheet:1x16:0,0^[multiply:#3F76E4" - river_water_texture = "mcl_core_water_source_animation.png^[sheet:1x16:0,0^[multiply:#0084FF" -end - -logistica.register_reservoir("lava", "Lava", itemstrings.lava_bucket, lava_texture, itemstrings.lava_source, 8) -logistica.register_reservoir("water", "Water", itemstrings.water_bucket, water_texture, itemstrings.water_source) -logistica.register_reservoir("river_water", "River Water", itemstrings.river_water_bucket, river_water_texture, itemstrings.river_water_source) --- milk buckets -if minetest.registered_items["mcl_mobitems:milk_bucket"] then - logistica.register_reservoir("milk", "Milk", "mcl_mobitems:milk_bucket", "logistica_milk_liquid.png") -end -if minetest.registered_items["animalia:bucket_milk"] then - logistica.register_reservoir("milk", "Milk", "animalia:bucket_milk", "logistica_milk_liquid.png") -end -if minetest.registered_items["ethereal:bucket_cactus"] then - logistica.register_reservoir("cactus_pulp", "Cactus Pulp", "ethereal:bucket_cactus", "logistica_milk_liquid.png^[colorize:#697600:227") -end +logistica.compat_bucket_register_buckets() -------------------------------- -- Passive Supply Chest diff --git a/registration/registration.lua b/registration/registration.lua index 55f1667..f12f017 100644 --- a/registration/registration.lua +++ b/registration/registration.lua @@ -1,8 +1,8 @@ local path = logistica.MODPATH .. "/registration" -- once again, order is important dofile(path.."/node_recipes.lua") -dofile(path.."/item_recipes.lua") dofile(path.."/machines_api_reg.lua") +dofile(path.."/item_recipes.lua") dofile(path.."/lava_furnace_recipes.lua") dofile(path.."/misc.lua") dofile(path.."/compat_unified_inv.lua") diff --git a/util/common.lua b/util/common.lua index 487f033..9f4d30a 100644 --- a/util/common.lua +++ b/util/common.lua @@ -1,7 +1,6 @@ logistica.TRANSLATOR = minetest.get_translator(logistica.MODNAME) - local META_ON_OFF_KEY = "logonoff" local charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" diff --git a/util/compat_bucket.lua b/util/compat_bucket.lua new file mode 100644 index 0000000..73758af --- /dev/null +++ b/util/compat_bucket.lua @@ -0,0 +1,91 @@ + +-- Provide compatiblity with: +-- 1. The bucket_lite mod and its many buckets +-- 2. The wooden bucket mod (there's 2 of them but only 1 seems functional with latest minetest - the bucket_wooden) + + + +local liquids = logistica.liquids +local des = liquids.name_to_description +local tex = liquids.name_to_texture +local src = liquids.name_to_source_block +local lit = liquids.name_to_light + +--[[ table entry format: +[empty_bucket_name] = { + [liquid_name] = filled_bucket_name +} +--]] +local buckets_to_register = {} + +-- default buckets +--[[ + logistica.register_reservoir( + liq.lava, des[liq.lava], itemstrings.lava_bucket, tex[liq.lava], src[liq.lava], lit[liq.lava]) +logistica.register_reservoir( + liq.water, des[liq.water], itemstrings.water_bucket, tex[liq.water], src[liq.water], lit[liq.water]) +logistica.register_reservoir( + liq.river_water, des[liq.river_water], itemstrings.river_water_bucket, tex[liq.river_water], src[liq.river_water], lit[liq.river_water]) +]] + +buckets_to_register[logistica.itemstrings.empty_bucket] = { + [liquids.water] = logistica.itemstrings.water_bucket, + [liquids.river_water] = logistica.itemstrings.river_water_bucket, + [liquids.lava] = logistica.itemstrings.lava_bucket, +} + +-- bucket_lite + +local function liteEmptyBucket(type) return "bucket:bucket_empty_"..type end +local function liteWaterBucket(type) return "bucket:bucket_water_uni_"..type end +local function liteRiverBucket(type) return "bucket:bucket_water_river_"..type end +local function liteLavaBucket(type) return "bucket:bucket_lava_uni_"..type end +local bucket_lite_types = { "bronze", "diamond", "gold", "mese", "steel", "stone", "wood" } +for _, type in ipairs(bucket_lite_types) do + local emptyBucket = liteEmptyBucket(type) + if minetest.registered_items[emptyBucket] then + buckets_to_register[emptyBucket] = { + [liquids.water] = liteWaterBucket(type), + [liquids.river_water] = liteRiverBucket(type), + [liquids.lava] = liteLavaBucket(type), + } + end +end + +-- bucket_wooden + +if minetest.registered_items["bucket_wooden:bucket_empty"] then + buckets_to_register["bucket_wooden:bucket_empty"] = { + [liquids.water] = "bucket_wooden:bucket_water", + [liquids.river_water] = "bucket_wooden:bucket_river_water", + } +end + +-- + +---------------------------------------------------------------- +-- global funcs and registration +---------------------------------------------------------------- + +function logistica.compat_bucket_register_buckets() + for emptyBucket, data in pairs(buckets_to_register) do + for liquidName, fullBucket in pairs(data) do + if minetest.registered_items[fullBucket] then + logistica.register_reservoir( + liquidName, des[liquidName], fullBucket, tex[liquidName], src[liquidName], lit[liquidName], emptyBucket + ) + end + end + end + + -- unique buckets with unique liquids + if minetest.registered_items["mcl_mobitems:milk_bucket"] then + logistica.register_reservoir("milk", "Milk", "mcl_mobitems:milk_bucket", "logistica_milk_liquid.png") + end + if minetest.registered_items["animalia:bucket_milk"] then + logistica.register_reservoir("milk", "Milk", "animalia:bucket_milk", "logistica_milk_liquid.png") + end + if minetest.registered_items["ethereal:bucket_cactus"] then + logistica.register_reservoir("cactus_pulp", "Cactus Pulp", "ethereal:bucket_cactus", "logistica_milk_liquid.png^[colorize:#697600:227") + end +end diff --git a/util/liquids.lua b/util/liquids.lua new file mode 100644 index 0000000..0a19bb5 --- /dev/null +++ b/util/liquids.lua @@ -0,0 +1,49 @@ +local S = logistica.TRANSLATOR + +local itemstrings = logistica.itemstrings + +logistica.liquids = {} +local liq = logistica.liquids +liq.lava = "lava" +liq.water = "water" +liq.river_water = "river_water" + +liq.name_to_description = { + [liq.lava] = S("Lava"), + [liq.water] = S("Water"), + [liq.river_water] = S("River Water"), +} + +local lava_texture = "default_lava.png" +local water_texture = "default_water.png" +local river_water_texture = "default_river_water.png" + +local mcla = minetest.get_game_info().id == "mineclonia" +local mcl2 = minetest.get_game_info().id == "mineclone2" +if mcla then + lava_texture = "default_lava_source_animated.png^[sheet:1x16:0,0" + water_texture = "default_water_source_animated.png^[sheet:1x16:0,0" + river_water_texture = "default_river_water_source_animated.png^[sheet:1x16:0,0" +elseif mcl2 then + lava_texture = "mcl_core_lava_source_animation.png^[sheet:1x16:0,0" + water_texture = "mcl_core_water_source_animation.png^[sheet:1x16:0,0^[multiply:#3F76E4" + river_water_texture = "mcl_core_water_source_animation.png^[sheet:1x16:0,0^[multiply:#0084FF" +end + +liq.name_to_texture = { + [liq.lava] = lava_texture, + [liq.water] = water_texture, + [liq.river_water] = river_water_texture, +} + +liq.name_to_source_block = { + [liq.lava] = itemstrings.lava_source, + [liq.water] = itemstrings.water_source, + [liq.river_water] = itemstrings.river_water_source, +} + +liq.name_to_light = { + [liq.lava] = 8, + [liq.water] = 0, + [liq.river_water] = 0, +} diff --git a/util/util.lua b/util/util.lua index c5ddb99..292a3c4 100644 --- a/util/util.lua +++ b/util/util.lua @@ -4,6 +4,7 @@ dofile(path.."/compat_mcl.lua") dofile(path.."/compat_mesecons.lua") dofile(path.."/settings.lua") dofile(path.."/common.lua") +dofile(path.."/liquids.lua") dofile(path.."/rotations.lua") dofile(path.."/hud.lua") dofile(path.."/ui_logic.lua") @@ -11,6 +12,7 @@ dofile(path.."/ui.lua") dofile(path.."/sound.lua") dofile(path.."/inv_list_sorting.lua") dofile(path.."/inv_list_filtering.lua") +dofile(path.."/compat_bucket.lua") -- bad debug local d = {}