Add files via upload

master
CosmosScripter 2019-07-24 21:34:29 -03:00 committed by GitHub
parent 14ec812829
commit ad561b6e0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 644 additions and 0 deletions

2
depends.txt Normal file
View File

@ -0,0 +1,2 @@
default
bows

409
init.lua Normal file
View File

@ -0,0 +1,409 @@
minetest.register_craftitem("zelda:key", {
description = "Key",
inventory_image = "key.png",
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type == "node" then
local pos1 = pointed_thing.under
local pos3 = {x=pos1.x, y=pos1.y + 1, z=pos1.z}
local pos2 = {x=pos1.x, y=pos1.y - 1, z=pos1.z}
local node_name = minetest.get_node(pos1).name
if node_name =="doors:door_steel_t_1" then
minetest.env:remove_node(pos1)
minetest.env:remove_node(pos2)
nodeupdate(pos1)
nodeupdate(pos2)
minetest.sound_play("secret", pos1)
if minetest.setting_getbool("creative_mode") then
itemstack:take_item()
else
itemstack:take_item()
end
return itemstack
elseif node_name=="doors:door_steel_b_1" then
minetest.env:remove_node(pos1)
minetest.env:remove_node(pos3)
nodeupdate(pos1)
nodeupdate(pos3)
minetest.sound_play("secret", pos1)
if minetest.setting_getbool("creative_mode") then
itemstack:take_item()
else
itemstack:take_item()
end
return itemstack
end
end
end,
})
minetest.register_node("zelda:chest", {
description = "Treasure Chest",
inventory_image = "treasure_img.png",
tiles = {
"surprise_top.png",
"surprise_top.png",
"surprise_side.png",
"surprise_side.png",
"surprise_side.png",
"surprise_front.png",
},
paramtype = "light",
light_source = 5,
groups = {choppy = 2, oddly_breakable_by_hand = 2},
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
minetest.sound_play("surprise", pos)
minetest.chat_send_player(clicker:get_player_name(), "<Chest> You got....")
minetest.after(7.9, function()
local choose = math.random(1,5)
minetest.env:remove_node(pos)
nodeupdate(pos)
minetest.add_particlespawner({
amount = 80,
time = 0.1,
minpos = {x=pos.x, y=pos.y, z=pos.z},
maxpos = {x=pos.x, y=pos.y, z=pos.z},
minvel = {x=-5, y=-5, z=-5},
maxvel = {x=5, y=5, z=5},
minacc = {x=0, y=-10, z=0},
maxacc = {x=0, y=-10, z=0},
minexptime = 1,
maxexptime = 1,
minsize = 1,
maxsize = 1,
collisiondetection = true,
vertical = false,
texture = "drop.png",
})
if choose == 1 then
minetest.add_item(pos, "default:apple")
minetest.chat_send_player(clicker:get_player_name(), "<Chest> AN APPLE!")
elseif choose == 2 then
minetest.add_item(pos, "default:diamond")
minetest.add_item(pos, "default:gold_lump")
minetest.add_item(pos, "default:steel_ingot")
minetest.add_item(pos, "default:coal_lump")
minetest.chat_send_player(clicker:get_player_name(), "<Chest> ORES!")
elseif choose == 3 then
minetest.add_item(pos, "bows:bow_obsidian")
minetest.chat_send_player(clicker:get_player_name(), "<Chest> A BOW!")
elseif choose == 4 then
minetest.add_item(pos, "zelda:key")
minetest.chat_send_player(clicker:get_player_name(), "<Chest> A KEY!")
elseif choose == 5 then
minetest.add_item(pos, "zelda:master_sword")
minetest.chat_send_player(clicker:get_player_name(), "<Chest> THE MASTER SWORD!")
end
end)
end,
})
minetest.register_craft( {
output = "zelda:chest",
recipe = {
{"", "default:gold_ingot", ""},
{"default:gold_ingot", "default:chest", "default:gold_ingot"},
{"", "default:gold_ingot", ""}
}
})
minetest.register_tool("zelda:master_sword", {
description = "Master Sword",
inventory_image = "master_sword.png",
stack_max = 1,
tool_capabilities = {
full_punch_interval = 0.05,
max_drop_level=0,
damage_groups = {fleshy=15},
groupcaps={
fleshy={time ={[2]=0.65, [3]=0.25}, uses=200, maxlevel=3},
snappy={times={[2]=0.70, [3]=0.25}, uses=200, maxlevel=3},
choppy={times={[3]=0.65}, uses=200, maxlevel=0}
}
}
})
minetest.register_node("zelda:pot", {
description = "Pot",
drawtype = "plantlike",
tiles = {"pot.png"},
paramtype = "light",
inventory_image = "pot.png",
visual_scale = 1.1,
wield_scale = {x=1.1, y=1.1, z=1.1},
groups = {choppy=3},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}
},
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local chance = math.random(1,5)
minetest.env:remove_node(pos)
nodeupdate(pos)
clicker:get_inventory():add_item("main", "zelda:pot1")
minetest.sound_play("pick_pot", pos)
if chance >= 3 then
minetest.add_particlespawner({
amount = 1,
time = 0.1,
minpos = {x=pos.x, y=pos.y, z=pos.z},
maxpos = {x=pos.x, y=pos.y, z=pos.z},
minvel = {x=-5, y=-5, z=-5},
maxvel = {x=5, y=5, z=5},
minacc = {x=0, y=-10, z=0},
maxacc = {x=0, y=-10, z=0},
minexptime = 3,
maxexptime = 3,
minsize = 2,
maxsize = 2,
collisiondetection = true,
vertical = false,
texture = "heart.png",
})
minetest.sound_play("heart", pos)
clicker:set_hp(clicker:get_hp()+5)
end
end,
})
minetest.register_craftitem("zelda:pot1", {
description = "Pot (throwable)",
inventory_image = "pot.png",
on_use = function(itemstack, user, pointed_thing)
if not minetest.setting_getbool("creative_mode") then itemstack:take_item()
end
if pointed_thing.type ~= "nothing" then
local pointed = minetest.get_pointed_thing_position(pointed_thing)
if vector.distance(user:getpos(), pointed) < 8 then
return itemstack
end
end
local pos = user:getpos()
local dir = user:get_look_dir()
local yaw = user:get_look_yaw()
if pos and dir then
pos.y = pos.y + 1.5
minetest.sound_play("throw", pos)
local obj = minetest.add_entity(pos, "zelda:pot_entity")
if obj then
obj:setvelocity({x=dir.x * 20, y=dir.y * 20, z=dir.z * 20})
obj:setacceleration({x=dir.x * -3, y=-10, z=dir.z * -3})
obj:setyaw(yaw + math.pi)
local ent = obj:get_luaentity()
if ent then
ent.player = ent.player or user
end
end
end
return itemstack
end,
})
local ZELDA_POT_ENTITY={
physical = false,
timer=0,
visual = "sprite",
visual_size = {x=0.5, y=0.5},
textures = {"pot.png"},
lastpos={},
collisionbox = {0,0,0,0,0,0},
}
ZELDA_POT_ENTITY.on_step = function(self, dtime)
self.timer = self.timer + dtime
local pos = self.object:getpos()
local node = minetest.get_node(pos)
if self.timer > 0.12 then
local objs = minetest.get_objects_inside_radius({x = pos.x, y = pos.y, z = pos.z}, 1)
for k, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then
if obj:get_luaentity().name ~= "zelda:pot_entity" and obj:get_luaentity().name ~= "__builtin:item" then
local damage = 5
obj:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups= {fleshy = damage},
}, nil)
minetest.sound_play("shatter", {pos = self.lastpos, gain = 0.8})
self.object:remove()
end
else
local damage = 5
obj:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups= {fleshy = damage},
}, nil)
minetest.sound_play("shatter", {pos = self.lastpos, gain = 0.8})
self.object:remove()
end
end
end
if self.lastpos.x ~= nil then
if minetest.registered_nodes[node.name].walkable then
if not minetest.setting_getbool("creative_mode") then
minetest.add_item(self.lastpos, "default:clay_brick")
minetest.add_item(self.lastpos, "default:clay_lump")
end
minetest.sound_play("shatter", {pos = self.lastpos, gain = 0.8})
self.object:remove()
end
end
self.lastpos= {x = pos.x, y = pos.y, z = pos.z}
end
minetest.register_entity("zelda:pot_entity", ZELDA_POT_ENTITY)
minetest.register_craft( {
output = "zelda:pot",
recipe = {
{"", "default:clay_brick", ""},
{"default:clay_brick", "bucket:bucket_empty", "default:clay_brick"},
{"", "default:clay_brick", ""}
}
})
minetest.register_craftitem("zelda:navi", {
description = "Navi",
inventory_image = "fairy.png",
on_use = function(itemstack, user, pointed_thing)
if user:get_hp() <= 5 then
local pos = user:getpos()
minetest.add_particlespawner({
amount = 1,
time = 0.1,
minpos = {x=pos.x, y=pos.y, z=pos.z},
maxpos = {x=pos.x, y=pos.y, z=pos.z},
minvel = {x=-2, y=-5, z=-2},
maxvel = {x=2, y=10, z=2},
minacc = {x=0, y=-1, z=0},
maxacc = {x=0, y=-1, z=0},
minexptime = 4,
maxexptime = 4,
minsize = 2,
maxsize = 2,
collisiondetection = true,
vertical = false,
texture = "fairy.png",
})
minetest.add_particlespawner({
amount = 80,
time = 0.1,
minpos = {x=pos.x, y=pos.y, z=pos.z},
maxpos = {x=pos.x, y=pos.y, z=pos.z},
minvel = {x=-2, y=-5, z=-2},
maxvel = {x=2, y=10, z=2},
minacc = {x=0, y=-1, z=0},
maxacc = {x=0, y=-1, z=0},
minexptime = 1,
maxexptime = 1,
minsize = 1,
maxsize = 2,
collisiondetection = true,
vertical = false,
texture = "drop.png",
})
minetest.sound_play("navi", pos)
user:set_hp(user:get_hp()+10)
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return itemstack
else
local pos = user:getpos()
local voice = math.random(1,5)
if voice == 1 then
minetest.sound_play("hello", pos)
elseif voice == 2 then
minetest.sound_play("hey", pos)
elseif voice == 3 then
minetest.sound_play("listen", pos)
elseif voice == 4 then
minetest.sound_play("look", pos)
elseif voice == 5 then
minetest.sound_play("watchout", pos)
end
end
end,
})
minetest.register_craft( {
output = "zelda:navi",
recipe = {
{"", "default:mese_crystal_fragment", ""},
{"default:mese_crystal_fragment", "zelda:pot", "default:mese_crystal_fragment"},
{"", "default:mese_crystal_fragment", ""}
}
})
minetest.register_craftitem("zelda:ocarina", {
description = "Ocarina of Time",
inventory_image = "ocarina.png",
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
local key = user:get_player_control()
if key.sneak then
time = minetest.get_timeofday()
hp = user:get_hp()
posoc = user:getpos()
time_mel = true
minetest.chat_send_player(user:get_player_name(), "<Ocarina Of Time> You will come back to this moment when you play the Song of Time.")
elseif key.aux1 then
local p = {
pos1 = {x=pos.x, y=pos.y+1, z=pos.z},
pos2 = {x=pos.x, y=pos.y-1, z=pos.z},
pos3 = {x=pos.x+1, y=pos.y, z=pos.z},
pos4 = {x=pos.x-1, y=pos.y, z=pos.z},
pos5 = {x=pos.x, y=pos.y, z=pos.z+1},
pos6 = {x=pos.x, y=pos.y, z=pos.z-1},
}
for k, v in pairs(p) do
if (minetest.get_node(v).name == "default:water_source" or minetest.get_node(v).name == "default:water_flowing") then
minetest.sound_play("song_storms", pos)
minetest.after(4.0, function()
minetest.env:remove_node(v)
minetest.chat_send_player(user:get_player_name(), "<Ocarina Of Time> You've played the Song of Storms.")
end)
end
end
else
if time_mel == true then
minetest.sound_play("song_time", pos)
minetest.after(9.0, function()
user:setpos(posoc)
user:set_hp(hp)
minetest.set_timeofday(time)
minetest.chat_send_player(user:get_player_name(), "<Ocarina Of Time> You've played the Song of Time.")
end)
else
minetest.chat_send_player(user:get_player_name(), "<Ocarina Of Time> You must play another melody before trying this.")
end
end
end,
})
minetest.register_craft( {
output = "zelda:ocarina",
recipe = {
{"", "default:mese_crystal", ""},
{"default:mese_crystal", "zelda:navi", "default:mese_crystal"},
{"", "zelda:master_sword", ""}
}
})
--Treasures in Desert's Dungeons and Mines
dofile(minetest.get_modpath("zelda").."/mines.lua")
minetest.register_ore({
ore_type = "scatter",
ore = "zelda:chest",
wherein = "default:desert_stone",
clust_scarcity = 35*35*35,
clust_num_ores = 1,
clust_size = 1,
height_min = -500,
height_max = -4,
})

233
mines.lua Normal file
View File

@ -0,0 +1,233 @@
local MINE_DEEP_MIN = tonumber(minetest.setting_get("mines_deep_min"))
local MINE_DEEP_MAX = tonumber(minetest.setting_get("mines_deep_max"))
local MINE_FACTOR = tonumber(minetest.setting_get("mines_spawnfactor"))
if not MINE_DEEP_MIN then
MINE_DEEP_MIN = -64
end
if not MINE_DEEP_MAX then
MINE_DEEP_MAX = -380
end
if not MINE_FACTOR then
MINE_FACTOR = 1.5
end
minetest.register_node("zelda:dummy", {
description = "Air (you hacker you!)",
inventory_image = "unknown_node.png",
wield_image = "unknown_node.png",
drawtype = "airlike",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
air_equivalent = true,
drop = "",
groups = {not_in_creative_inventory=1},
})
local ids = {
air = minetest.get_content_id("air"),
fence = minetest.get_content_id("default:fence_wood"),
wood = minetest.get_content_id("default:wood"),
dummy = minetest.get_content_id("zelda:dummy")
}
local function rotate_torch(pos)
minetest.after(8, function()
local n = minetest.get_node(pos)
if n ~= nil then
if n.name == "zelda:dummy" then
minetest.set_node(pos, {name="default:torch",param2=1})
end
end
end)
end
local function fill_chest(pos)
minetest.after(5, function()
local n = minetest.get_node(pos)
if n ~= nil then
if n.name == "zelda:dummy" then
minetest.set_node(pos, {name="zelda:chest"})
local meta = minetest.get_meta(pos)
end
end
end)
end
local function check_dir(dir,old_dir)
if old_dir == 1 and dir == 3 then
--n_switch = 2
return true
elseif old_dir == 3 and dir == 1 then
--n_switch = 4
return true
elseif old_dir == 2 and dir == 4 then
--n_switch = 1
return true
elseif old_dir == 4 and dir == 2 then
--n_switch = 3
return true
end
return false
end
local function make_mine(mpos,p2,p3, vm_data, vx_area,cnt)
local pos = {x=mpos.x,y=mpos.y,z=mpos.z}
for j=0,12,1 do
local switch = cnt+1
n_switch = math.random(1,4)
while check_dir(n_switch,switch) == true do
n_switch = math.random(1,4)
end
switch = n_switch
for i=0,20,1 do
local pillar = ids.air
local pillar_top = ids.air
if i==0 or i == 5 or i == 10 or i == 15 or i == 20 then
pillar = ids.fence
pillar_top = ids.wood
end
local x1
local x2
local x3
local x4
local z1
local z2
local z3
local z4
if switch == 1 then
x1 = pos.x+1
x2 = pos.x
x3 = pos.x-1
x4 = pos.x
x5 = pos.x+1
z1 = pos.z+i
z2 = pos.z+i
z3 = pos.z+i
z4 = pos.z+i-1
z5 = pos.z+i
elseif switch == 2 then
x1 = pos.x+i
x2 = pos.x+i
x3 = pos.x+i
x4 = pos.x+i-1
x5 = pos.x+i
z1 = pos.z+1
z2 = pos.z
z3 = pos.z-1
z4 = pos.z
z5 = pos.z+1
elseif switch == 3 then
x1 = pos.x+1
x2 = pos.x
x3 = pos.x-1
x4 = pos.x
x5 = pos.x+1
z1 = pos.z-i
z2 = pos.z-i
z3 = pos.z-i
z4 = pos.z-i-1
z5 = pos.z-i
else
x1 = pos.x-i
x2 = pos.x-i
x3 = pos.x-i
x4 = pos.x-i-1
x5 = pos.x-i
z1 = pos.z+1
z2 = pos.z
z3 = pos.z-1
z4 = pos.z
z5 = pos.z+1
end
vm_data[vx_area:indexp({x=x1, y=pos.y-1, z=z1})] = pillar
vm_data[vx_area:indexp({x=x2, y=pos.y-1, z=z2})] = ids.air
vm_data[vx_area:indexp({x=x3, y=pos.y-1, z=z3})] = pillar
vm_data[vx_area:indexp({x=x1, y=pos.y, z=z1})] = pillar
vm_data[vx_area:indexp({x=x2, y=pos.y, z=z2})] = ids.air
vm_data[vx_area:indexp({x=x3, y=pos.y, z=z3})] = pillar
vm_data[vx_area:indexp({x=x1, y=pos.y+1, z=z1})] = pillar_top
vm_data[vx_area:indexp({x=x2, y=pos.y+1, z=z2})] = pillar_top
vm_data[vx_area:indexp({x=x3, y=pos.y+1, z=z3})] = pillar_top
if math.random(0,6) == 3 then
vm_data[vx_area:indexp({x=x4, y=pos.y-1, z=z4})] = ids.dummy
rotate_torch({x=x4, y=pos.y-1, z=z4})
end
if math.random(0,60) == 13 then
local p = {x=x5, y=pos.y-1, z=z5}
if vm_data[vx_area:indexp(p)] ~= ids.fence then
vm_data[vx_area:indexp(p)] = ids.dummy
fill_chest(p)
end
end
end
if switch == 1 then
pos.z = pos.z+20
--pos.x = pos.x+step
elseif switch == 2 then
pos.x = pos.x+20
--pos.z = pos.z+step
elseif switch == 3 then
pos.z = pos.z-20
--pos.x = pos.x+step
elseif switch == 4 then
pos.x = pos.x-20
--pos.z = pos.z+step
end
end
if cnt == 0 then
minetest.log("action", "Created mine at ("..mpos.x..","..mpos.y..","..mpos.z..")")
local out2 = make_mine(p2,p3,mpos,vm_data,vx_area,1)
local out3 = make_mine(p3,p2,mpos,out2,vx_area,2)
return out3
else
return vm_data
end
end
local function find_cave(min,max,vm_data, vx_area)
local out = nil
for i in vx_area:iterp(min, max) do
if vm_data[i] == ids.air then
local p = vx_area:position(i)
if p.y <= MINE_DEEP_MIN then out = p end
end
end
return out
end
local cnt = 0
minetest.register_on_generated(function(minp, maxp, seed)
if minp.y > MINE_DEEP_MIN or minp.y < MINE_DEEP_MAX then
return
end
cnt = cnt+1
if cnt < 8/MINE_FACTOR then return end
cnt = 0
--if math.random(0,100) > 85 then return end
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local data = vm:get_data()
local va = VoxelArea:new{ MinEdge = emin, MaxEdge = emax }
local mpos = find_cave(emin,emax,data,va)
if mpos == nil then return end
local mpos2 = {x=mpos.x+math.random(0,3),y=mpos.y-1,z=mpos.z}
local mpos3 = {x=mpos.x,y=mpos.y-2,z=mpos.z+math.random(0,3)}
data = make_mine(mpos,mpos2,mpos3, data, va, 0)
vm:set_data(data)
vm:calc_lighting(emin,emax)
vm:update_liquids()
vm:write_to_map()
end)

BIN
sounds/heart.ogg Normal file

Binary file not shown.

BIN
sounds/hello.ogg Normal file

Binary file not shown.

BIN
sounds/hey.ogg Normal file

Binary file not shown.

BIN
sounds/listen.ogg Normal file

Binary file not shown.

BIN
sounds/look.ogg Normal file

Binary file not shown.

BIN
sounds/navi.ogg Normal file

Binary file not shown.

BIN
sounds/pick_pot.ogg Normal file

Binary file not shown.

BIN
sounds/secret.ogg Normal file

Binary file not shown.

BIN
sounds/shatter.ogg Normal file

Binary file not shown.

BIN
sounds/song_storms.ogg Normal file

Binary file not shown.

BIN
sounds/song_time.ogg Normal file

Binary file not shown.

BIN
sounds/surprise.ogg Normal file

Binary file not shown.

BIN
sounds/throw.ogg Normal file

Binary file not shown.

BIN
sounds/watchout.ogg Normal file

Binary file not shown.

BIN
textures/drop.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
textures/fairy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 B

BIN
textures/heart.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 B

BIN
textures/key.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 B

BIN
textures/master_sword.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

BIN
textures/ocarina.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

BIN
textures/pot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

BIN
textures/surprise_front.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

BIN
textures/surprise_side.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

BIN
textures/surprise_top.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

BIN
textures/treasure_img.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B