Arreglados encantamientos

-- Yawin
master
Yawin 2017-03-16 16:14:20 +01:00
parent 837d740044
commit b36712e249
16 changed files with 137 additions and 31 deletions

1
Mod_Magic Symbolic link
View File

@ -0,0 +1 @@
../referenced-mods/yawin/Mod_Magic/

View File

@ -2,6 +2,7 @@
-- MOD MAGIC API ------------------------------------------------
-----------------------------------------------------------------
dofile(magic.path.."/functions/effects.lua")
dofile(magic.path.."/functions/homewarp.lua")
dofile(magic.path.."/functions/multiblock.lua")
dofile(magic.path.."/functions/altar_rituals.lua")

View File

@ -19,6 +19,8 @@ function magic.do_ritual(node, player)
if n_rit then
magic.rituals[n_rit][2](node, player)
end
magic.gfx.altar_ok(node.under)
end
function magic.get_items(node)

71
functions/effects.lua Normal file
View File

@ -0,0 +1,71 @@
-----------------------------------------------------------------
-- GRAPHICAL EFFECTS -------------------------------------------
-----------------------------------------------------------------
function magic.gfx.altar_ok(pos)
local spawner = magic.gfx.default()
spawner.minpos = { x = 0, y = 0, z = 0}
spawner.maxpos = { x = 0, y = 0, z = 0}
spawner.minvel = { x = -5, y = 0, z = -5}
spawner.maxvel = { x = 5, y = 5, z = 5}
spawner.minacc = { x = 0, y = 0, z = 0}
spawner.maxacc = { x = 0, y = 0, z = 0}
spawner.amount = 100
spawner.time = 0.1
magic.gfx.set_particlespawner(pos,"bubble.png^[colorize:#551A8B:100", spawner)
end
function magic.gfx.recipe_ok(pos)
local spawner = magic.gfx.default()
spawner.minpos = { x = -0.5, y = -0.5, z = -0.5}
spawner.maxpos = { x = 0.5, y = 0.5, z = 0.5}
spawner.minvel = { x = -3.5, y = -3.5, z = -3.5}
spawner.maxvel = { x = 3.5, y = 3.5, z = 3.5}
spawner.minacc = { x = 0, y = 0, z = 0}
spawner.maxacc = { x = 0, y = 0, z = 0}
spawner.amount = 50
spawner.time = 0.1
magic.gfx.set_particlespawner(pos,"bubble.png^[colorize:#551A8B:100", spawner)
end
function magic.gfx.set_particlespawner(pos, _texture, spawner)
local ps = minetest.add_particlespawner({
amount = spawner.amount,
time = spawner.time,
minpos = {x = pos.x + spawner.minpos.x, y = pos.y + spawner.minpos.y, z = pos.z + spawner.minpos.z},
maxpos = {x = pos.x + spawner.maxpos.x, y = pos.y + spawner.maxpos.y, z = pos.z + spawner.maxpos.z},
minvel = spawner.minvel,
maxvel = spawner.maxvel,
minacc = spawner.minacc,
maxacc = spawner.maxacc,
minexptime = spawner.minexptime,
maxexptime = spawner.maxexptime,
minsize = spawner.minsize,
maxsize = spawner.maxsize,
collisiondetection = spawner.collisiondetection,
vertical = spawner.vertical,
texture = _texture,
})
local meta = minetest.get_meta(pos)
meta:set_string("spawner", ps)
end
function magic.gfx.default()
return {
amount = 5,
time = 0,
minpos = {x = -0.35, y = 0.5, z = -0.35},
maxpos = {x = 0.35, y = 0.5, z = 0.35},
minvel = {x = 0, y = 0, z = 0},
maxvel = {x = 0, y = 0, z = 0},
minacc = {x = 0, y = 0.5, z = 0},
maxacc = {x = 0, y = 1.5, z = 0},
minexptime = 1,
maxexptime = 1,
minsize = 1,
maxsize = 1,
collisiondetection = false,
vertical = false
}
end

View File

@ -1,22 +1,22 @@
-----------------------------------------------------------------
-- ENCHANTMENTS LOGIC -------------------------------------------
-----------------------------------------------------------------
minetest.register_on_dignode(function(pos, oldnode, digger)
---magic.use_tool(pos, oldnode, digger)
end)
function minetest.handle_node_drops(pos, drops, digger)
magic.use_tool(pos, drops, digger)
end
function magic.use_tool(pos, drops, digger)
if not digger or digger:get_wielded_item():to_string() == "" then return end
function magic.use_tool(pos, oldnode, digger)
local item = digger:get_wielded_item()
local meta = item:get_meta()
if item:to_string() == "" then
return
end
local actions = {}
local nodeinfo = {
name = oldnode.name,
drop = minetest.get_node_drops(oldnode.name)[1],
}
local nodeinfo = {drop={}}
for i in ipairs(drops) do
nodeinfo.drop[i] = drops[i]
--minetest.chat_send_all(drops[d])
end
for e_id, enchantment in pairs(magic.enchants) do
if enchantment.type == "on_dig" then
@ -28,14 +28,19 @@ function magic.use_tool(pos, oldnode, digger)
end
if #actions == 0 then
for d in pairs(nodeinfo.drop) do
minetest.add_item(pos, nodeinfo.drop[d])
end
return
end
for i in ipairs(actions) do
actions[i].action(actions[i].val, pos, oldnode, digger, nodeinfo)
nodeinfo.drop = actions[i].action(actions[i].val, pos, digger, nodeinfo)
end
minetest.add_item(pos, nodeinfo.drop)
for d in pairs(nodeinfo.drop) do
minetest.add_item(pos, nodeinfo.drop[d])
end
end
function magic.register_on_dig_enchant(enchant_id, enchant_type, value_max, action_function, ingredient, enchantables)
@ -85,10 +90,14 @@ end
-- ENCHANTMENTS -------------------------------------------------
-----------------------------------------------------------------
magic.register_on_dig_enchant("luck", "on_dig", 3,
function(luck_value, pos, oldnode, digger, nodeinfo)
function(luck_value, pos, digger, nodeinfo)
local drop_count = math.random(2, luck_value + 1) + 1
nodeinfo.drop = nodeinfo.drop.." "..drop_count
return nodeinfo
for i in ipairs(nodeinfo.drop) do
nodeinfo.drop[i] = nodeinfo.drop[i].." "..drop_count
end
return nodeinfo.drop
end,
"default:cobble",
@ -112,9 +121,9 @@ magic.register_on_dig_enchant("luck", "on_dig", 3,
}
)
magic.register_on_dig_enchant("silk_touch", "on_dig", 3,
function(luck_value, pos, oldnode, digger, nodeinfo)
nodeinfo.drop = oldnode.name
return nodeinfo
function(luck_value, pos, digger, nodeinfo)
nodeinfo.drop = {minetest.get_node(pos).name};
return nodeinfo.drop
end,
"default:wood",
@ -138,15 +147,17 @@ magic.register_on_dig_enchant("silk_touch", "on_dig", 3,
}
)
magic.register_on_dig_enchant("cook", "on_dig", 3,
function(luck_value, pos, oldnode, digger, nodeinfo)
local temper, _ = minetest.get_craft_result({ method = "cooking", width = 1, items = {nodeinfo.drop}})
if temper and temper.item:to_table() then
temper = temper.item:to_table().name
nodeinfo.drop = temper
function(luck_value, pos, digger, nodeinfo)
local tdrop
local ltdrop = {}
for i in ipairs(nodeinfo.drop) do
tdrop = minetest.get_craft_result({ method = "cooking", width = 1, items = {nodeinfo.drop[i]}})
ltdrop[#ltdrop + 1] = tdrop.item:to_table().name
end
return nodeinfo
return ltdrop
end,
"default:coal_lump",

View File

@ -1,11 +1,14 @@
-- Definitions made by this mod that other mods can use too
magic = {}
magic.enchants = {}
magic.gfx = {}
magic.playerHomes = {}
magic.recipes = {}
magic.rituals = {}
magic.playerHomes = {}
magic.enchants = {}
magic.path = minetest.get_modpath("magic")
magic.worldpath = minetest.get_worldpath()

View File

@ -21,5 +21,7 @@ magic.register_recipe("begining",
local sch = magic.path .. "/schems/magical_font.mts"
minetest.place_schematic({x = posx, y = posy, z = posz}, sch, 0, nil, true)
magic.gfx.recipe_ok(node.under)
end
)

View File

@ -25,5 +25,7 @@ magic.register_recipe("big_tree",
local sch = magic.path .. "/schems/magical_big_tree.mts"
minetest.place_schematic({x = posx, y = posy, z = posz}, sch, 0, nil, true)
magic.gfx.recipe_ok(node.under)
end
)

View File

@ -26,8 +26,7 @@ magic.register_recipe("compass",
nod = minetest.get_node(node.under)
minetest.set_node({x = posx, y = posy, z = posz + 1}, {name = nod.name})
minetest.set_node({x = posx, y = posy, z = posz}, {name = "air"})
--local sch = magic.path .. "/schems/compass.mts"
--minetest.place_schematic({x = posx, y = posy, z = posz}, sch, 0, nil, true)
magic.gfx.recipe_ok(node.under)
end
)

View File

@ -58,6 +58,8 @@ magic.register_recipe("extension",
},
function(node, player, facedir)
extension_action(node, player, facedir)
magic.gfx.recipe_ok(node.under)
end
)
@ -71,5 +73,7 @@ magic.register_recipe("extension2",
},
function(node, player, facedir)
extension_action(node, player, facedir)
magic.gfx.recipe_ok(node.under)
end
)

View File

@ -59,5 +59,7 @@ magic.register_recipe("home_stone",
minetest.set_node(node.under, {name="magic:magicalobsidian"})
minetest.env:add_item({x = node.under.x, y = node.under.y + 1, z = node.under.z}, "magic:home_stone")
magic.gfx.recipe_ok(node.under)
end
)

View File

@ -52,5 +52,7 @@ magic.register_recipe("home_warp",
i = i + 1
end
magic.gfx.recipe_ok(node.under)
end
)

View File

@ -69,6 +69,8 @@ magic.register_recipe("laputa",
incx = -range
incy = incy - 1
end
magic.gfx.recipe_ok(node.under)
end
)

View File

@ -72,5 +72,7 @@ magic.register_recipe("perforator",
end
end
end
magic.gfx.recipe_ok(node.under)
end
)

View File

@ -51,5 +51,7 @@ magic.register_recipe("prospector",
else
minetest.chat_send_player(player:get_player_name(), "[Mod Magic] There is not a cave or is too far")
end
magic.gfx.recipe_ok(node.under)
end
)

BIN
textures/magic_bubble.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B