added quest cmd to story mod

This commit is contained in:
cale 2016-03-04 20:08:14 +01:00
parent ee7e8f6e75
commit 944a6899b2
6 changed files with 46 additions and 12 deletions

View File

@ -116,6 +116,22 @@ minetest.register_node("default:stones_on_floor", {
})
minetest.register_node("default:rope", {
description = "Rope",
tiles = {"default_rope.png"},
groups = {snappy = 3},
paramtype = "light",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.1, -0.5, -0.1, 0.1, 0.5, 0.1},
},
},
walkable = false,
climbable = true,
})
-- box

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 B

View File

@ -34,8 +34,9 @@ function quests.add_quest(player, quest)
if not quests.player_quests[player] then
quests.player_quests[player] = {}
end
print("[quests] add quest")
table.insert(quests.player_quests[player], quest)
quests.save_quests()
end
quests.show_quests_form = "size[8,7.5;]"
@ -57,7 +58,7 @@ minetest.register_chatcommand("quests", {
local s = quests.show_quests_form
local txt = ""
for k,v in pairs(quests.player_quests[name]) do
txt = txt .. " -> " .. k.quest_type .. " " .. v.node .. " (" .. tostring(v.progress) .. "/" .. tostring(v.max) .. ")\n"
txt = txt .. " -> " .. v.quest_type .. " " .. v.node .. " (" .. tostring(v.progress) .. "/" .. tostring(v.max) .. ")\n"
end
s = string.format(s, txt)
minetest.show_formspec(name, "quests:show_quests", s)
@ -66,19 +67,24 @@ minetest.register_chatcommand("quests", {
})
minetest.register_on_dignode(function(pos, oldnode, digger)
print("[quests] dig")
if not digger or not digger:is_player() then
return
end
print("[quests] dig 1")
if not quests.player_quests[digger:get_player_name()] then
return
end
print("[quests] dig 2")
table.foreach(quests.player_quests[digger:get_player_name()], function(k, v)
if v.quest_type == "dignode" and newnode.name == v.node then
print("[quests] run quest " .. v.quest_type .. ", " .. v.node)
if v.quest_type == "dignode" and oldnode.name == v.node then
v.progress = v.progress + 1
if v.v.progress > (v.max-1) and v.done == false then
xp.add_xp(player, v.xp)
if v.progress > (v.max-1) and v.done == false then
xp.add_xp(digger, v.xp)
v.done = true
end
quests.save_quests()
end
end)
end)
@ -93,10 +99,11 @@ minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack
table.foreach(quests.player_quests[placer:get_player_name()], function(k, v)
if v.quest_type == "placenode" and newnode.name == v.node then
v.progress = v.progress + 1
if v.v.progress > (v.max-1) and v.done == false then
xp.add_xp(player, v.xp)
if v.progress > (v.max-1) and v.done == false then
xp.add_xp(placer, v.xp)
v.done = true
end
quests.save_quests()
end
end)
end)
@ -105,6 +112,8 @@ minetest.register_on_newplayer(function(player)
quests.player_quests[player:get_player_name()] = {}
end)
quests.load_quests()
-- side quests
minetest.register_node("quests:quest_block", {

View File

@ -172,6 +172,16 @@ function story.generator.run(part, player, line_pos)
story.generator.players_storys[player:get_player_name()].pos = places.pos[cmd[2]]
end
end
if cmd[1] == "$quest" and cmd[2] and cmd[3] and cmd[4] and cmd[5] and tonumber(cmd[4]) and tonumber(cmd[5]) then
quests.add_quest(player:get_player_name(), {
quest_type = cmd[2],
node = cmd[3],
progress = 0,
done = false,
max = tonumber(cmd[4]),
xp = tonumber(cmd[5])
})
end
if cmd[1] == "$pos" then
story.generator.players_storys[player:get_player_name()].pos = {x=0,y=10,z=0}
end

View File

@ -2,8 +2,4 @@ $dialog test
$place home
$create
$wait
$dialog test
$place homeB
$create
$wait
$spawn pets:pig homePig
$quest dignode default:grass 10 39

View File

@ -13,6 +13,9 @@ function xp.add_xp(player, num)
xp.player_xp[player:get_player_name()] = xp.player_xp[player:get_player_name()] + num
else
xp.player_xp[player:get_player_name()] = num
if not xp.player_levels[player:get_player_name()] then
xp.player_levels[player:get_player_name()] = 1
end
end
cmsg.push_message_player(player, "You got "..tostring(num).. " xp!")