8 Commits

Author SHA1 Message Date
9cf5fab245 technic_cnc: Use client-side translation API 2024-03-29 13:34:34 +01:00
d5ff69d1d9 Add Everness sandstone compressor recipes (#634) 2024-03-25 19:45:57 +01:00
f47da0c045 Add grinding for pyrite from Everness mod (#633)
Add recipe for grinding pyrite lump from everness mod into pyrite dust if everness mod is present (also includes images for pyrite dust).
2024-03-08 18:44:13 +01:00
a08ba2bb93 Get rid of deprecated metadata (#628)
The deprecated metadata gets converted to a proper ItemStackMetaRef.
All keys stay the same except for:
- Cans that use `can_level` now, since they didn't store a serialized table in the metadata before.
- `charge` which is now `technic:charge`, since any item (also from other mods) may have a technic charge which can cause compatibility problems.

Backwards compatibility is kept but going back to older `technic` versions might result in misbehaving circuits.
2024-01-22 18:27:54 +01:00
410e341da5 HV Reactor: Improve formspec layout 2024-01-09 21:51:08 +01:00
5826c2feaa Fix outdated dependency links (#627) 2024-01-06 12:26:20 +01:00
b221d69717 Remove duplicated textures
Now the ingot textures provided by commit 83e9cab3 are loaded
2023-12-19 18:59:46 +01:00
a296446da1 Add granite brick node (#593) 2023-12-19 18:25:45 +01:00
122 changed files with 418 additions and 343 deletions

View File

@ -15,10 +15,10 @@ world. A few notable features:
* Minetest 5.0.0 or newer * Minetest 5.0.0 or newer
* [Minetest Game](https://github.com/minetest/minetest_game/) * [Minetest Game](https://github.com/minetest/minetest_game/)
* [mesecons](https://github.com/minetest-mods/mesecons) -> signalling events * [mesecons](https://github.com/minetest-mods/mesecons) -> signalling events
* [pipeworks](https://gitlab.com/VanessaE/pipeworks/) -> automation of item transport * [pipeworks](https://github.com/mt-mods/pipeworks) -> automation of item transport
* [moreores](https://github.com/minetest-mods/moreores/) -> additional ores * [moreores](https://github.com/minetest-mods/moreores/) -> additional ores
* [basic_materials](https://gitlab.com/VanessaE/basic_materials) -> basic craft items * [basic_materials](https://github.com/mt-mods/basic_materials) -> basic craft items
* Supports [moretrees](https://gitlab.com/VanessaE/moretrees) -> rubber trees * Supports [moretrees](https://github.com/mt-mods/moretrees) -> rubber trees
* Consult `depends.txt` or `mod.conf` of each mod for further dependency information. * Consult `depends.txt` or `mod.conf` of each mod for further dependency information.

View File

@ -27,6 +27,12 @@ if minetest.get_modpath("moreblocks") then
tiles={"technic_granite.png"}, tiles={"technic_granite.png"},
}) })
stairsplus:register_all("technic", "granite_bricks", "technic:granite_bricks", {
description=S("Granite Bricks"),
groups={cracky=1, not_in_creative_inventory=1},
tiles={"technic_granite_bricks.png"},
})
stairsplus:register_all("technic", "concrete", "technic:concrete", { stairsplus:register_all("technic", "concrete", "technic:concrete", {
description=S("Concrete"), description=S("Concrete"),
groups={cracky=3, not_in_creative_inventory=1}, groups={cracky=3, not_in_creative_inventory=1},

View File

@ -65,15 +65,26 @@ function technic.swap_node(pos, name)
end end
--- Returns the meta of an item
-- Gets overridden when legacy.lua is loaded
function technic.get_stack_meta(itemstack)
return itemstack:get_meta()
end
--- Same as technic.get_stack_meta for cans
function technic.get_stack_meta_cans(itemstack)
return itemstack:get_meta()
end
--- Fully charge RE chargeable item. --- Fully charge RE chargeable item.
-- Must be defined early to reference in item definitions. -- Must be defined early to reference in item definitions.
function technic.refill_RE_charge(stack) function technic.refill_RE_charge(stack)
local max_charge = technic.power_tools[stack:get_name()] local max_charge = technic.power_tools[stack:get_name()]
if not max_charge then return stack end if not max_charge then return stack end
local meta = technic.get_stack_meta(stack)
meta:set_int("technic:charge", max_charge)
technic.set_RE_wear(stack, max_charge, max_charge) technic.set_RE_wear(stack, max_charge, max_charge)
local meta = minetest.deserialize(stack:get_metadata()) or {}
meta.charge = max_charge
stack:set_metadata(minetest.serialize(meta))
return stack return stack
end end

View File

@ -39,3 +39,40 @@ for i = 0, 64 do
minetest.register_alias("technic:lv_cable"..i, "technic:lv_cable") minetest.register_alias("technic:lv_cable"..i, "technic:lv_cable")
end end
-- Item meta
-- Meta keys that have changed
technic.legacy_meta_keys = {
["charge"] = "technic:charge",
}
-- Converts legacy itemstack metadata string to itemstack meta and returns the ItemStackMetaRef
function technic.get_stack_meta(itemstack)
local meta = itemstack:get_meta()
local legacy_string = meta:get("") -- Get deprecated metadata
if legacy_string then
local legacy_table = minetest.deserialize(legacy_string)
if legacy_table then
local table = meta:to_table()
for k, v in pairs(legacy_table) do
table.fields[technic.legacy_meta_keys[k] or k] = v
end
meta:from_table(table)
end
meta:set_string("", "") -- Remove deprecated metadata
end
return meta
end
-- Same as technic.get_stack_meta for cans.
-- (Cans didn't store a serialized table in the legacy metadata string, but just a number.)
function technic.get_stack_meta_cans(itemstack)
local meta = itemstack:get_meta()
local legacy_string = meta:get("") -- Get deprecated metadata
if legacy_string then
meta:set_string("can_level", legacy_string)
meta:set_string("", "") -- Remove deprecated metadata
return meta
end
return meta
end

View File

@ -31,24 +31,26 @@ minetest.register_craft({
}) })
local function make_reactor_formspec(meta) local function make_reactor_formspec(meta)
local f = "size[8,9]".. local f =
"label[0,0;"..S("Nuclear Reactor Rod Compartment").."]".. "formspec_version[4]"..
"list[current_name;src;2,1;3,2;]".. "size[10.75,10.75]"..
"list[current_player;main;0,5;8,4;]".. "label[0.2,0.4;"..S("Nuclear Reactor Rod Compartment").."]"..
"list[current_name;src;1.5,1;3,2;]"..
"list[current_player;main;0.5,5.5;8,4;]"..
"listring[]".. "listring[]"..
"button[5.5,1.5;2,1;start;Start]".. "button[5.7,1;2,1;start;Start]"..
"checkbox[5.5,2.5;autostart;automatic Start;"..meta:get_string("autostart").."]" "checkbox[5.7,2.75;autostart;automatic Start;"..meta:get_string("autostart").."]"
if not digiline_remote_path then if not digiline_remote_path then
return f return f
end end
local digiline_enabled = meta:get_string("enable_digiline") local digiline_enabled = meta:get_string("enable_digiline")
f = f.."checkbox[0.5,2.8;enable_digiline;Enable Digiline;"..digiline_enabled.."]" f = f.."checkbox[1.5,3.75;enable_digiline;Enable Digiline channel;"..digiline_enabled.."]"
if digiline_enabled ~= "true" then if digiline_enabled ~= "true" then
return f return f
end end
return f.. return f..
"button_exit[4.6,3.69;2,1;save;Save]".. "field[2,4.2;4.25,1;remote_channel;;${remote_channel}]" ..
"field[1,4;4,1;remote_channel;Digiline Remote Channel;${remote_channel}]" "button_exit[6.5,4.2;2,1;save;Save]"
end end
local SS_OFF = 0 local SS_OFF = 0
@ -140,8 +142,11 @@ of a lead layer it will be converted to a lead layer.
--]] --]]
local function reactor_structure_badness(pos) local function reactor_structure_badness(pos)
local vm = VoxelManip() local vm = VoxelManip()
-- Blast-resistant Concrete Block layer outer positions
local pos1 = vector.subtract(pos, 3) local pos1 = vector.subtract(pos, 3)
local pos2 = vector.add(pos, 3) local pos2 = vector.add(pos, 3)
local MinEdge, MaxEdge = vm:read_from_map(pos1, pos2) local MinEdge, MaxEdge = vm:read_from_map(pos1, pos2)
local data = vm:get_data() local data = vm:get_data()
local area = VoxelArea:new({MinEdge=MinEdge, MaxEdge=MaxEdge}) local area = VoxelArea:new({MinEdge=MinEdge, MaxEdge=MaxEdge})
@ -157,16 +162,19 @@ local function reactor_structure_badness(pos)
for z = pos1.z, pos2.z do for z = pos1.z, pos2.z do
for y = pos1.y, pos2.y do for y = pos1.y, pos2.y do
for x = pos1.x, pos2.x do for x = pos1.x, pos2.x do
-- In the entire volume, make sure there is:
local cid = data[area:index(x, y, z)] local cid = data[area:index(x, y, z)]
if x == pos1.x or x == pos2.x or if x == pos1.x or x == pos2.x or
y == pos1.y or y == pos2.y or y == pos1.y or y == pos2.y or
z == pos1.z or z == pos2.z then z == pos1.z or z == pos2.z then
-- r=3 : Blast-resistant Concrete Block shell
if cid == c_blast_concrete then if cid == c_blast_concrete then
blast_layer = blast_layer + 1 blast_layer = blast_layer + 1
end end
elseif x == pos1.x+1 or x == pos2.x-1 or elseif x == pos1.x+1 or x == pos2.x-1 or
y == pos1.y+1 or y == pos2.y-1 or y == pos1.y+1 or y == pos2.y-1 or
z == pos1.z+1 or z == pos2.z-1 then z == pos1.z+1 or z == pos2.z-1 then
-- r=2 : Lead Block shell
if cid == c_lead then if cid == c_lead then
lead_layer = lead_layer + 1 lead_layer = lead_layer + 1
elseif cid == c_steel then elseif cid == c_steel then
@ -175,6 +183,7 @@ local function reactor_structure_badness(pos)
elseif x == pos1.x+2 or x == pos2.x-2 or elseif x == pos1.x+2 or x == pos2.x-2 or
y == pos1.y+2 or y == pos2.y-2 or y == pos1.y+2 or y == pos2.y-2 or
z == pos1.z+2 or z == pos2.z-2 then z == pos1.z+2 or z == pos2.z-2 then
-- r=1 : Water cooling
if cid == c_water_source or cid == c_water_flowing then if cid == c_water_source or cid == c_water_flowing then
water_layer = water_layer + 1 water_layer = water_layer + 1
end end
@ -184,6 +193,8 @@ local function reactor_structure_badness(pos)
end end
if steel_layer >= 96 then if steel_layer >= 96 then
-- Legacy: convert stainless steel to lead
-- Why don't we accept both without conversion?
for z = pos1.z+1, pos2.z-1 do for z = pos1.z+1, pos2.z-1 do
for y = pos1.y+1, pos2.y-1 do for y = pos1.y+1, pos2.y-1 do
for x = pos1.x+1, pos2.x-1 do for x = pos1.x+1, pos2.x-1 do
@ -206,6 +217,7 @@ local function reactor_structure_badness(pos)
if water_layer > 25 then water_layer = 25 end if water_layer > 25 then water_layer = 25 end
if lead_layer > 96 then lead_layer = 96 end if lead_layer > 96 then lead_layer = 96 end
if blast_layer > 216 then blast_layer = 216 end if blast_layer > 216 then blast_layer = 216 end
-- Amount of missing blocks
return (25 - water_layer) + (96 - lead_layer) + (216 - blast_layer) return (25 - water_layer) + (96 - lead_layer) + (216 - blast_layer)
end end
@ -297,7 +309,7 @@ local function run(pos, node)
end end
meta:set_int("HV_EU_supply", 0) meta:set_int("HV_EU_supply", 0)
meta:set_int("burn_time", 0) meta:set_int("burn_time", 0)
meta:set_string("infotext", S("%s Idle"):format(reactor_desc)) meta:set_string("infotext", S("@1 Idle", reactor_desc))
technic.swap_node(pos, "technic:hv_nuclear_reactor_core") technic.swap_node(pos, "technic:hv_nuclear_reactor_core")
meta:set_int("structure_accumulated_badness", 0) meta:set_int("structure_accumulated_badness", 0)
siren_clear(pos, meta) siren_clear(pos, meta)

View File

@ -415,12 +415,8 @@ local function default_get_charge(itemstack)
if not technic.power_tools[tool_name] then if not technic.power_tools[tool_name] then
return 0, 0 return 0, 0
end end
-- Set meta data for the tool if it didn't do it itself local item_meta = technic.get_stack_meta(itemstack)
local item_meta = minetest.deserialize(itemstack:get_metadata()) or {} return item_meta:get_int("technic:charge"), technic.power_tools[tool_name]
if not item_meta.charge then
item_meta.charge = 0
end
return item_meta.charge, technic.power_tools[tool_name]
end end
local function default_set_charge(itemstack, charge) local function default_set_charge(itemstack, charge)
@ -428,9 +424,8 @@ local function default_set_charge(itemstack, charge)
if technic.power_tools[tool_name] then if technic.power_tools[tool_name] then
technic.set_RE_wear(itemstack, charge, technic.power_tools[tool_name]) technic.set_RE_wear(itemstack, charge, technic.power_tools[tool_name])
end end
local item_meta = minetest.deserialize(itemstack:get_metadata()) or {} local item_meta = technic.get_stack_meta(itemstack)
item_meta.charge = charge item_meta:set_int("technic:charge", charge)
itemstack:set_metadata(minetest.serialize(item_meta))
end end
function technic.charge_tools(meta, batt_charge, charge_step) function technic.charge_tools(meta, batt_charge, charge_step)

View File

@ -21,27 +21,57 @@ local recipes = {
{"technic:uranium35_ingot 5", "technic:uranium_fuel"}, {"technic:uranium35_ingot 5", "technic:uranium_fuel"},
} }
if minetest.get_modpath("everness") then
local everness_sand_to_sandstone_recipes = {
{"everness:coral_deep_ocean_sand 2", "everness:coral_deep_ocean_sandstone_block"},
{"everness:coral_sand 2", "everness:coral_sandstone"},
{"everness:coral_white_sand 2", "everness:coral_white_sandstone"},
{"everness:crystal_forest_deep_ocean_sand 2", "everness:crystal_forest_deep_ocean_sandstone_block"},
{"everness:crystal_sand 2", "everness:crystal_sandstone"},
{"everness:cursed_lands_deep_ocean_sand 2", "everness:cursed_lands_deep_ocean_sandstone_block"},
{"everness:cursed_sand 2", "everness:cursed_sandstone_block"},
{"everness:mineral_sand 2", "everness:mineral_sandstone"},
}
for _, data in ipairs(everness_sand_to_sandstone_recipes) do
table.insert(recipes, {data[1], data[2]})
end
end
-- defuse the default sandstone recipe, since we have the compressor to take over in a more realistic manner -- defuse the default sandstone recipe, since we have the compressor to take over in a more realistic manner
local crafts_to_clear = {
"default:desert_sand",
"default:sand",
"default:silver_sand"
}
if minetest.get_modpath("everness") then
local everness_crafts_to_clear = {
"everness:coral_sand",
"everness:coral_forest_deep_ocean_sand",
"everness:coral_white_sand",
"everness:crystal_sand",
"everness:cursed_sand",
"everness:cursed_lands_deep_ocean_sand",
"everness:crystal_forest_deep_ocean_sand",
"everness:mineral_sand",
}
for _, sand_name in ipairs(everness_crafts_to_clear) do
table.insert(crafts_to_clear, sand_name)
end
end
for _, sand_name in ipairs(crafts_to_clear) do
minetest.clear_craft({ minetest.clear_craft({
type = "shaped",
recipe = { recipe = {
{"default:sand", "default:sand"}, {sand_name, sand_name},
{"default:sand", "default:sand"}, {sand_name, sand_name},
},
})
minetest.clear_craft({
recipe = {
{"default:desert_sand", "default:desert_sand"},
{"default:desert_sand", "default:desert_sand"},
},
})
minetest.clear_craft({
recipe = {
{"default:silver_sand", "default:silver_sand"},
{"default:silver_sand", "default:silver_sand"},
}, },
}) })
end
for _, data in pairs(recipes) do for _, data in pairs(recipes) do
technic.register_compressor_recipe({input = {data[1]}, output = data[2]}) technic.register_compressor_recipe({input = {data[1]}, output = data[2]})
end end

View File

@ -36,6 +36,17 @@ local recipes = {
{"default:ice", "default:snowblock"}, {"default:ice", "default:snowblock"},
} }
if minetest.get_modpath("everness") then
table.insert(recipes, {"everness:coral_deep_ocean_sandstone_block", "everness:coral_deep_ocean_sand 2"})
table.insert(recipes, {"everness:coral_sandstone", "everness:coral_sand 2"})
table.insert(recipes, {"everness:coral_white_sandstone", "everness:coral_white_sand 2"})
table.insert(recipes, {"everness:crystal_forest_deep_ocean_sandstone_block", "everness:crystal_forest_deep_ocean_sand 2"})
table.insert(recipes, {"everness:crystal_sandstone", "everness:crystal_sand 2"})
table.insert(recipes, {"everness:cursed_lands_deep_ocean_sandstone_block", "everness:cursed_lands_deep_ocean_sand 2"})
table.insert(recipes, {"everness:cursed_sandstone_block", "everness:cursed_sand 2"})
table.insert(recipes, {"everness:mineral_sandstone", "everness:mineral_sand 2"})
end
-- defuse the sandstone -> 4 sand recipe to avoid infinite sand bugs (also consult the inverse compressor recipe) -- defuse the sandstone -> 4 sand recipe to avoid infinite sand bugs (also consult the inverse compressor recipe)
minetest.clear_craft({ minetest.clear_craft({
recipe = { recipe = {
@ -53,6 +64,15 @@ minetest.clear_craft({
}, },
}) })
if minetest.get_modpath("everness") then
minetest.clear_craft({
recipe = {
{"everness:mineral_sandstone"}
},
})
-- Currently (2024-03-09), there seem to be no reverse recipes for any of the other everness sandstones.
end
if minetest.get_modpath("farming") then if minetest.get_modpath("farming") then
table.insert(recipes, {"farming:seed_wheat", "farming:flour 1"}) table.insert(recipes, {"farming:seed_wheat", "farming:flour 1"})
end end
@ -74,6 +94,10 @@ if minetest.get_modpath("homedecor") then
table.insert(recipes, {"home_decor:brass_ingot", "technic:brass_dust 1"}) table.insert(recipes, {"home_decor:brass_ingot", "technic:brass_dust 1"})
end end
if minetest.get_modpath("everness") then
table.insert(recipes, {"everness:pyrite_lump", "technic:pyrite_dust 2"})
end
for _, data in pairs(recipes) do for _, data in pairs(recipes) do
technic.register_grinder_recipe({input = {data[1]}, output = data[2]}) technic.register_grinder_recipe({input = {data[1]}, output = data[2]})
end end
@ -122,6 +146,9 @@ if minetest.get_modpath("gloopores") or minetest.get_modpath("glooptest") then
register_dust("Kalite", nil) register_dust("Kalite", nil)
register_dust("Talinite", "glooptest:talinite_ingot") register_dust("Talinite", "glooptest:talinite_ingot")
end end
if minetest.get_modpath("everness") then
register_dust("Pyrite", "everness:pyrite_ingot")
end
for p = 0, 35 do for p = 0, 35 do
local nici = (p ~= 0 and p ~= 7 and p ~= 35) and 1 or nil local nici = (p ~= 0 and p ~= 7 and p ~= 35) and 1 or nil

View File

@ -1,3 +1,3 @@
name = technic name = technic
depends = default, pipeworks, technic_worldgen, basic_materials depends = default, pipeworks, technic_worldgen, basic_materials
optional_depends = bucket, screwdriver, mesecons, mesecons_mvps, digilines, digiline_remote, intllib, unified_inventory, vector_extras, dye, craftguide,i3 optional_depends = bucket, screwdriver, mesecons, mesecons_mvps, digilines, digiline_remote, intllib, unified_inventory, vector_extras, dye, craftguide, i3, everness

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 675 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 405 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 736 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 778 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 778 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 743 B

View File

Before

Width:  |  Height:  |  Size: 181 B

After

Width:  |  Height:  |  Size: 181 B

View File

Before

Width:  |  Height:  |  Size: 251 B

After

Width:  |  Height:  |  Size: 251 B

View File

Before

Width:  |  Height:  |  Size: 168 B

After

Width:  |  Height:  |  Size: 168 B

View File

Before

Width:  |  Height:  |  Size: 194 B

After

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 457 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 501 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 517 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 511 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 457 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 407 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 682 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 660 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 763 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 674 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 483 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 807 B

View File

@ -12,14 +12,6 @@ local function set_can_wear(itemstack, level, max_level)
itemstack:set_wear(temp) itemstack:set_wear(temp)
end end
local function get_can_level(itemstack)
if itemstack:get_metadata() == "" then
return 0
else
return tonumber(itemstack:get_metadata())
end
end
function technic.register_can(d) function technic.register_can(d)
local data = {} local data = {}
for k, v in pairs(d) do data[k] = v end for k, v in pairs(d) do data[k] = v end
@ -33,7 +25,8 @@ function technic.register_can(d)
if pointed_thing.type ~= "node" then return end if pointed_thing.type ~= "node" then return end
local node = minetest.get_node(pointed_thing.under) local node = minetest.get_node(pointed_thing.under)
if node.name ~= data.liquid_source_name then return end if node.name ~= data.liquid_source_name then return end
local charge = get_can_level(itemstack) local meta = technic.get_stack_meta_cans(itemstack)
local charge = meta:get_int("can_level")
if charge == data.can_capacity then return end if charge == data.can_capacity then return end
if minetest.is_protected(pointed_thing.under, user:get_player_name()) then if minetest.is_protected(pointed_thing.under, user:get_player_name()) then
minetest.log("action", user:get_player_name().. minetest.log("action", user:get_player_name()..
@ -44,7 +37,7 @@ function technic.register_can(d)
end end
minetest.remove_node(pointed_thing.under) minetest.remove_node(pointed_thing.under)
charge = charge + 1 charge = charge + 1
itemstack:set_metadata(tostring(charge)) meta:set_int("can_level", charge)
set_can_wear(itemstack, charge, data.can_capacity) set_can_wear(itemstack, charge, data.can_capacity)
return itemstack return itemstack
end, end,
@ -63,7 +56,8 @@ function technic.register_can(d)
-- Try to place node above the pointed source, or abort. -- Try to place node above the pointed source, or abort.
if not def.buildable_to or node_name == data.liquid_source_name then return end if not def.buildable_to or node_name == data.liquid_source_name then return end
end end
local charge = get_can_level(itemstack) local meta = technic.get_stack_meta_cans(itemstack)
local charge = meta:get_int("can_level")
if charge == 0 then return end if charge == 0 then return end
if minetest.is_protected(pos, user:get_player_name()) then if minetest.is_protected(pos, user:get_player_name()) then
minetest.log("action", user:get_player_name().. minetest.log("action", user:get_player_name()..
@ -74,12 +68,13 @@ function technic.register_can(d)
end end
minetest.set_node(pos, {name=data.liquid_source_name}) minetest.set_node(pos, {name=data.liquid_source_name})
charge = charge - 1 charge = charge - 1
itemstack:set_metadata(tostring(charge)) meta:set_int("can_level", charge)
set_can_wear(itemstack, charge, data.can_capacity) set_can_wear(itemstack, charge, data.can_capacity)
return itemstack return itemstack
end, end,
on_refill = function(stack) on_refill = function(stack)
stack:set_metadata(tostring(data.can_capacity)) local meta = technic.get_stack_meta_cans(stack)
meta:set_int("can_level", data.can_capacity)
set_can_wear(stack, data.can_capacity, data.can_capacity) set_can_wear(stack, data.can_capacity, data.can_capacity)
return stack return stack
end, end,

View File

@ -313,10 +313,8 @@ minetest.register_tool("technic:chainsaw", {
return itemstack return itemstack
end end
local meta = minetest.deserialize(itemstack:get_metadata()) local meta = technic.get_stack_meta(itemstack)
if not meta or not meta.charge then local charge = meta:get_int("technic:charge")
return
end
local name = user:get_player_name() local name = user:get_player_name()
if minetest.is_protected(pointed_thing.under, name) then if minetest.is_protected(pointed_thing.under, name) then
@ -326,14 +324,14 @@ minetest.register_tool("technic:chainsaw", {
-- Send current charge to digging function so that the -- Send current charge to digging function so that the
-- chainsaw will stop after digging a number of nodes -- chainsaw will stop after digging a number of nodes
chainsaw_dig(user, pointed_thing.under, meta.charge) chainsaw_dig(user, pointed_thing.under, charge)
meta.charge = cutter.charge charge = cutter.charge
cutter = {} -- Free RAM cutter = {} -- Free RAM
if not technic.creative_mode then if not technic.creative_mode then
technic.set_RE_wear(itemstack, meta.charge, chainsaw_max_charge) meta:set_int("technic:charge", charge)
itemstack:set_metadata(minetest.serialize(meta)) technic.set_RE_wear(itemstack, charge, chainsaw_max_charge)
end end
return itemstack return itemstack
end, end,

View File

@ -38,12 +38,13 @@ local function check_for_flashlight(player)
local hotbar = inv:get_list("main") local hotbar = inv:get_list("main")
for i = 1, 8 do for i = 1, 8 do
if hotbar[i]:get_name() == "technic:flashlight" then if hotbar[i]:get_name() == "technic:flashlight" then
local meta = minetest.deserialize(hotbar[i]:get_metadata()) local meta = technic.get_stack_meta(hotbar[i])
if meta and meta.charge and meta.charge >= 2 then local charge = meta:get_int("technic:charge")
if charge >= 2 then
if not technic.creative_mode then if not technic.creative_mode then
meta.charge = meta.charge - 2; charge = charge - 2;
technic.set_RE_wear(hotbar[i], meta.charge, flashlight_max_charge) meta:set_int("technic:charge", charge)
hotbar[i]:set_metadata(minetest.serialize(meta)) technic.set_RE_wear(hotbar[i], charge, flashlight_max_charge)
inv:set_stack("main", i, hotbar[i]) inv:set_stack("main", i, hotbar[i])
end end
return true return true

View File

@ -248,54 +248,53 @@ end
local function mining_drill_mkX_setmode(user, itemstack, drill_type, max_modes) local function mining_drill_mkX_setmode(user, itemstack, drill_type, max_modes)
local player_name = user:get_player_name() local player_name = user:get_player_name()
local meta = minetest.deserialize(itemstack:get_metadata()) or {} local meta = technic.get_stack_meta(itemstack)
if not meta["mode"] then if not meta:contains("mode") then
minetest.chat_send_player(player_name, minetest.chat_send_player(player_name,
S("Use while sneaking to change Mining Drill Mk%d modes."):format(drill_type)) S("Use while sneaking to change Mining Drill Mk%d modes."):format(drill_type))
end end
local mode = (meta["mode"] or 0) + 1 local mode = meta:get_int("mode") + 1
if mode > max_modes then mode = 1 end if mode > max_modes then mode = 1 end
minetest.chat_send_player(player_name, minetest.chat_send_player(player_name,
S("Mining Drill Mk%d Mode %d"):format(2, mode).. S("Mining Drill Mk%d Mode %d"):format(2, mode)..
": "..mining_drill_mode_text[mode][1]) ": "..mining_drill_mode_text[mode][1])
itemstack:set_name(("technic:mining_drill_mk%d_%s"):format(drill_type, mode)) itemstack:set_name(("technic:mining_drill_mk%d_%s"):format(drill_type, mode))
meta["mode"] = mode meta:set_int("mode", mode)
itemstack:set_metadata(minetest.serialize(meta))
return itemstack return itemstack
end end
local function mining_drill_mkX_handler(itemstack, user, pointed_thing, drill_type, max_modes) local function mining_drill_mkX_handler(itemstack, user, pointed_thing, drill_type, max_modes)
local keys = user:get_player_control() local keys = user:get_player_control()
local meta = minetest.deserialize(itemstack:get_metadata()) or {} local meta = technic.get_stack_meta(itemstack)
-- Mode switching (if possible) -- Mode switching (if possible)
if max_modes > 1 then if max_modes > 1 then
if not meta.mode or keys.sneak then if not meta:contains("mode") or keys.sneak then
return mining_drill_mkX_setmode(user, itemstack, drill_type, max_modes) return mining_drill_mkX_setmode(user, itemstack, drill_type, max_modes)
end end
end end
if pointed_thing.type ~= "node" or not pos_is_pointable(pointed_thing.under) then if pointed_thing.type ~= "node" or not pos_is_pointable(pointed_thing.under) then
return return
end end
if not meta.charge then
return local charge = meta:get_int("technic:charge")
end local mode = meta:contains("mode") and meta:get_int("mode") or 1
-- Check whether the tool has enough charge -- Check whether the tool has enough charge
local charge_to_take = cost_to_use(drill_type, meta.mode or 1) local charge_to_take = cost_to_use(drill_type, mode)
if meta.charge < charge_to_take then if charge < charge_to_take then
return return
end end
-- Do the actual shoorting action -- Do the actual shoorting action
local pos = minetest.get_pointed_thing_position(pointed_thing, false) local pos = minetest.get_pointed_thing_position(pointed_thing, false)
drill_dig_it(pos, user, meta.mode or 1) drill_dig_it(pos, user, mode)
if not technic.creative_mode then if not technic.creative_mode then
meta.charge = meta.charge - charge_to_take charge = charge - charge_to_take
itemstack:set_metadata(minetest.serialize(meta)) meta:set_int("technic:charge", charge)
technic.set_RE_wear(itemstack, meta.charge, max_charge[drill_type]) technic.set_RE_wear(itemstack, charge, max_charge[drill_type])
end end
return itemstack return itemstack
end end

View File

@ -101,25 +101,26 @@ for _, m in pairs(mining_lasers_list) do
wear_represents = "technic_RE_charge", wear_represents = "technic_RE_charge",
on_refill = technic.refill_RE_charge, on_refill = technic.refill_RE_charge,
on_use = function(itemstack, user) on_use = function(itemstack, user)
local meta = minetest.deserialize(itemstack:get_metadata()) local meta = technic.get_stack_meta(itemstack)
if not meta or not meta.charge or meta.charge == 0 then local charge = meta:get_int("technic:charge")
if charge == 0 then
return return
end end
local range = m[2] local range = m[2]
if meta.charge < m[4] then if charge < m[4] then
if not allow_entire_discharging then if not allow_entire_discharging then
return return
end end
-- If charge is too low, give the laser a shorter range -- If charge is too low, give the laser a shorter range
range = range * meta.charge / m[4] range = range * charge / m[4]
end end
laser_shoot(user, range, "technic_laser_beam_mk" .. m[1] .. ".png", laser_shoot(user, range, "technic_laser_beam_mk" .. m[1] .. ".png",
"technic_laser_mk" .. m[1]) "technic_laser_mk" .. m[1])
if not technic.creative_mode then if not technic.creative_mode then
meta.charge = math.max(meta.charge - m[4], 0) charge = math.max(charge - m[4], 0)
technic.set_RE_wear(itemstack, meta.charge, m[3]) meta:set_int("technic:charge", charge)
itemstack:set_metadata(minetest.serialize(meta)) technic.set_RE_wear(itemstack, charge, m[3])
end end
return itemstack return itemstack
end, end,

View File

@ -2,14 +2,16 @@ local S = technic.getter
technic.register_power_tool("technic:prospector", 300000) technic.register_power_tool("technic:prospector", 300000)
local function get_metadata(toolstack) -- Helper function to consolidate ItemStackMetaRef access and initialize
local m = minetest.deserialize(toolstack:get_metadata()) local function meta_to_table(meta)
if not m then m = {} end local t = {}
if not m.charge then m.charge = 0 end local mt = meta:to_table()
if not m.target then m.target = "" end
if not m.look_depth then m.look_depth = 7 end t.charge = tonumber(mt.fields["technic:charge"]) or 0
if not m.look_radius then m.look_radius = 1 end t.target = mt.fields.target or ""
return m t.look_depth = tonumber(mt.fields.look_depth) or 7
t.look_radius = tonumber(mt.fields.look_radius) or 1
return t
end end
minetest.register_tool("technic:prospector", { minetest.register_tool("technic:prospector", {
@ -20,7 +22,8 @@ minetest.register_tool("technic:prospector", {
on_use = function(toolstack, user, pointed_thing) on_use = function(toolstack, user, pointed_thing)
if not user or not user:is_player() or user.is_fake_player then return end if not user or not user:is_player() or user.is_fake_player then return end
if pointed_thing.type ~= "node" then return end if pointed_thing.type ~= "node" then return end
local toolmeta = get_metadata(toolstack) local meta = technic.get_stack_meta(toolstack)
local toolmeta = meta_to_table(meta)
local look_diameter = toolmeta.look_radius * 2 + 1 local look_diameter = toolmeta.look_radius * 2 + 1
local charge_to_take = toolmeta.look_depth * (toolmeta.look_depth + 1) * look_diameter * look_diameter local charge_to_take = toolmeta.look_depth * (toolmeta.look_depth + 1) * look_diameter * look_diameter
if toolmeta.charge < charge_to_take then return end if toolmeta.charge < charge_to_take then return end
@ -30,7 +33,7 @@ minetest.register_tool("technic:prospector", {
end end
if not technic.creative_mode then if not technic.creative_mode then
toolmeta.charge = toolmeta.charge - charge_to_take toolmeta.charge = toolmeta.charge - charge_to_take
toolstack:set_metadata(minetest.serialize(toolmeta)) meta:set_int("technic:charge", toolmeta.charge)
technic.set_RE_wear(toolstack, toolmeta.charge, technic.power_tools[toolstack:get_name()]) technic.set_RE_wear(toolstack, toolmeta.charge, technic.power_tools[toolstack:get_name()])
end end
-- What in the heaven's name is this evil sorcery ? -- What in the heaven's name is this evil sorcery ?
@ -77,7 +80,8 @@ minetest.register_tool("technic:prospector", {
end, end,
on_place = function(toolstack, user, pointed_thing) on_place = function(toolstack, user, pointed_thing)
if not user or not user:is_player() or user.is_fake_player then return end if not user or not user:is_player() or user.is_fake_player then return end
local toolmeta = get_metadata(toolstack) local meta = technic.get_stack_meta(toolstack)
local toolmeta = meta_to_table(meta)
local pointed local pointed
if pointed_thing.type == "node" then if pointed_thing.type == "node" then
local pname = minetest.get_node(pointed_thing.under).name local pname = minetest.get_node(pointed_thing.under).name
@ -125,19 +129,16 @@ minetest.register_on_player_receive_fields(function(user, formname, fields)
if not user or not user:is_player() or user.is_fake_player then return end if not user or not user:is_player() or user.is_fake_player then return end
local toolstack = user:get_wielded_item() local toolstack = user:get_wielded_item()
if toolstack:get_name() ~= "technic:prospector" then return true end if toolstack:get_name() ~= "technic:prospector" then return true end
local toolmeta = get_metadata(toolstack) local meta = technic.get_stack_meta(toolstack)
for field, value in pairs(fields) do for field, value in pairs(fields) do
if field:sub(1, 7) == "target_" then if field:sub(1, 7) == "target_" then
toolmeta.target = field:sub(8) meta:set_string("target", field:sub(8))
end elseif field:sub(1, 12) == "look_radius_" then
if field:sub(1, 12) == "look_radius_" then meta:set_string("look_radius", field:sub(13))
toolmeta.look_radius = field:sub(13) elseif field:sub(1, 11) == "look_depth_" then
end meta:set_string("look_depth", field:sub(12))
if field:sub(1, 11) == "look_depth_" then
toolmeta.look_depth = field:sub(12)
end end
end end
toolstack:set_metadata(minetest.serialize(toolmeta))
user:set_wielded_item(toolstack) user:set_wielded_item(toolstack)
return true return true
end) end)

View File

@ -41,8 +41,9 @@ local function screwdriver_handler(itemstack, user, pointed_thing, mode)
-- contrary to the default screwdriver, do not check for can_dig, to allow rotating machines with CLU's in them -- contrary to the default screwdriver, do not check for can_dig, to allow rotating machines with CLU's in them
-- this is consistent with the previous sonic screwdriver -- this is consistent with the previous sonic screwdriver
local meta1 = minetest.deserialize(itemstack:get_metadata()) local meta = technic.get_stack_meta(itemstack)
if not meta1 or not meta1.charge or meta1.charge < 100 then local charge = meta:get_int("technic:charge")
if charge < 100 then
return return
end end
@ -64,9 +65,9 @@ local function screwdriver_handler(itemstack, user, pointed_thing, mode)
minetest.swap_node(pos, node) minetest.swap_node(pos, node)
if not technic.creative_mode then if not technic.creative_mode then
meta1.charge = meta1.charge - 100 charge = charge - 100
itemstack:set_metadata(minetest.serialize(meta1)) meta:set_int("technic:charge", charge)
technic.set_RE_wear(itemstack, meta1.charge, sonic_screwdriver_max_charge) technic.set_RE_wear(itemstack, charge, sonic_screwdriver_max_charge)
end end
return itemstack return itemstack

View File

@ -14,24 +14,23 @@ minetest.register_tool("technic:vacuum", {
wear_represents = "technic_RE_charge", wear_represents = "technic_RE_charge",
on_refill = technic.refill_RE_charge, on_refill = technic.refill_RE_charge,
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
local meta = minetest.deserialize(itemstack:get_metadata()) local meta = technic.get_stack_meta(itemstack)
if not meta or not meta.charge then local charge = meta:get_int("technic:charge")
if charge < vacuum_charge_per_object then
return return
end end
if meta.charge > vacuum_charge_per_object then
minetest.sound_play("vacuumcleaner", { minetest.sound_play("vacuumcleaner", {
to_player = user:get_player_name(), to_player = user:get_player_name(),
gain = 0.4, gain = 0.4,
}) })
end
local pos = user:get_pos() local pos = user:get_pos()
local inv = user:get_inventory() local inv = user:get_inventory()
for _, object in ipairs(minetest.get_objects_inside_radius(pos, vacuum_range)) do for _, object in ipairs(minetest.get_objects_inside_radius(pos, vacuum_range)) do
local luaentity = object:get_luaentity() local luaentity = object:get_luaentity()
if not object:is_player() and luaentity and luaentity.name == "__builtin:item" and luaentity.itemstring ~= "" then if not object:is_player() and luaentity and luaentity.name == "__builtin:item" and luaentity.itemstring ~= "" then
if inv and inv:room_for_item("main", ItemStack(luaentity.itemstring)) then if inv and inv:room_for_item("main", ItemStack(luaentity.itemstring)) then
meta.charge = meta.charge - vacuum_charge_per_object charge = charge - vacuum_charge_per_object
if meta.charge < vacuum_charge_per_object then if charge < vacuum_charge_per_object then
return return
end end
inv:add_item("main", ItemStack(luaentity.itemstring)) inv:add_item("main", ItemStack(luaentity.itemstring))
@ -45,8 +44,8 @@ minetest.register_tool("technic:vacuum", {
end end
end end
technic.set_RE_wear(itemstack, meta.charge, vacuum_max_charge) meta:set_int("technic:charge", charge)
itemstack:set_metadata(minetest.serialize(meta)) technic.set_RE_wear(itemstack, charge, vacuum_max_charge)
return itemstack return itemstack
end, end,
}) })

View File

@ -29,7 +29,7 @@ if technic_cnc.use_technic then
allow_metadata_inventory_take = technic.machine_inventory_take allow_metadata_inventory_take = technic.machine_inventory_take
allow_metadata_inventory_move = technic.machine_inventory_move allow_metadata_inventory_move = technic.machine_inventory_move
can_dig = technic.machine_can_dig can_dig = technic.machine_can_dig
desc_tr = S("%s CNC Machine"):format("LV") desc_tr = S("@1 CNC Machine", S("LV"))
else else
minetest.register_craft({ minetest.register_craft({
output = 'technic:cnc', output = 'technic:cnc',
@ -130,9 +130,9 @@ local cnc_formspec =
"image_button[5,4;1,1;technic_cnc_element_t.png;element_t; ]".. "image_button[5,4;1,1;technic_cnc_element_t.png;element_t; ]"..
"image_button[6,4;1,1;technic_cnc_element_edge.png;element_edge; ]".. "image_button[6,4;1,1;technic_cnc_element_edge.png;element_edge; ]"..
"label[0, 5.5;"..S("In:").."]".. "label[0, 5;"..S("In:").."]"..
"list[current_name;src;0.5,5.5;1,1;]".. "list[current_name;src;0.5,5.5;1,1;]"..
"label[4, 5.5;"..S("Out:").."]".. "label[4, 5;"..S("Out:").."]"..
"list[current_name;dst;5,5.5;4,1;]".. "list[current_name;dst;5,5.5;4,1;]"..
"list[current_player;main;0,7;8,4;]".. "list[current_player;main;0,7;8,4;]"..
@ -221,7 +221,7 @@ local run = function(pos, node)
(not minetest.registered_nodes[result]) or (not minetest.registered_nodes[result]) or
(not inv:room_for_item("dst", result)) then (not inv:room_for_item("dst", result)) then
technic.swap_node(pos, machine_node) technic.swap_node(pos, machine_node)
meta:set_string("infotext", S("%s Idle"):format(machine_name)) meta:set_string("infotext", S("@1 Idle", machine_name))
meta:set_string("cnc_product", "") meta:set_string("cnc_product", "")
meta:set_int("LV_EU_demand", 0) meta:set_int("LV_EU_demand", 0)
return return
@ -229,10 +229,10 @@ local run = function(pos, node)
if eu_input < demand then if eu_input < demand then
technic.swap_node(pos, machine_node) technic.swap_node(pos, machine_node)
meta:set_string("infotext", S("%s Unpowered"):format(machine_name)) meta:set_string("infotext", S("@1 Unpowered", machine_name))
elseif eu_input >= demand then elseif eu_input >= demand then
technic.swap_node(pos, machine_node.."_active") technic.swap_node(pos, machine_node.."_active")
meta:set_string("infotext", S("%s Active"):format(machine_name)) meta:set_string("infotext", S("@1 Active", machine_name))
meta:set_int("src_time", meta:get_int("src_time") + 1) meta:set_int("src_time", meta:get_int("src_time") + 1)
if meta:get_int("src_time") >= 3 then -- 3 ticks per output if meta:get_int("src_time") >= 3 then -- 3 ticks per output
meta:set_int("src_time", 0) meta:set_int("src_time", 0)

Some files were not shown because too many files have changed in this diff Show More