7 Commits

Author SHA1 Message Date
fbc4cc8511 technic_cnc/cnc.lua: Fix access to non-existant stack parameter (#528) 2020-01-28 21:38:13 +01:00
904800abde Add river water can (#527) 2020-01-26 14:29:44 +01:00
1a45ad19d4 Alloy furnace: Accept only unique ItemStacks from tubes (#523)
Co-authored-by: Luke aka SwissalpS <Luke@SwissalpS.ws>
Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
2020-01-11 22:06:24 +01:00
e90b28895c battery_box.lua: Make "srcstack" local (#525)
Fixes warning:
Assignment to undeclared global "srcstack" inside a function at battery_box.lua:454
2020-01-06 21:50:15 +01:00
7696546d47 Fix steel strut overlay texture name (#526) 2020-01-06 21:49:05 +01:00
da95be53ec Fix radiation protection when armor group is not set (#509)
The radiation damage group can be not set when armor completely
protects against radiation or when no mod has set a default value
for the damage group. We want to apply radiation damage in the
second case but not in the first.
2019-12-30 21:02:01 +01:00
76a39e71b9 Cleanup duplicate call (#522)
No need to call get_inventory twice
2019-12-25 22:23:34 +01:00
11 changed files with 101 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

@ -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)
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)