Merge pull request #3 from minetest-mods/master

Update from minetest-mods
This commit is contained in:
BobFred7 2020-02-27 19:59:47 -05:00 committed by GitHub
commit 69b2144dd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 102 additions and 21 deletions

View File

@ -142,7 +142,7 @@ local iclipfence_def = {
local sclip_tex = {
"technic_insulator_clip.png",
{ name = "strut.png^steel_strut_overlay.png", color = "white" },
{ name = "strut.png^technic_steel_strut_overlay.png", color = "white" },
{ name = "strut.png", color = "white" }
}

View File

@ -21,6 +21,9 @@ celeron55 (Perttu Ahola) modified by Zefram (CC BY-SA 3.0):
sdzen (Elise Staudter) (CC BY-SA 3.0):
* most of the older 16x16 textures
leftshift (CC BY-SA 3.0):
* technic_river_water_can.png
RealBadAngel: (WTFPL)
* Everything else.

View File

@ -64,6 +64,10 @@ Registration functions
### Specific machines
* `technic.register_solar_array(data)`
* data is a table
* `technic.can_insert_unique_stack(pos, node, stack, direction)`
* `technic.insert_object_unique_stack(pos, node, stack, direction)`
* Functions for the parameters `can_insert` and `insert_object` to avoid
filling multiple inventory slots with same type of item.
Used itemdef fields
-------------------

View File

@ -95,7 +95,7 @@ minetest.register_node("technic:injector", {
if meta:get_int("splitstacks") == 1 then
stack = stack:peek_item(1)
end
return meta:get_inventory():room_for_item("main", stack)
return inv:room_for_item("main", stack)
end,
insert_object = function(pos, node, stack, direction)
return minetest.get_meta(pos):get_inventory():add_item("main", stack)

View File

@ -1,10 +1,50 @@
local S = technic.getter
function technic.insert_object_unique_stack(pos, node, incoming_stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local incoming_name = incoming_stack:get_name()
local stack_index = nil
for inv_index, inv_stack in pairs(inv:get_list("src")) do
if inv_stack:get_name() == incoming_name then
stack_index = inv_index
break
end
end
if stack_index == nil then
return inv:add_item("src", incoming_stack)
end
local present_stack = inv:get_stack("src", stack_index)
local leftover = present_stack:add_item(incoming_stack)
inv:set_stack("src", stack_index, present_stack)
return leftover
end
function technic.can_insert_unique_stack(pos, node, incoming_stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local incoming_name = incoming_stack:get_name()
if meta:get_int("splitstacks") == 0 then
-- avoid looping second time with inv:contains_item("src", incoming_stack)
for _, inv_stack in pairs(inv:get_list("src")) do
if inv_stack:get_name() == incoming_name then
return inv_stack:item_fits(incoming_stack)
end
end
end
return technic.default_can_insert(pos, node, incoming_stack, direction)
end
function technic.register_alloy_furnace(data)
data.typename = "alloy"
data.machine_name = "alloy_furnace"
data.machine_desc = S("%s Alloy Furnace")
data.insert_object = technic.insert_object_unique_stack
data.can_insert = technic.can_insert_unique_stack
technic.register_base_machine(data)
end

View File

@ -452,7 +452,7 @@ function technic.discharge_tools(meta, batt_charge, charge_step, max_charge)
if inv:is_empty("dst") then
return batt_charge, false
end
srcstack = inv:get_stack("dst", 1)
local srcstack = inv:get_stack("dst", 1)
local toolname = srcstack:get_name()
if technic.power_tools[toolname] == nil then
return batt_charge, false

View File

@ -15,6 +15,7 @@ if minetest.get_modpath("dye") then
-- register recipes with the same crafting ratios as `dye` provides
local dye_recipes = {
{"technic:coal_dust", "dye:black 2"},
{"default:blueberries", "dye:violet 2"},
{"default:grass_1", "dye:green 1"},
{"default:dry_shrub", "dye:brown 1"},
{"default:junglegrass", "dye:green 2"},

View File

@ -4,22 +4,26 @@ local S = technic.getter
local fs_helpers = pipeworks.fs_helpers
local tube_entry = "^pipeworks_tube_connection_metallic.png"
local tube = {
insert_object = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:add_item("src", stack)
end,
can_insert = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if meta:get_int("splitstacks") == 1 then
stack = stack:peek_item(1)
end
return inv:room_for_item("src", stack)
end,
connect_sides = {left = 1, right = 1, back = 1, top = 1, bottom = 1},
}
function technic.default_can_insert(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if meta:get_int("splitstacks") == 1 then
stack = stack:peek_item(1)
end
return inv:room_for_item("src", stack)
end
function technic.new_default_tube()
return {
insert_object = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:add_item("src", stack)
end,
can_insert = technic.default_can_insert,
connect_sides = {left = 1, right = 1, back = 1, top = 1, bottom = 1},
}
end
local connect_default = {"bottom", "back", "left", "right"}
@ -64,6 +68,14 @@ function technic.register_base_machine(data)
"listring[current_player;main]"
end
local tube = technic.new_default_tube()
if data.can_insert then
tube.can_insert = data.can_insert
end
if data.insert_object then
tube.insert_object = data.insert_object
end
local run = function(pos, node)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
@ -144,6 +156,7 @@ function technic.register_base_machine(data)
if ltier == "lv" then
tentry = ""
end
minetest.register_node("technic:"..ltier.."_"..machine_name, {
description = machine_desc:format(tier),
tiles = {

View File

@ -294,6 +294,8 @@ local function calculate_damage_multiplier(object)
end
if ag.radiation then
return 0.01 * ag.radiation
elseif armor_enabled then
return 0
end
if ag.fleshy then
return math.sqrt(0.01 * ag.fleshy)

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

View File

@ -112,3 +112,21 @@ minetest.register_craft({
{'technic:zinc_ingot', 'technic:stainless_steel_ingot', 'technic:zinc_ingot'},
}
})
technic.register_can({
can_name = 'technic:river_water_can',
can_description = S("River Water Can"),
can_inventory_image = "technic_river_water_can.png",
can_capacity = 16,
liquid_source_name = "default:river_water_source",
liquid_flowing_name = "default:river_water_flowing",
})
minetest.register_craft({
output = 'technic:river_water_can 1',
recipe = {
{'technic:zinc_ingot', 'technic:rubber', 'technic:zinc_ingot'},
{'default:steel_ingot', '', 'default:steel_ingot'},
{'technic:zinc_ingot', 'default:steel_ingot', 'technic:zinc_ingot'},
}
})

View File

@ -59,7 +59,7 @@ else
if minetest.is_protected(pos, player:get_player_name()) then
return 0
end
return stack:get_count()
return count
end
can_dig = function(pos, player)