ExchangeClone/exchangeclone/philosophers_stone.lua

352 lines
10 KiB
Lua
Raw Normal View History

2023-11-19 01:48:35 +01:00
local S = minetest.get_translator()
2023-12-15 00:09:59 +01:00
local phil = "exchangeclone:philosophers_stone"
2023-05-23 16:53:45 +02:00
local function show_enchanting(player)
local player_meta = player:get_meta()
player_meta:set_int("mcl_enchanting:num_bookshelves", 8) -- 15 for max enchantments
2023-11-19 01:48:35 +01:00
player_meta:set_string("mcl_enchanting:table_name", S("Enchanting Table").." (".. S("Philosopher's Stone")..")")
2023-05-23 16:53:45 +02:00
mcl_enchanting.show_enchanting_formspec(player)
end
local width = (exchangeclone.mcl and 9) or 8
local repairing_formspec =
"size["..tostring(width)..", 7]"..
"label[0.5,0.5;Repairing]"..
2023-12-21 21:37:52 +01:00
"label["..tostring(width/3-0.5)..",0.5;Dust]"..
"list[current_player;exchangeclone_covalence_dust;"..tostring(width/3-0.5)..",1;1,1]"..
"label["..tostring(width/2-0.5)..",0.5;Gear]"..
"list[current_player;exchangeclone_covalence_gear;"..tostring(width/2-0.5)..",1;1,1]"..
"label["..tostring(2*width/3-0.5)..",0.5;Output]"..
"list[current_player;exchangeclone_covalence_output;"..tostring(2*width/3-0.5)..",1;1,1]"..
exchangeclone.inventory_formspec(0,2.75)..
"listring[current_player;main]"..
2023-12-21 21:37:52 +01:00
"listring[current_player;exchangeclone_covalence_gear]"..
"listring[current_player;main]"..
2023-12-21 21:37:52 +01:00
"listring[current_player;exchangeclone_covalence_dust]"..
"listring[current_player;main]"..
2023-12-21 21:37:52 +01:00
"listring[current_player;exchangeclone_covalence_output]"..
"listring[current_player;main]"
if exchangeclone.mcl then
repairing_formspec = repairing_formspec..
mcl_formspec.get_itemslot_bg(width/3-0.5,1,1,1)..
mcl_formspec.get_itemslot_bg(width/2-0.5,1,1,1)..
mcl_formspec.get_itemslot_bg(2*width/3-0.5,1,1,1)
end
2024-02-12 19:19:04 +01:00
-- exchangeclone.node_transmutations moved to zzzz_exchangeclone_init so it would load first
2024-02-04 22:29:48 +01:00
-- This means it can be modified by other mods
function exchangeclone.phil_action(itemstack, player, center)
if exchangeclone.check_cooldown(player, "phil") then return end
local mode = player:get_player_control().sneak and 2 or 1
local start_node = minetest.get_node(center)
local transmute_name = exchangeclone.node_transmutations[mode][start_node.name]
if not transmute_name and mode == 2 then
transmute_name = exchangeclone.node_transmutations[1][start_node.name]
end
if not transmute_name then return end
local charge = math.max(itemstack:get_meta():get_int("exchangeclone_tool_charge"), 1)
local nodes
if charge == 1 then
nodes = {center}
else
local vector1, vector2 = exchangeclone.process_range(player, "basic_radius", charge)
if not (vector1 and vector2) then return end
local pos1, pos2 = vector.add(center, vector1), vector.add(center, vector2)
nodes = minetest.find_nodes_in_area(pos1, pos2, start_node.name)
end
2024-02-12 19:19:04 +01:00
exchangeclone.play_sound(player, "exchangeclone_transmute")
2024-02-04 22:29:48 +01:00
for i, pos in pairs(nodes) do
if minetest.is_protected(pos, player:get_player_name()) then
minetest.record_protection_violation(pos, player:get_player_name())
else
local node = minetest.get_node(pos)
node.name = transmute_name
minetest.swap_node(pos, node)
2023-05-23 16:53:45 +02:00
end
end
2024-02-04 22:29:48 +01:00
exchangeclone.start_cooldown(player, "phil", 0.3)
end
2023-05-23 16:53:45 +02:00
2024-01-19 23:12:25 +01:00
local on_left_click
2023-09-29 01:23:49 +02:00
if exchangeclone.mcl then
on_left_click = function(itemstack, player, pointed_thing)
if player:get_player_control().sneak then
show_enchanting(player)
else
if player:get_player_control().aux1 then
minetest.show_formspec(player:get_player_name(), "exchangeclone_repairing", repairing_formspec)
else
mcl_crafting_table.show_crafting_form(player)
end
2023-05-23 16:53:45 +02:00
end
end
else
on_left_click = function(itemstack, player, pointed_thing)
minetest.show_formspec(player:get_player_name(), "exchangeclone_repairing", repairing_formspec)
end
2023-05-23 16:53:45 +02:00
end
local function on_right_click(itemstack, player, pointed_thing)
local click_test = exchangeclone.check_on_rightclick(itemstack, player, pointed_thing)
if click_test ~= false then
return click_test
end
if player:get_player_control().aux1 then
2024-01-24 04:23:32 +01:00
return exchangeclone.charge_update(itemstack, player)
end
if pointed_thing and pointed_thing.type == "node" then
2024-02-04 22:29:48 +01:00
exchangeclone.phil_action(itemstack, player, pointed_thing.under)
2023-05-23 16:53:45 +02:00
end
end
minetest.register_tool("exchangeclone:philosophers_stone", {
2023-11-19 01:48:35 +01:00
description = S("Philosopher's Stone").."\n"..S("Always returned when crafting"),
2023-05-23 16:53:45 +02:00
inventory_image = "exchangeclone_philosophers_stone.png",
wield_image = "exchangeclone_philosophers_stone.png",
2024-01-24 04:23:32 +01:00
exchangeclone_tool_charge = 0,
2023-05-23 16:53:45 +02:00
on_use = on_left_click,
on_place = on_right_click,
on_secondary_use = on_right_click,
2024-02-16 22:44:08 +01:00
groups = {philosophers_stone = 1, disable_repair = 1, fire_immune = 1},
wear_represents = "exchangeclone_charge_level"
2023-05-23 16:53:45 +02:00
})
2024-02-04 22:29:48 +01:00
exchangeclone.set_charge_type("exchangeclone:philosophers_stone", "phil")
2023-11-08 01:02:24 +01:00
local diamond = exchangeclone.itemstrings.diamond
2023-12-15 00:09:59 +01:00
local corner = exchangeclone.itemstrings.glowstoneworth
local side = exchangeclone.itemstrings.redstoneworth
2023-05-23 16:53:45 +02:00
minetest.register_craft({
output = "exchangeclone:philosophers_stone",
recipe = {
{corner, side, corner},
{side, diamond, side},
{corner, side, corner}
}
})
minetest.register_craft({
output = "mcl_core:coal_lump",
type = "shapeless",
recipe = {
2023-12-15 00:09:59 +01:00
phil,
2023-05-23 16:53:45 +02:00
"mcl_core:charcoal_lump",
"mcl_core:charcoal_lump",
"mcl_core:charcoal_lump",
"mcl_core:charcoal_lump"
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-05-23 16:53:45 +02:00
})
minetest.register_craft({
output = "mcl_core:charcoal_lump 4",
type = "shapeless",
recipe = {
2023-12-15 00:09:59 +01:00
phil,
2023-05-23 16:53:45 +02:00
"mcl_core:coal_lump"
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-05-23 16:53:45 +02:00
})
minetest.register_craft({
2023-11-08 01:02:24 +01:00
output = exchangeclone.itemstrings.iron,
2023-05-23 16:53:45 +02:00
type = "shapeless",
recipe = {
2023-12-15 00:09:59 +01:00
phil,
2023-11-08 01:02:24 +01:00
exchangeclone.itemstrings.coal,
exchangeclone.itemstrings.coal,
2023-05-23 16:53:45 +02:00
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-05-23 16:53:45 +02:00
})
minetest.register_craft({
2023-11-08 01:02:24 +01:00
output = exchangeclone.itemstrings.coal.." 2",
2023-05-23 16:53:45 +02:00
type = "shapeless",
recipe = {
2023-12-15 00:09:59 +01:00
phil,
2023-11-08 01:02:24 +01:00
exchangeclone.itemstrings.iron
2023-05-23 16:53:45 +02:00
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-05-23 16:53:45 +02:00
})
minetest.register_craft({
2023-12-15 00:09:59 +01:00
output = exchangeclone.itemstrings.copper.." 2",
2023-05-23 16:53:45 +02:00
type = "shapeless",
recipe = {
2023-12-15 00:09:59 +01:00
phil,
exchangeclone.itemstrings.iron,
exchangeclone.itemstrings.iron,
2023-05-23 16:53:45 +02:00
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-05-23 16:53:45 +02:00
})
minetest.register_craft({
2023-12-15 00:09:59 +01:00
output = exchangeclone.itemstrings.iron.." 2",
2023-05-23 16:53:45 +02:00
type = "shapeless",
recipe = {
2023-12-15 00:09:59 +01:00
phil,
exchangeclone.itemstrings.copper,
exchangeclone.itemstrings.copper,
2023-05-23 16:53:45 +02:00
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-05-23 16:53:45 +02:00
})
2023-11-08 01:02:24 +01:00
minetest.register_craft({
output = "mcl_throwing:ender_pearl",
2023-11-10 03:35:23 +01:00
type = "shapeless",
2023-11-08 01:02:24 +01:00
recipe = {
2023-12-15 00:09:59 +01:00
phil,
2023-11-08 01:02:24 +01:00
"mcl_core:iron_ingot",
"mcl_core:iron_ingot",
"mcl_core:iron_ingot",
"mcl_core:iron_ingot",
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-05-23 16:53:45 +02:00
})
minetest.register_craft({
output = "default:tin_ingot 4",
2023-05-23 16:53:45 +02:00
type = "shapeless",
recipe = {
2023-12-15 00:09:59 +01:00
phil,
2023-05-23 16:53:45 +02:00
"default:copper_ingot",
"default:copper_ingot",
"default:copper_ingot",
"default:copper_ingot",
"default:copper_ingot",
2023-05-23 16:53:45 +02:00
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-05-23 16:53:45 +02:00
})
minetest.register_craft({
output = "default:copper_ingot 5",
2023-05-23 16:53:45 +02:00
type = "shapeless",
recipe = {
2023-12-15 00:09:59 +01:00
phil,
2023-05-23 16:53:45 +02:00
"default:tin_ingot",
"default:tin_ingot",
"default:tin_ingot",
"default:tin_ingot",
2023-05-23 16:53:45 +02:00
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-05-23 16:53:45 +02:00
})
minetest.register_craft({
2023-11-08 01:02:24 +01:00
output = exchangeclone.itemstrings.iron.." 8",
2023-05-23 16:53:45 +02:00
type = "shapeless",
recipe = {
2023-12-15 00:09:59 +01:00
phil,
2023-11-08 01:02:24 +01:00
exchangeclone.itemstrings.gold
2023-05-23 16:53:45 +02:00
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-05-23 16:53:45 +02:00
})
minetest.register_craft({
2023-11-08 01:02:24 +01:00
output = exchangeclone.itemstrings.gold,
2023-05-23 16:53:45 +02:00
type = "shapeless",
recipe = {
2023-12-15 00:09:59 +01:00
phil,
2023-11-08 01:02:24 +01:00
exchangeclone.itemstrings.iron,
exchangeclone.itemstrings.iron,
exchangeclone.itemstrings.iron,
exchangeclone.itemstrings.iron,
exchangeclone.itemstrings.iron,
exchangeclone.itemstrings.iron,
exchangeclone.itemstrings.iron,
exchangeclone.itemstrings.iron,
2023-05-23 16:53:45 +02:00
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-05-23 16:53:45 +02:00
})
minetest.register_craft({
2023-11-10 03:35:23 +01:00
output = exchangeclone.itemstrings.emeraldworth,
2023-05-23 16:53:45 +02:00
type = "shapeless",
recipe = {
2023-12-15 00:09:59 +01:00
phil,
2023-11-08 01:02:24 +01:00
exchangeclone.itemstrings.gold,
exchangeclone.itemstrings.gold,
2023-05-23 16:53:45 +02:00
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-05-23 16:53:45 +02:00
})
minetest.register_craft({
2023-11-08 01:02:24 +01:00
output = exchangeclone.itemstrings.gold.." 2",
2023-05-23 16:53:45 +02:00
type = "shapeless",
recipe = {
2023-12-15 00:09:59 +01:00
phil,
2023-11-10 03:35:23 +01:00
exchangeclone.itemstrings.emeraldworth,
2023-05-23 16:53:45 +02:00
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-05-23 16:53:45 +02:00
})
minetest.register_craft({
2023-11-08 01:02:24 +01:00
output = exchangeclone.itemstrings.diamond,
2023-05-23 16:53:45 +02:00
type = "shapeless",
recipe = {
2023-12-15 00:09:59 +01:00
phil,
2023-11-10 03:35:23 +01:00
exchangeclone.itemstrings.emeraldworth,
exchangeclone.itemstrings.emeraldworth,
2023-05-23 16:53:45 +02:00
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-05-23 16:53:45 +02:00
})
minetest.register_craft({
2023-11-10 03:35:23 +01:00
output = exchangeclone.itemstrings.emeraldworth.." 2",
2023-05-23 16:53:45 +02:00
type = "shapeless",
recipe = {
2023-12-15 00:09:59 +01:00
phil,
2023-11-08 01:02:24 +01:00
exchangeclone.itemstrings.diamond
2023-05-23 16:53:45 +02:00
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-05-23 16:53:45 +02:00
})
2023-05-26 18:55:55 +02:00
minetest.register_craft({
2023-11-10 03:35:23 +01:00
output = "mcl_nether:glowstone_dust",
2023-05-26 18:55:55 +02:00
type = "shapeless",
recipe = {
2023-12-15 00:09:59 +01:00
phil,
2023-11-10 03:35:23 +01:00
"mesecons:redstone",
"mesecons:redstone",
"mesecons:redstone",
"mesecons:redstone",
"mesecons:redstone",
"mesecons:redstone",
2023-05-26 18:55:55 +02:00
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-05-26 18:55:55 +02:00
})
minetest.register_craft({
2023-11-10 03:35:23 +01:00
output = "mesecons:redstone 6",
2023-05-26 18:55:55 +02:00
type = "shapeless",
recipe = {
2023-12-15 00:09:59 +01:00
phil,
2023-11-10 03:35:23 +01:00
"mcl_nether:glowstone_dust",
2023-05-26 18:55:55 +02:00
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-05-26 18:55:55 +02:00
})
minetest.register_craft({
2023-11-10 03:35:23 +01:00
output = "mcl_core:lapis",
type = "shapeless",
recipe = {
2023-12-15 00:09:59 +01:00
phil,
2023-11-10 03:35:23 +01:00
"mcl_nether:glowstone_dust",
"mcl_nether:glowstone_dust"
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-11-10 03:35:23 +01:00
})
minetest.register_craft({
output = "mcl_nether:glowstone_dust 2",
2023-05-26 18:55:55 +02:00
type = "shapeless",
recipe = {
2023-12-15 00:09:59 +01:00
phil,
2023-05-26 18:55:55 +02:00
"mcl_core:lapis",
},
2023-12-15 00:09:59 +01:00
replacements = {{phil, phil}}
2023-05-23 16:53:45 +02:00
})