diff options
author | root <root@linux-forks.de> | 2018-08-09 17:35:47 +0200 |
---|---|---|
committer | root <root@linux-forks.de> | 2018-08-09 17:35:47 +0200 |
commit | ee4c2f4e0ed0e697beef2341eda8885492da8368 (patch) | |
tree | 762fa254c65dee1c8fd7873eed05a282862e2316 | |
parent | 004728dcd1c90770dad6b69b83ac464b682369e6 (diff) | |
parent | 0ea43eb6d5217bf696371e8df22b07f34bf2abfa (diff) |
Merge https://github.com/h-v-smacker/technic
25 files changed, 576 insertions, 32 deletions
diff --git a/extranodes/init.lua b/extranodes/init.lua index edaa41a..d986b6e 100644 --- a/extranodes/init.lua +++ b/extranodes/init.lua @@ -10,6 +10,7 @@ dofile(path.."/trampoline.lua") dofile(path.."/extratubes.lua") dofile(path.."/extramesecons.lua") dofile(path.."/lox.lua") +dofile(path.."/plastic_block.lua") if minetest.get_modpath("ethereal") and minetest.get_modpath("flowers") then dofile(path.."/antishroom.lua") diff --git a/extranodes/plastic_block.lua b/extranodes/plastic_block.lua new file mode 100644 index 0000000..6ab6a7f --- /dev/null +++ b/extranodes/plastic_block.lua @@ -0,0 +1,128 @@ +local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end + +local plastic_nodes = { + {node = "plastic_clean", name = S("Plastic Clean"), tiles = {"technic_plastic_clean.png"}}, + {node = "plastic_siding_1", name = S("Plastic Siding Block 1"), tiles = {"technic_plastic_siding_1.png"}}, + {node = "plastic_siding_2", name = S("Plastic Siding Block 2"), tiles = {"technic_plastic_siding_2.png"}}, + {node = "plastic_siding_3", name = S("Plastic Siding Block 3"), tiles = {"technic_plastic_siding_3.png"}}, + {node = "plastic_bricks", name = S("Plastic Bricks"), tiles = {"technic_plastic_bricks.png"}}, + {node = "plastic_block", name = S("Plastic Block"), tiles = {"technic_plastic_block.png"}}, + {node = "plastic_cross", name = S("Plastic Cross"), tiles = {"technic_plastic_cross.png"}}, + {node = "plastic_waves", name = S("Plastic Waves"), tiles = {"technic_plastic_waves.png"}}, + {node = "plastic_tiles", name = S("Plastic Tiles"), tiles = {"technic_plastic_tiles.png"}}, +} + +for _,n in pairs(plastic_nodes) do + + minetest.register_node (":technic:" .. n.node, { + description = n.name, + drawtype = "normal", + tiles = n.tiles, + drop = "technic:" .. n.node, + groups = {dig_immediate = 2, paintable_plastic_block = 1}, + paramtype = "light", + paramtype2 = "colorwallmounted", + palette = "technic_paint_palette.png", + }) + +end + +local thin_nodes = { + {node = "plastic_siding_1", name = S("Plastic Siding 1"), tiles = {"technic_plastic_siding_1.png"}}, + {node = "plastic_siding_2", name = S("Plastic Siding 2"), tiles = {"technic_plastic_siding_2.png"}}, + {node = "plastic_siding_3", name = S("Plastic Siding 3"), tiles = {"technic_plastic_siding_3.png"}}, +} + +for _,n in pairs(thin_nodes) do + + minetest.register_node (":technic:" .. n.node .. "_thin", { + description = n.name, + drawtype = "nodebox", + tiles = n.tiles, + node_box = { + type = "wallmounted", + wall_bottom = {-0.5, -0.5, -0.5, 0.5, -0.25, 0.5}, + wall_top = {-0.5, 0.25, -0.5, 0.5, 0.5, 0.5}, + wall_side = {-0.5, -0.5, -0.5, -0.25, 0.5, 0.5}, + }, + drop = "technic:" .. n.node .. "_thin", + groups = {dig_immediate = 2, paintable_plastic_block = 1}, + paramtype = "light", + paramtype2 = "colorwallmounted", + palette = "technic_paint_palette.png", + }) + +end + + + +minetest.register_craft({ + output = "technic:plastic_clean", + recipe = { + { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting"}, + { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting"}, + { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting"} + }, +}) + +minetest.register_craft({ + output = "technic:plastic_siding_1_thin 2", + recipe = { + {"technic:plastic_clean"}, + }, +}) + +minetest.register_craft({ + output = "technic:plastic_siding_1", + recipe = { + {"technic:plastic_siding_1_thin", "technic:plastic_siding_1_thin"}, + }, +}) + +minetest.register_craft({ + output = "technic:plastic_siding_2_thin 4", + recipe = { + { "technic:plastic_clean", "", ""}, + { "technic:plastic_clean", "", ""}, + }, +}) + +minetest.register_craft({ + output = "technic:plastic_siding_2", + recipe = { + {"technic:plastic_siding_2_thin", "technic:plastic_siding_2_thin"}, + }, +}) + +minetest.register_craft({ + output = "technic:plastic_siding_3_thin 6", + recipe = { + { "technic:plastic_clean", "", ""}, + { "technic:plastic_clean", "", ""}, + { "technic:plastic_clean", "", ""}, + }, +}) + +minetest.register_craft({ + output = "technic:plastic_siding_3", + recipe = { + {"technic:plastic_siding_3_thin", "technic:plastic_siding_3_thin"}, + }, +}) + +minetest.register_craft({ + output = "technic:plastic_bricks 4", + recipe = { + { "technic:plastic_clean", "technic:plastic_clean"}, + { "technic:plastic_clean", "technic:plastic_clean"}, + }, +}) + +minetest.register_craft({ + output = "technic:plastic_block 9", + recipe = { + { "technic:plastic_clean", "technic:plastic_clean", "technic:plastic_clean"}, + { "technic:plastic_clean", "technic:plastic_clean", "technic:plastic_clean"}, + { "technic:plastic_clean", "technic:plastic_clean", "technic:plastic_clean"}, + }, +}) diff --git a/extranodes/textures/technic_plastic_block.png b/extranodes/textures/technic_plastic_block.png Binary files differnew file mode 100644 index 0000000..7a7bc6c --- /dev/null +++ b/extranodes/textures/technic_plastic_block.png diff --git a/extranodes/textures/technic_plastic_bricks.png b/extranodes/textures/technic_plastic_bricks.png Binary files differnew file mode 100644 index 0000000..79d082a --- /dev/null +++ b/extranodes/textures/technic_plastic_bricks.png diff --git a/extranodes/textures/technic_plastic_clean.png b/extranodes/textures/technic_plastic_clean.png Binary files differnew file mode 100644 index 0000000..01c4ca7 --- /dev/null +++ b/extranodes/textures/technic_plastic_clean.png diff --git a/extranodes/textures/technic_plastic_cross.png b/extranodes/textures/technic_plastic_cross.png Binary files differnew file mode 100644 index 0000000..3257d2f --- /dev/null +++ b/extranodes/textures/technic_plastic_cross.png diff --git a/extranodes/textures/technic_plastic_siding_1.png b/extranodes/textures/technic_plastic_siding_1.png Binary files differnew file mode 100644 index 0000000..c1f451a --- /dev/null +++ b/extranodes/textures/technic_plastic_siding_1.png diff --git a/extranodes/textures/technic_plastic_siding_2.png b/extranodes/textures/technic_plastic_siding_2.png Binary files differnew file mode 100644 index 0000000..da3e736 --- /dev/null +++ b/extranodes/textures/technic_plastic_siding_2.png diff --git a/extranodes/textures/technic_plastic_siding_3.png b/extranodes/textures/technic_plastic_siding_3.png Binary files differnew file mode 100644 index 0000000..1588862 --- /dev/null +++ b/extranodes/textures/technic_plastic_siding_3.png diff --git a/extranodes/textures/technic_plastic_tiles.png b/extranodes/textures/technic_plastic_tiles.png Binary files differnew file mode 100644 index 0000000..e4aed57 --- /dev/null +++ b/extranodes/textures/technic_plastic_tiles.png diff --git a/extranodes/textures/technic_plastic_waves.png b/extranodes/textures/technic_plastic_waves.png Binary files differnew file mode 100644 index 0000000..997f81c --- /dev/null +++ b/extranodes/textures/technic_plastic_waves.png diff --git a/technic/depends.txt b/technic/depends.txt index c052452..55a0eff 100644 --- a/technic/depends.txt +++ b/technic/depends.txt @@ -9,4 +9,5 @@ digilines? digiline_remote? intllib? unified_inventory? -vector_extras?
\ No newline at end of file +vector_extras? +ehlphabet?
\ No newline at end of file diff --git a/technic/machines/other/init.lua b/technic/machines/other/init.lua index a67d1a1..a7e90d3 100644 --- a/technic/machines/other/init.lua +++ b/technic/machines/other/init.lua @@ -16,5 +16,7 @@ end -- Coal-powered machines dofile(path.."/coal_alloy_furnace.lua") dofile(path.."/coal_furnace.lua") +dofile(path.."/solar_furnace.lua") + dofile(path.."/anchor.lua") diff --git a/technic/machines/other/solar_furnace.lua b/technic/machines/other/solar_furnace.lua new file mode 100644 index 0000000..dba4789 --- /dev/null +++ b/technic/machines/other/solar_furnace.lua @@ -0,0 +1,206 @@ + +-- A solar furnace is an auxiliary device which allows to use cooking recipes +-- without fuel. The downside is half the speed of a fuel-consuming furnace +-- and the need to be exposed to maximal direct sunlight at all times (L = 15). + + +local S = technic.getter + +minetest.register_craft({ + output = 'technic:solar_furnace', + recipe = { + {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'}, + {'technic:composite_plate', 'default:furnace', 'technic:composite_plate'}, + {'technic:cast_iron_ingot', 'technic:cast_iron_ingot', 'technic:cast_iron_ingot'}, + } +}) + +local machine_name = S("Solar Furnace") +local formspec = + "size[8,9]".. + "label[0,0;"..machine_name.."]".. + "image[2,2;1,1;technic_power_meter_bg.png]".. + "list[current_name;src;2,1;1,1;]".. + "list[current_name;dst;5,1;2,2;]".. + "list[current_player;main;0,5;8,4;]".. + "listring[current_name;dst]".. + "listring[current_player;main]".. + "listring[current_name;src]".. + "listring[current_player;main]" + +minetest.register_node("technic:solar_furnace", { + description = machine_name, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-5/16, -1/2, -5/16, 5/16, 3/16, 5/16}, + {-1/2, 3/16, -1/2, 1/2, 1/2, 1/2}, + {-2/16, 1/2, -2/16, 2/16, 17/32, 2/16}, + }, + }, + tiles = {"technic_solar_furnace_top.png", "technic_solar_furnace_bottom.png", + "technic_solar_furnace_side.png", "technic_solar_furnace_side.png", + "technic_solar_furnace_side.png", "technic_solar_furnace_side.png"}, + paramtype2 = "facedir", + groups = {cracky=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_stone_defaults(), + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", formspec) + meta:set_string("infotext", machine_name) + local inv = meta:get_inventory() + inv:set_size("src", 1) + inv:set_size("dst", 4) + meta:set_int("elapsed", 0) + meta:set_int("cook_time", 0) + end, + can_dig = technic.machine_can_dig, + allow_metadata_inventory_put = technic.machine_inventory_put, + allow_metadata_inventory_take = technic.machine_inventory_take, + allow_metadata_inventory_move = technic.machine_inventory_move, +}) + +minetest.register_node("technic:solar_furnace_active", { + description = machine_name, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-5/16, -1/2, -5/16, 5/16, 3/16, 5/16}, + {-1/2, 3/16, -1/2, 1/2, 1/2, 1/2}, + {-2/16, 1/2, -2/16, 2/16, 17/32, 2/16}, + }, + }, + tiles = {"technic_solar_furnace_top.png", "technic_solar_furnace_bottom.png", + "technic_solar_furnace_side.png", "technic_solar_furnace_side.png", + "technic_solar_furnace_side.png", "technic_solar_furnace_side.png"}, + paramtype2 = "facedir", + light_source = 14, + drop = "technic:solar_furnace", + groups = {cracky=2, not_in_creative_inventory=1}, + legacy_facedir_simple = true, + sounds = default.node_sound_stone_defaults(), + can_dig = technic.machine_can_dig, + allow_metadata_inventory_put = technic.machine_inventory_put, + allow_metadata_inventory_take = technic.machine_inventory_take, + allow_metadata_inventory_move = technic.machine_inventory_move, +}) + +minetest.register_abm({ + label = "Machines: run solar furnace", + nodenames = {"technic:solar_furnace", "technic:solar_furnace_active"}, + interval = 1, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + + local recipe = nil + + if not meta:get_int("elapsed") then + meta:set_int("elapsed", 0) + end + + if not meta:get_int("cook_time") then + meta:set_int("cook_time", 0) + end + + local light_pos = {x = pos.x, y = pos.y + 1, z = pos.z} + + local powered = false + + local node = minetest.get_node_or_nil(light_pos) + + if minetest.get_node_light(light_pos) == 15 and node.name == "air" then + powered = true + end + + local result = technic.get_recipe("cooking", inv:get_list("src")) + if result and result.time then + meta:set_int("cook_time", result.time * 2) + end + + + + if powered then + + if result then + + if meta:get_int("elapsed") >= meta:get_int("cook_time") then + + local percent = 100 + meta:set_string("infotext", S("%s is active"):format(machine_name).." ("..percent.."%)") + meta:set_string("formspec", + "size[8,9]".. + "label[0,0;"..machine_name.."]".. + "image[2,2;1,1;technic_power_meter_bg.png^[lowpart:" .. percent .. ":technic_power_meter_fg.png]".. + "list[current_name;src;2,1;1,1;]".. + "list[current_name;dst;5,1;2,2;]".. + "list[current_player;main;0,5;8,4;]".. + "listring[current_name;dst]".. + "listring[current_player;main]".. + "listring[current_name;src]".. + "listring[current_player;main]") + + local result_stack = ItemStack(result.output) + if inv:room_for_item("dst", result_stack) then + inv:set_list("src", result.new_input) + inv:add_item("dst", result_stack) + end + + meta:set_int("elapsed", 0) + + local recipe = technic.get_recipe("cooking", inv:get_list("src")) + + if not recipe then + meta:set_string("infotext", S("%s is empty"):format(machine_name)) + technic.swap_node(pos, "technic:solar_furnace") + meta:set_string("formspec", formspec) + end + + else + + local percent = math.floor(meta:get_int("elapsed") / meta:get_int("cook_time") * 100) + if percent > 100 then + percent = 100 + end + meta:set_string("infotext", S("%s is active"):format(machine_name).." ("..percent.."%)") + technic.swap_node(pos, "technic:solar_furnace_active") + meta:set_string("formspec", + "size[8,9]".. + "label[0,0;"..machine_name.."]".. + "image[2,2;1,1;technic_power_meter_bg.png^[lowpart:" .. percent .. ":technic_power_meter_fg.png]".. + "list[current_name;src;2,1;1,1;]".. + "list[current_name;dst;5,1;2,2;]".. + "list[current_player;main;0,5;8,4;]".. + "listring[current_name;dst]".. + "listring[current_player;main]".. + "listring[current_name;src]".. + "listring[current_player;main]") + return + + meta:set_int("elapsed", meta:get_int("elapsed") + 1) + end + else + meta:set_int("elapsed", 0) + + meta:set_string("infotext", S("%s is empty"):format(machine_name)) + technic.swap_node(pos, "technic:solar_furnace") + meta:set_string("formspec", formspec) + end + + else + + meta:set_int("elapsed", 0) + + meta:set_string("infotext", S("%s cannot function\nMust be in full direct sunlight"):format(machine_name)) + technic.swap_node(pos, "technic:solar_furnace") + meta:set_string("formspec", formspec) + end + + + end, +}) + diff --git a/technic/machines/register/alloy_recipes.lua b/technic/machines/register/alloy_recipes.lua index 0d40b77..209d376 100644 --- a/technic/machines/register/alloy_recipes.lua +++ b/technic/machines/register/alloy_recipes.lua @@ -14,10 +14,10 @@ end local recipes = { {"technic:copper_dust 3", "technic:tin_dust", "technic:bronze_dust 4"}, {"default:copper_ingot 3", "moreores:tin_ingot", "default:bronze_ingot 4"}, - {"technic:wrought_iron_dust", "technic:coal_dust", "technic:carbon_steel_dust", 3}, - {"technic:wrought_iron_ingot", "technic:coal_dust", "technic:carbon_steel_ingot", 3}, - {"technic:carbon_steel_dust", "technic:coal_dust", "technic:cast_iron_dust", 3}, - {"technic:carbon_steel_ingot", "technic:coal_dust", "technic:cast_iron_ingot", 3}, + {"technic:wrought_iron_dust", "technic:coal_dust", "technic:carbon_steel_dust", 3}, + {"technic:wrought_iron_ingot", "technic:coal_dust", "technic:carbon_steel_ingot", 3}, + {"technic:carbon_steel_dust", "technic:coal_dust", "technic:cast_iron_dust", 3}, + {"technic:carbon_steel_ingot", "technic:coal_dust", "technic:cast_iron_ingot", 3}, {"technic:carbon_steel_dust 3", "technic:chromium_dust", "technic:stainless_steel_dust 4"}, {"technic:carbon_steel_ingot 3", "technic:chromium_ingot", "technic:stainless_steel_ingot 4"}, {"technic:copper_dust 2", "technic:zinc_dust", "technic:brass_dust 3"}, @@ -27,16 +27,19 @@ local recipes = { -- from https://en.wikipedia.org/wiki/Carbon_black -- The highest volume use of carbon black is as a reinforcing filler in rubber products, especially tires. -- "[Compounding a] pure gum vulcanizate … with 50% of its weight of carbon black improves its tensile strength and wear resistance …" - {"technic:raw_latex 4", "technic:coal_dust 2", "technic:rubber 6", 2}, - {"technic:raw_latex 3", "technic:sulfur_dust 1", "technic:latex_foam", 2}, + {"technic:raw_latex 4", "technic:coal_dust 2", "technic:rubber 6", 2}, + {"technic:raw_latex 3", "technic:sulfur_dust 1", "technic:latex_foam", 2}, + -- straightforward way to get red stone + {"default:stone", "dye:red", "default:desert_stone", 2}, + } if minetest.get_modpath("ethereal") then table.insert(recipes, {"ethereal:crystal_spike", "ethereal:fire_dust 2", "default:mese_crystal 2"}) if not minetest.get_modpath("bakedclay") then - table.insert(recipes, {"default:clay", "dye:red", "bakedclay:red"}) - table.insert(recipes, {"default:clay", "dye:orange", "bakedclay:orange"}) - table.insert(recipes, {"default:clay", "dye:grey", "bakedclay:grey"}) + table.insert(recipes, {"default:clay", "dye:red", "bakedclay:red", 3}) + table.insert(recipes, {"default:clay", "dye:orange", "bakedclay:orange", 3}) + table.insert(recipes, {"default:clay", "dye:grey", "bakedclay:grey", 3}) end if minetest.get_modpath("bonemeal") then table.insert(recipes, {"default:sand", "bonemeal:mulch", "ethereal:sandy 2"}) diff --git a/technic/machines/register/common.lua b/technic/machines/register/common.lua index f872fa2..0dcdbe1 100644 --- a/technic/machines/register/common.lua +++ b/technic/machines/register/common.lua @@ -130,12 +130,14 @@ function technic.handle_machine_pipeworks(pos, tube_upgrade, send_function) local x_velocity = 0 local z_velocity = 0 - -- Output is on the left side of the furnace - if node.param2 == 3 then pos1.z = pos1.z - 1 z_velocity = -1 end + -- The machines shall always eject items to the right side + -- This will be easy to remember, since the destination inventory is always on the right as well + if node.param2 == 3 then pos1.z = pos1.z - 1 z_velocity = 1 end if node.param2 == 2 then pos1.x = pos1.x - 1 x_velocity = -1 end - if node.param2 == 1 then pos1.z = pos1.z + 1 z_velocity = 1 end + if node.param2 == 1 then pos1.z = pos1.z + 1 z_velocity = -1 end if node.param2 == 0 then pos1.x = pos1.x + 1 x_velocity = 1 end + local output_tube_connected = false local node1 = minetest.get_node(pos1) if minetest.get_item_group(node1.name, "tubedevice") > 0 then diff --git a/technic/machines/register/compressor_recipes.lua b/technic/machines/register/compressor_recipes.lua index 3339981..6952e07 100644 --- a/technic/machines/register/compressor_recipes.lua +++ b/technic/machines/register/compressor_recipes.lua @@ -12,7 +12,9 @@ local recipes = { {"default:snowblock", "default:ice"}, {"default:sand 2", "default:sandstone"}, {"default:silver_sand 2", "default:silver_sandstone"}, - {"default:desert_sand", "default:desert_stone"}, +-- {"default:desert_sand", "default:desert_stone"}, +-- for consistency, any sand should be compressed into respective sandstone type + {"default:desert_sand 2", "default:desert_sandstone"}, {"technic:mixed_metal_ingot", "technic:composite_plate"}, {"default:copper_ingot 5", "technic:copper_plate"}, {"technic:coal_dust 4", "technic:graphite"}, @@ -24,6 +26,10 @@ local recipes = { if minetest.get_modpath("ethereal") then + -- substitute for old recipe chain + -- instead of 5 dry dirt -> 1 desert sand -> compressing -> desert_stone + table.insert(recipes, {"ethereal:dry_dirt 5", "default:desert_stone"}) + -- compressing most copious leaves into more compact fuel -- this conversion is based on the burn time (1 vs. 10) + some overhead table.insert(recipes, {"default:acacia_leaves 15", "ethereal:charcoal_lump 1"}) diff --git a/technic/machines/register/recipes.lua b/technic/machines/register/recipes.lua index f9e2458..810f691 100644 --- a/technic/machines/register/recipes.lua +++ b/technic/machines/register/recipes.lua @@ -67,6 +67,9 @@ end function technic.get_recipe(typename, items) if typename == "cooking" then -- Already builtin in Minetest, so use that + if not items then + return nil + end local result, new_input = minetest.get_craft_result({ method = "cooking", width = 1, diff --git a/technic/textures/technic_prospector_mk2.png b/technic/textures/technic_prospector_mk2.png Binary files differnew file mode 100644 index 0000000..e255dd7 --- /dev/null +++ b/technic/textures/technic_prospector_mk2.png diff --git a/technic/textures/technic_solar_furnace_bottom.png b/technic/textures/technic_solar_furnace_bottom.png Binary files differnew file mode 100644 index 0000000..bfefccb --- /dev/null +++ b/technic/textures/technic_solar_furnace_bottom.png diff --git a/technic/textures/technic_solar_furnace_side.png b/technic/textures/technic_solar_furnace_side.png Binary files differnew file mode 100644 index 0000000..8c7128f --- /dev/null +++ b/technic/textures/technic_solar_furnace_side.png diff --git a/technic/textures/technic_solar_furnace_top.png b/technic/textures/technic_solar_furnace_top.png Binary files differnew file mode 100644 index 0000000..6f17029 --- /dev/null +++ b/technic/textures/technic_solar_furnace_top.png diff --git a/technic/tools/prospector.lua b/technic/tools/prospector.lua index 6373e98..99ab172 100644 --- a/technic/tools/prospector.lua +++ b/technic/tools/prospector.lua @@ -1,6 +1,7 @@ local S = technic.getter technic.register_power_tool("technic:prospector", 650000) +technic.register_power_tool("technic:prospector_mk2", 650000) local function get_metadata(toolstack) local m = minetest.deserialize(toolstack:get_metadata()) @@ -9,6 +10,7 @@ local function get_metadata(toolstack) if not m.target then m.target = "" end if not m.look_depth then m.look_depth = 7 end if not m.look_radius then m.look_radius = 1 end + if not m.scan_radius then m.scan_radius = 1 end return m end @@ -96,33 +98,182 @@ minetest.register_tool("technic:prospector", { end, }) + + +local function remove_waypoints(user, w) + + for i,p in ipairs(w) do + user:hud_remove(p) + end + +end + + +minetest.register_tool("technic:prospector_mk2", { + description = S("Prospector Mk2"), + inventory_image = "technic_prospector_mk2.png", + wear_represents = "technic_RE_charge", + on_refill = technic.refill_RE_charge, + on_use = function(toolstack, user, pointed_thing) + if not user or not user:is_player() or user.is_fake_player then return end + if pointed_thing.type ~= "node" then return end + local toolmeta = get_metadata(toolstack) + local look_diameter = toolmeta.look_radius * 2 + 1 + local charge_to_take = math.pow(toolmeta.scan_radius * 7, 3) + if toolmeta.charge < charge_to_take then return end + if toolmeta.target == "" then + minetest.chat_send_player(user:get_player_name(), "Right-click to set target block type") + return + end + if not technic.creative_mode then + toolmeta.charge = toolmeta.charge - charge_to_take + toolstack:set_metadata(minetest.serialize(toolmeta)) + technic.set_RE_wear(toolstack, toolmeta.charge, technic.power_tools[toolstack:get_name()]) + end + local start_pos = pointed_thing.under + + local min_pos = {x = start_pos.x - toolmeta.scan_radius * 7, y = start_pos.y - toolmeta.scan_radius * 7, z = start_pos.z - toolmeta.scan_radius * 7 } + + local max_pos = {x = start_pos.x + toolmeta.scan_radius * 7, y = start_pos.y + toolmeta.scan_radius * 7, z = start_pos.z + toolmeta.scan_radius * 7 } + + local results = minetest.find_nodes_in_area(min_pos, max_pos, toolmeta.target) + + local waypoints = {} + local found = false + + if #results > math.pow(toolmeta.scan_radius * 7, 3) * 0.25 then + + minetest.chat_send_player(user:get_player_name(), minetest.registered_nodes[toolmeta.target].description.." is literally everywhere within the scanned region") + + else + + for _,p in ipairs(results) do + + if math.random() >= 0.02 then + found = true + local idx = user:hud_add({ + hud_elem_type = "waypoint", + name = "", + text = "", + number = 0xFF0000, + world_pos = p + }) + table.insert(waypoints, idx) + + end + + end + + if found then + minetest.after(7, remove_waypoints, user, waypoints) + end + + minetest.chat_send_player(user:get_player_name(), minetest.registered_nodes[toolmeta.target].description.." is "..(found and "present" or "absent").." within ".. toolmeta.scan_radius * 7 .." meters radius") + end + + minetest.sound_play("technic_prospector_"..(found and "hit" or "miss"), { pos = vector.add(user:getpos(), { x = 0, y = 1, z = 0 }), gain = 1.0, max_hear_distance = 10 }) + + return toolstack + end, + on_place = function(toolstack, user, pointed_thing) + if not user or not user:is_player() or user.is_fake_player then return end + local toolmeta = get_metadata(toolstack) + local pointed + if pointed_thing.type == "node" then + local pname = minetest.get_node(pointed_thing.under).name + local pdef = minetest.registered_nodes[pname] + if pdef and (pdef.groups.not_in_creative_inventory or 0) == 0 and pname ~= toolmeta.target then + pointed = pname + end + end + local scan_radius = toolmeta.scan_radius * 7 + minetest.show_formspec(user:get_player_name(), "technic:prospector_control_mk2", + "size[7,8.5]".. + "item_image[0,0;1,1;"..toolstack:get_name().."]".. + "label[1,0;"..minetest.formspec_escape(toolstack:get_definition().description).."]".. + (toolmeta.target ~= "" and + "label[0,1.5;Current target:]".. + "label[0,2;"..minetest.formspec_escape(minetest.registered_nodes[toolmeta.target].description).."]".. + "item_image[0,2.5;1,1;"..toolmeta.target.."]" or + "label[0,1.5;No target set]").. + (pointed and + "label[3.5,1.5;May set new target:]".. + "label[3.5,2;"..minetest.formspec_escape(minetest.registered_nodes[pointed].description).."]".. + "item_image[3.5,2.5;1,1;"..pointed.."]".. + "button_exit[3.5,3.65;2,0.5;target_"..pointed..";Set target]" or + "label[3.5,1.5;No new target available]").. + "label[0,4.5;Scan radius:]".. + "label[0,5;".. scan_radius .."]".. + "label[3.5,4.5;Set scan radius:]".. + "button_exit[3.5,5.15;1,0.5;scan_radius_1;7]".. + "button_exit[4.5,5.15;1,0.5;scan_radius_2;14]".. + "button_exit[5.5,5.15;1,0.5;scan_radius_3;21]".. + "label[0,7.5;Accuracy:]".. + "label[0,8;98%]") + return + end, +}) + + + minetest.register_on_player_receive_fields(function(user, formname, fields) - if formname ~= "technic:prospector_control" then return false end + if formname ~= "technic:prospector_control" and formname ~= "technic:prospector_control_mk2" then return false end if not user or not user:is_player() or user.is_fake_player then return end local toolstack = user:get_wielded_item() - if toolstack:get_name() ~= "technic:prospector" then return true end - local toolmeta = get_metadata(toolstack) - for field, value in pairs(fields) do - if field:sub(1, 7) == "target_" then - toolmeta.target = field:sub(8) - end - if field:sub(1, 12) == "look_radius_" then - toolmeta.look_radius = field:sub(13) + + if formname == "technic:prospector_control" and toolstack:get_name() == "technic:prospector" then + + local toolmeta = get_metadata(toolstack) + for field, value in pairs(fields) do + if field:sub(1, 7) == "target_" then + toolmeta.target = field:sub(8) + end + if field:sub(1, 12) == "look_radius_" then + toolmeta.look_radius = field:sub(13) + end + if field:sub(1, 11) == "look_depth_" then + toolmeta.look_depth = field:sub(12) + end end - if field:sub(1, 11) == "look_depth_" then - toolmeta.look_depth = field:sub(12) + toolstack:set_metadata(minetest.serialize(toolmeta)) + user:set_wielded_item(toolstack) + return true + end + + if formname == "technic:prospector_control_mk2" and toolstack:get_name() == "technic:prospector_mk2" then + + local toolmeta = get_metadata(toolstack) + for field, value in pairs(fields) do + if field:sub(1, 7) == "target_" then + toolmeta.target = field:sub(8) + end + if field:sub(1, 12) == "scan_radius_" then + toolmeta.scan_radius = field:sub(13) + end end + toolstack:set_metadata(minetest.serialize(toolmeta)) + user:set_wielded_item(toolstack) + return true end - toolstack:set_metadata(minetest.serialize(toolmeta)) - user:set_wielded_item(toolstack) + return true + end) minetest.register_craft({ output = "technic:prospector", recipe = { - {"moreores:pick_silver", "moreores:mithril_block", "pipeworks:teleport_tube_1"}, + {"moreores:pick_silver", "default:goldblock", "pipeworks:teleport_tube_1"}, {"technic:brass_ingot", "technic:control_logic_unit", "technic:brass_ingot"}, - {"", "technic:blue_energy_crystal", ""}, + {"", "technic:red_energy_crystal", ""}, } }) + +minetest.register_craft({ + output = "technic:prospector_mk2", + recipe = { + {"moreores:pick_mithril", "moreores:mithril_block", "pipeworks:teleport_tube_1"}, + {"technic:brass_ingot", "technic:control_logic_unit_adv", "technic:brass_ingot"}, + {"", "technic:blue_energy_crystal", ""}, + } +})
\ No newline at end of file diff --git a/technic/tools/spray_painter.lua b/technic/tools/spray_painter.lua index 1fa9c5a..ff7ce04 100644 --- a/technic/tools/spray_painter.lua +++ b/technic/tools/spray_painter.lua @@ -58,6 +58,19 @@ minetest.register_node ("technic:fluorescent_paint_layer", { }) +if minetest.get_modpath("ehlphabet") then + minetest.register_node(":ehlphabet:block_color", { + description = S("Ehlphabet Block (colored)"), + tiles = {"ehlphabet_000.png"}, + groups = {cracky = 3, not_in_creative_inventory = 1}, + drop = "ehlphabet:block", + paramtype = "light", + paramtype2 = "colorwallmounted", + palette = "technic_paint_palette.png", +}) + +end + local function spray_painter_setmode(user, itemstack, meta, f) local player_name = user:get_player_name() @@ -127,11 +140,37 @@ local function spray_paint(itemstack, user, pointed_thing, ptype) local target = minetest.get_node_or_nil(pointed_thing.under) - - -- if the tool is pointed at a layer of paint -> cycling colors + local paintable = false - if target and target.name == paint_name then + -- target-specific code + if target then + -- if pointing at ehlphabet block (regular or colored) + if (target.name == "ehlphabet:block" or target.name == "ehlphabet:block_color") then + + if target.name == "ehlphabet:block" then + minetest.swap_node(pointed_thing.under, { name = "ehlphabet:block_color" }) + target = minetest.get_node_or_nil(pointed_thing.under) + end + + paintable = true + + -- if pointing at plastic blocks + elseif minetest.get_item_group(target.name, "paintable_plastic_block") > 0 then + + paintable = true + + -- if the tool is pointed at a layer of paint -> cycling colors + elseif target.name == paint_name then + + paintable = true + + end + + end + + if paintable then + local p2 = target.param2 local orientation = p2 % 8 local cindex = (p2 - orientation) / 8 @@ -154,6 +193,7 @@ local function spray_paint(itemstack, user, pointed_thing, ptype) itemstack:set_metadata(minetest.serialize(meta)) end + return itemstack end diff --git a/technic/tools/walking_tractor.lua b/technic/tools/walking_tractor.lua index 1f40a4b..0f514e2 100644 --- a/technic/tools/walking_tractor.lua +++ b/technic/tools/walking_tractor.lua @@ -55,6 +55,7 @@ local ripe_for_harvest = { "ethereal:onion_5", "ethereal:strawberry_8", -- also doubles as a snow-plough + "default:snow", "default:snowblock", "stairs:slab_snowblock", -- mushrooms |