Changed objectives and their values
parent
fafd5a363f
commit
5313957f39
|
@ -1,11 +1,11 @@
|
||||||
local function subdivideObjective(str, desc)
|
local function subdivideObjective(str, desc)
|
||||||
local subdata = str:split(" ")
|
local subdata = str:split(" ")
|
||||||
if subdata[1] == "Return" then
|
if subdata[1] == "Return" then
|
||||||
return {type=subdata[1], description=desc, count=subdata[2],content=subdata[3]}
|
return {command=subdata[1], description=desc, total=subdata[2],content=subdata[3], completed=false, count=0}
|
||||||
elseif subdata[1] == "Collect" then
|
elseif subdata[1] == "Collect" then
|
||||||
return {type=subdata[1], description=desc, count=subdata[2],content=subdata[3]}
|
return {command=subdata[1], description=desc, total=subdata[2],content=subdata[3], completed=false, count=0}
|
||||||
elseif subdata[1] == "Kill" then
|
elseif subdata[1] == "Kill" then
|
||||||
return {type=subdata[1], description=desc, count=subdata[2],content=subdata[3]}
|
return {command=subdata[1], description=desc, total=subdata[2],content=subdata[3], completed=false, count=0}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function convertObjectiveString(str, desc)
|
local function convertObjectiveString(str, desc)
|
||||||
|
@ -26,19 +26,18 @@ end
|
||||||
function adventures.storeQuestData(data)
|
function adventures.storeQuestData(data)
|
||||||
local pos = {x=data[2],y=data[3],z=data[4]}
|
local pos = {x=data[2],y=data[3],z=data[4]}
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.env:get_meta(pos)
|
||||||
local objs = convertObjectiveString(meta:get_string("objective"), meta:get_string("description"))
|
local objs = convertObjectiveString(meta:get_string("name"), meta:get_string("objective"), meta:get_string("description"))
|
||||||
local y = 3+table.getn(objs)
|
local y = 3+table.getn(objs)
|
||||||
local str = "label[0,0;"..meta:get_string("name").."]"..
|
local str = "label[0,0;"..meta:get_string("name").."]"..
|
||||||
"list[context;reward;4,"..(y-3)..";2,2;]"..
|
"list[context;reward;4,"..(y-3)..";2,2;]"..
|
||||||
"list[context;items;0,"..(y-3)..";2,2;]"..
|
"list[context;items;0,"..(y-3)..";2,2;]"..
|
||||||
"button[1.5,"..(y-1)..";1.5,0.75;accept;Accept]"..
|
"button[2.25,"..(y-1)..";1.5,0.75;accept;Accept]"
|
||||||
"button_exit[3,"..(y-1)..";1.5,0.75;decline;Decline]"
|
|
||||||
for i,obj in pairs(objs) do
|
for i,obj in pairs(objs) do
|
||||||
str = str.."label[0.125,"..(i/2)..";"..obj.description.."]"
|
str = str.."label[0.125,"..(i/2)..";"..obj.description.."]"
|
||||||
end
|
end
|
||||||
str = "size[6,"..y.."]"..str
|
str = "size[6,"..y.."]"..str
|
||||||
meta:set_string("formspec", str)
|
meta:set_string("formspec", str)
|
||||||
adventures.quests[meta:get_string("name")] = {objectives = objs, id = meta:get_int("id")}
|
adventures.quests[meta:get_string("name")] = {source=pos, objectives = objs, completed=false, active=false}
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("adventures:quest", {
|
minetest.register_node("adventures:quest", {
|
||||||
|
@ -49,8 +48,18 @@ minetest.register_node("adventures:quest", {
|
||||||
on_receive_fields = function(pos, formname, fields, sender)
|
on_receive_fields = function(pos, formname, fields, sender)
|
||||||
if fields.accept then
|
if fields.accept then
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.env:get_meta(pos)
|
||||||
local quests = adventures.playerQuests[sender]
|
adventures.currentQuests[meta:get_string("name")] = adventures.quests[meta:get_string("name")]
|
||||||
quests[meta:get_string("name")] = adventures.quests[meta:get_string("name")]
|
local objs = adventures.currentQuests[meta:get_string("name")].objectives
|
||||||
|
for _,obj in pairs(objs) do
|
||||||
|
if obj.command == "Return" then
|
||||||
|
table.insert(adventures.currentObjectives["Return"], {quest=name, index=i})
|
||||||
|
elseif obj.command == "Collect" then
|
||||||
|
print("Storing Collect Objective")
|
||||||
|
table.insert(adventures.currentObjectives["Collect"], {quest=name, index=i})
|
||||||
|
elseif obj.command == "Kill" then
|
||||||
|
table.insert(adventures.currentObjectives["Kill"], {quest=name, index=i})
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
|
Loading…
Reference in New Issue