123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513 |
- potions.enchantments = {
- simple = {
- {
- size = 2,
- layout = {"", "default:stick", "default:stick", "" },
- output = "potions:wand",
- }
- }
- }
- -- TODO: check size
- local function compare_recipe(a, b, bsize)
- for k,v in ipairs(a.layout) do
- if b[k] ~= v then
- return false
- end
- end
-
- return true
- end
- local function check_enchanting_recipe(type, layout, size)
- local tab = potions.enchantments[type]
- if not tab then
- return nil
- end
-
- for _,v in ipairs(tab) do
- if compare_recipe(v, layout, size) then
- return v.output
- end
- end
-
- return nil
- end
- local function ench_inv_op(pos, listname, index, stack, player)
- if listname == "output" then
- return
- end
-
-
- local meta = minetest.get_meta(pos)
- local inv = meta:get_inventory()
-
- local m = inv:get_list("main")--to_table()
- local l = {}
- for k,v in ipairs(m) do
- l[k] = v:get_name()
- end
-
- local res = check_enchanting_recipe("simple", l, 2)
- if res then
-
- inv:set_list("output", {res})
- end
-
- end
- minetest.register_node("potions:ench_table_wood", {
- description = "Wooden Enchanting Table",
- drawtype = "nodebox",
- node_box = {
- type = "fixed",
- fixed = {
- { -0.4, -0.5, -0.4, -0.25, 0.45, -0.25},
- { 0.25, -0.5, 0.25, 0.4, 0.45, 0.4},
- { -0.4, -0.5, 0.25, -0.25, 0.45, 0.4},
- { 0.25, -0.5, -0.4, 0.4, 0.45, -0.25},
-
- {-0.5, 0.35, -0.5, 0.5, 0.5, 0.5},
- },
- },
- tiles = {"default_junglewood.png"},
- paramtype = "light",
- paramtype2 = "facedir",
- groups = {choppy = 2, oddly_breakable_by_hand = 3},
- sounds = default.node_sound_wood_defaults(),
- stack_max = 1,
-
- on_construct = function(pos)
- local meta = minetest.get_meta(pos)
- local formspec = "size[8,8.5]"..
- "label[5,0;Wooden Enchanting Table]" ..
- "list[current_name;main;1,.5;2,2;]" ..
- "list[current_name;output;4.5,1.5;1,1;]" ..
- "list[current_player;main;0,4.25;8,1;]"..
- "list[current_player;main;0,5.5;8,3;8]"..
- default.gui_bg..default.gui_bg_img..default.gui_slots
-
- meta:set_string("formspec", formspec)
-
- meta:set_int("uses", 0)
-
- local inv = meta:get_inventory()
- inv:set_size("main", 2*2)
- inv:set_size("output", 1)
- end,
-
- after_place_node = function(pos, placer)
- local meta = minetest.get_meta(pos)
- local owner = placer and placer:get_player_name() or ""
- meta:set_string("owner", owner)
- end,
- allow_metadata_inventory_put = function(pos, listname, index, stack, player)
- if listname == "output" then
- return 0
- end
-
- return stack:get_count()
- end,
-
- on_metadata_inventory_put = ench_inv_op,
- on_metadata_inventory_move = ench_inv_op,
-
- on_metadata_inventory_take = function(pos, listname, index, stack, player)
- if listname == "output" then
- local meta = minetest.get_meta(pos)
- local inv = meta:get_inventory()
- inv:set_list("main", {})
- end
- end,
- -- on_receive_fields = function(pos, formname, fields, player)
- --
- -- end,
- })
- minetest.register_craft({
- output = 'potions:ench_table_wood',
- recipe = {
- {'dye:black', 'dye:red', 'dye:black'},
- {'default:junglewood', 'default:junglewood', 'default:junglewood'},
- {'default:junglewood', '', 'default:junglewood'},
- }
- })
- minetest.register_craftitem("potions:arcane_book", {
- description = "Arcane Book",
- inventory_image = "default_book.png",
- groups = {book = 1, flammable = 3},
- })
- minetest.register_node("potions:treasure_seed", {
- description = "Treasure Seed",
- -- tiles = {"default_mese.png"},
- drawtype = "airlike",
- groups = {crumbly = 3},
- drop = "default:sand",
- sounds = default.node_sound_dirt_defaults(),
- })
- local spawn_treasure = function(pos, node)
- -- print("treasure at " .. dump(pos))
- minetest.set_node(pos, {name="air"})
- pos.y = pos.y - 5
- for x = -1,1 do
- for z = -1,1 do
- minetest.set_node({x=pos.x+x, y=pos.y-1, z=pos.z+z}, {name="default:junglewood"})
- end
- end
-
-
- for y = 0,1 do
- for x = -1,1 do
- for z = -1,1 do
- minetest.set_node({x=pos.x+x, y=pos.y+y, z=pos.z+z}, {name="air"})
- end
- end
- end
-
- for x = -1,1 do
- for z = -1,1 do
- minetest.set_node({x=pos.x+x, y=pos.y+2, z=pos.z+z}, {name="default:junglewood"})
- end
- end
-
- minetest.set_node({x=pos.x+1, y=pos.y+0, z=pos.z+1}, {name="default:fence_junglewood"})
- minetest.set_node({x=pos.x-1, y=pos.y+0, z=pos.z+1}, {name="default:fence_junglewood"})
- minetest.set_node({x=pos.x+1, y=pos.y+0, z=pos.z-1}, {name="default:fence_junglewood"})
- minetest.set_node({x=pos.x-1, y=pos.y+0, z=pos.z-1}, {name="default:fence_junglewood"})
- minetest.set_node({x=pos.x+1, y=pos.y+1, z=pos.z+1}, {name="default:fence_junglewood"})
- minetest.set_node({x=pos.x-1, y=pos.y+1, z=pos.z+1}, {name="default:fence_junglewood"})
- minetest.set_node({x=pos.x+1, y=pos.y+1, z=pos.z-1}, {name="default:fence_junglewood"})
- minetest.set_node({x=pos.x-1, y=pos.y+1, z=pos.z-1}, {name="default:fence_junglewood"})
-
-
- pos.z = pos.z + 1
- minetest.set_node(pos, {name = "potions:small_chest"})
-
- local meta = minetest.get_meta(pos)
- local inv = meta:get_inventory()
- inv:set_list("main", {"potions:arcane_book"})
-
- end
- minetest.register_lbm({
- label = "spawn treasure",
- name = "potions:treasure_1",
- nodenames = {"potions:treasure_seed"},
- action = spawn_treasure,
- })
- minetest.register_abm({
- label = "spawn treasure",
- name = "potions:treasure_1",
- nodenames = {"potions:treasure_seed"},
- chance = 1,
- interval = 10,
- action = spawn_treasure,
- })
- minetest.register_decoration({
- name = "potions:treasure_seed",
- deco_type = "simple",
- place_on = {"default:sand"},
- sidelen = 16,
- noise_params = {
- offset = -0.016,
- scale = 0.024,
- spread = {x = 100, y = 100, z = 100},
- seed = 230,
- octaves = 4,
- persist = 0.6
- },
- flags = "force_placement",
- y_max = 5,
- y_min = -8,
- decoration = "potions:treasure_seed",
- })
- minetest.register_node("potions:small_chest", {
- description = "Small Chest",
- tiles = {
- "default_chest_top.png",
- "default_chest_top.png",
- "default_chest_side.png",
- "default_chest_side.png",
- "default_chest_lock.png",
- "default_chest_side.png"
- },
- paramtype = "light",
- paramtype2 = "facedir",
- is_ground_content = false,
- drawtype = "nodebox",
- node_box = {
- type = "fixed",
- fixed = {
- {-0.4, -0.5, -0.3, 0.4, 0.0, 0.3},
- },
- },
- collision_box = {
- type = "fixed",
- fixed = {
- {-0.4, -0.5, -0.3, 0.4, 0.0, 0.3},
- },
- },
- groups = {choppy = 3, oddly_breakable_by_hand = 2, divinable = 1 },
- sounds = default.node_sound_wood_defaults(),
- on_construct = function(pos)
- local meta = minetest.get_meta(pos)
- local inv = meta:get_inventory()
- inv:set_size("main", 3 * 2)
- meta:set_string("formspec",
- "size[8,7;]" ..
- "list[context;main;2,0.3;3,2;]" ..
- "list[current_player;main;0,2.85;8,1;]" ..
- "list[current_player;main;0,4.08;8,3;8]" ..
- "listring[context;main]" ..
- "listring[current_player;main]" ..
- default.get_hotbar_bg(0,2.85)
- )
- end,
-
- can_dig = function(pos,player)
- local inv = minetest.get_meta(pos):get_inventory()
- return inv:is_empty("main")
- end,
- })
- minetest.register_node("potions:divining_block", {
- description = "Divining Block",
- tiles = {"default_silver_sandstone_brick.png"},
- groups = {crumbly = 3},
- sounds = default.node_sound_dirt_defaults(),
-
- on_punch = function(pos, node, player)
-
- if potions.get_manna(player) > 50 then
-
- local p = minetest.find_node_near(pos, 50, {"group:divinable"})
-
- -- print(dump(p))
-
- if p then
- local dx = p.x - pos.x
- local dz = p.z - pos.z
- local l = math.sqrt(dx*dx + dz*dz)
-
- dx = dx / l
- dz = dz / l
-
- local vel = 4
-
- minetest.add_particlespawner({
- amount = 140,
- time = 15,
- minpos = pos,
- maxpos = pos,
- minvel = {x=dx*vel, y=5.5, z=dz*vel},
- maxvel = {x=dx*vel, y=5.5, z=dz*vel},
- minacc = {x=-0.1, y=-02.1, z=-0.1},
- maxacc = {x=0.1, y=-02.1, z=0.1},
- minexptime = 1.5,
- maxexptime = 5.5,
- -- collisiondetection = true,
- -- collision_removal = true,
- minsize = 0.5,
- maxsize = 2.5,
- texture = "potions_particle.png^[colorize:yellow:60",
- -- animation = tileanimation
- glow = 1
- })
-
- end
-
- potions.add_manna(player, -50)
- end
-
-
- end
-
-
- })
- minetest.register_node("potions:geode_divining_block", {
- description = "Divining Block",
- tiles = {"default_sandstone_brick.png"},
- groups = {crumbly = 3},
- sounds = default.node_sound_dirt_defaults(),
-
- on_punch = function(pos, node, player)
-
- if potions.get_manna(player) > 90 then
-
- local p = minetest.find_node_near(pos, 60, {"group:geode_wall"})
-
- -- print(dump(p))
-
- if p then
- local dx = p.x - pos.x
- local dz = p.z - pos.z
- local l = math.sqrt(dx*dx + dz*dz)
-
- dx = dx / l
- dz = dz / l
-
- local vel = 4
-
- minetest.add_particlespawner({
- amount = 140,
- time = 15,
- minpos = pos,
- maxpos = pos,
- minvel = {x=dx*vel, y=5.5, z=dz*vel},
- maxvel = {x=dx*vel, y=5.5, z=dz*vel},
- minacc = {x=-0.1, y=-02.1, z=-0.1},
- maxacc = {x=0.1, y=-02.1, z=0.1},
- minexptime = 1.5,
- maxexptime = 5.5,
- -- collisiondetection = true,
- -- collision_removal = true,
- minsize = 0.5,
- maxsize = 2.5,
- texture = "potions_particle.png^[colorize:yellow:60",
- -- animation = tileanimation
- glow = 1
- })
-
- end
-
- potions.add_manna(player, -90)
- end
-
-
- end
-
-
- })
- minetest.register_craft({
- output = 'potions:divining_block',
- recipe = {
- {'','',''},
- {'','group:leaves',''},
- {'default:silver_sandstone_block', 'default:silver_sandstone_block', 'default:silver_sandstone_block'},
- }
- })
- minetest.register_craft({
- output = 'potions:geode_divining_block',
- recipe = {
- {'','',''},
- {'','group:gem',''},
- {'default:silver_sandstone_block', 'default:silver_sandstone_block', 'default:silver_sandstone_block'},
- }
- })
- minetest.register_craft({
- output = 'potions:instant_hole',
- recipe = {
- {'default:dirt','potions:arcane_book','default:dirt'},
- {'', 'default:ladder', ''},
- {'', 'default:ladder', ''},
- }
- })
- minetest.register_craftitem("potions:firefly_stick", {
- description = "Firefly Stick",
- inventory_image = "default_stick.png^[colorize:yellow:200",
- stack_max = 5,
- on_use = function(itemstack, user, pointed_thing)
-
- if potions.get_manna(user) > 80 then
-
- local pos = user:getpos()
-
- pos.y = pos.y + 1
-
- local function try(p)
- local n = minetest.get_node(p)
- if n.name == "air" then
- minetest.set_node(p, {name="fireflies:firefly"})
- end
- end
-
- try({x=pos.x + 5, y=pos.y, z=pos.z + 0})
- try({x=pos.x + 5, y=pos.y, z=pos.z + 5})
- try({x=pos.x + 0, y=pos.y, z=pos.z + 0})
- try({x=pos.x + 0, y=pos.y, z=pos.z + 5})
-
- potions.add_manna(user, -80)
- end
- return itemstack
-
- end,
- })
- minetest.register_craft({
- output = 'potions:firefly_stick',
- recipe = {
- {'fireflies:firefly', '', ''},
- {'default:stick', '', ''},
- {'potions:arcane_book', '', ''},
- },
- replacements = {{"potions:arcane_book", "potions:arcane_book"}},
- })
|