-- helper functions for yl_speak_up.input_fs_manage_quests(..) -- returns the index of the new quest yl_speak_up.input_fs_manage_quests_add_new_entry = function(pname, entry_name) local res = yl_speak_up.add_quest(pname, entry_name, "Name of your quest", "Enter a longer description here for describing the quest ".. "to players who search for one.", "Enter a short description here describing what the quest is about.", "Room for comments/notes") -- TODO: might make sense to show the error message somewhere if(res ~= "OK") then return -1 end local quest_list = yl_speak_up.get_sorted_quest_list(pname) return table.indexof(quest_list, entry_name) end -- helper functions for yl_speak_up.input_fs_manage_quests(..) -- returns a text describing if deleting the quest worked yl_speak_up.input_fs_manage_quests_del_old_entry = function(pname, entry_name) return "NOT IMPLEMENTED YET" -- delete (empty) variable -- return yl_speak_up.del_quest_variable(pname, entry_name, nil) end -- helper functions for yl_speak_up.input_fs_manage_quests(..) -- implements all the functions that are specific to managing quests and not part of -- general item management yl_speak_up.input_fs_manage_quests_check_fields = function(player, formname, fields, quest_name, list_of_entries) local pname = player:get_player_name() if(not(quest_name)) then quest_name = "" end if(fields and fields.show_variable) then yl_speak_up.show_fs(player, "manage_variables", quest_name) return end -- this function didn't have anything to do return "NOTHING FOUND" end -- makes use of yl_speak_up.input_fs_manage_general and is thus pretty short yl_speak_up.input_fs_manage_quests = function(player, formname, fields) local pname = player:get_player_name() local quest_list = yl_speak_up.get_sorted_quest_list(pname) local res = yl_speak_up.input_fs_manage_general(player, formname, fields, -- what_is_the_list_about, min_length, max_length, function_add_new_entry, "quest", 2, 80, yl_speak_up.input_fs_manage_quests_add_new_entry, quest_list, yl_speak_up.input_fs_manage_quests_del_old_entry, yl_speak_up.input_fs_manage_quests_check_fields) return true end yl_speak_up.get_fs_manage_quests = function(player, param) local pname = player:get_player_name() local quest_list = yl_speak_up.get_sorted_quest_list(pname) local formspec = {} if(param and param ~= "") then local index = table.indexof(quest_list, param) yl_speak_up.speak_to[pname].tmp_index_general = index + 1 end table.insert(formspec, "size[18,12]".. "label[0.2,1.2;A quest is a linear sequence of quest steps. Quests can ".. "depend on and influence other quests.\n".. "Progress for each player is stored in a variable. The name of ".. "that variable cannot be changed after creation.]") local selected = yl_speak_up.get_fs_manage_general(player, param, formspec, quest_list, "Create quest", "Create a new varialbe with the name\n".. "you entered in the field to the left.", "quest", "Enter the name of the new quest you want to create.\n".. "You can't change this name afterwards. But you *can*\n".. "add and change a human readable description later on.", "If you click here, the selected quest will be deleted.\n".. "This will only be possible if it's not used anywhere.") if(selected and selected ~= "") then local k = selected -- index 1 is "Add variable:" table.insert(formspec, "button[12,2.15;4.5,0.6;show_variable;Show and edit this variable]") end return table.concat(formspec, "") end