Contents
- Contents
- Introduction
- Methods
- quests:cache
- quests:create
- quests:createBuilder
- quests:createManuscript
- quests:getCompleted
- quests:getDescription
- quests:getDescriptionForUnstartedInRegionFromNPCName
- quests:getIncomplete
- quests:getLevelWarning
- quests:getNPCNamesForUnstartedInRegionForLevel
- quests:getOpen
- quests:getProgressDetails
- quests:getQuest
- quests:getQuestFromSlot
- quests:getRepeatable
- quests:isLoaded
- quests:list
- quests:listAll
- quests:listStates
- quests:load
- quests:register
- quests:unload
- Classes
- LuaQuest
- Public Members
- Public Methods
- LuaQuest:addToWorld
- LuaQuest:getFormattedHistory
- LuaQuest:getHistory
- LuaQuest:getMinLevel
- LuaQuest:getNPCName
- LuaQuest:getName
- LuaQuest:getOriginalName
- LuaQuest:getRegion
- LuaQuest:getSlotName
- LuaQuest:isCompleted
- LuaQuest:isRepeatable
- LuaQuest:isStarted
- LuaQuest:isVisibleOnQuestStatus
- LuaQuest:register
- LuaQuest:removeFromWorld
- LuaQuest:setAddFunction
- LuaQuest:setCompletedCheckFunction
- LuaQuest:setDescription
- LuaQuest:setFormattedHistoryFunction
- LuaQuest:setHistoryFunction
- LuaQuest:setMinLevel
- LuaQuest:setNPCName
- LuaQuest:setName
- LuaQuest:setRegion
- LuaQuest:setRemoveFunction
- LuaQuest:setRepeatable
- LuaQuest:setRepeatableCheckFunction
- LuaQuest:setSlotName
- LuaQuest:setStartedCheckFunction
- LuaQuest:setVisibleOnQuestStatus
- LuaQuest
- Usage Examples
Introduction
Object instance: quests
Description
Adds helper functions for creating & manipulating quests & exposes select public methods of the StendhalQuestSystem class.
Methods
quests:cache
quests:cache quest
- Call
registerdirectly from the quest instance. - Caches a quest for loading at server startup.
- Parameters:
- quest IQuest Quest instance to be cached.
quests:create
quests:create
quests:create slotName
quests:create slotName, name
quests:create slotName, name, desc
- Creates a new quest.
- Parameters:
- Returns: LuaQuest New quest instance.
quests:createBuilder
quests:createBuilder task
- Creates a quest builder to pass to
quests:createManuscript. - Parameters:
- task string Quest task type. Supported are "BringItemTask" & "KillCreaturesTask".
- Returns: QuestBuilder New quest builder instance.
quests:createManuscript
quests:createManuscript builder
- Creates a new quest in manuscript format.
- Parameters:
- builder QuestBuilder A quest builder instance that defines quest.
- Returns: QuestManuscript New quest instance.
quests:getCompleted
quests:getCompleted player
- Retrieves a list of completed quests from a player.
- Parameters:
- player Player Player instance to be checked.
- Returns: List<String> List of string identifiers for completed quests.
- TODO:
- Return table instead of Java list.
quests:getDescription
quests:getDescription player, questName
- Retrieves the description of a quest.
- Parameters:
- Returns: string Description.
quests:getDescriptionForUnstartedInRegionFromNPCName
quests:getDescriptionForUnstartedInRegionFromNPCName player, region,
name
- Retrieves quest descriptions for unstarted quests in a specified region matching a specific NPC name.
- Parameters:
- Returns: java.util.List<java.lang.String>
- TODO:
- Return table instead of Java list.
quests:getIncomplete
quests:getIncomplete player, region
- Retrieves a list of incomplete quests in a specified region.
- Parameters:
- Returns: java.util.List<java.lang.String> List of string identifiers of incomplete quests in region.
- TODO:
- Return table instead of Java list.
quests:getLevelWarning
quests:getLevelWarning player, questName
- If the quest is too dangerous, add a warning unless the player has already completed it.
- Parameters:
- Returns: string
quests:getNPCNamesForUnstartedInRegionForLevel
quests:getNPCNamesForUnstartedInRegionForLevel player, region
- Retrieves a list of the unique npc names for unstarted quests in a specified region.
- Parameters:
- Returns: java.util.List<java.lang.String>
- TODO:
- Return table instead of Java list.
quests:getOpen
quests:getOpen player
- Retrieves a list of open quests from a player.
- Parameters:
- player Player Player instance to be checked.
- Returns: java.util.List<java.lang.String> List of string identifiers for open quests.
- TODO:
- Return table instead of Java list.
quests:getProgressDetails
quests:getProgressDetails player, questeName
- Retrieves details on the progress of the quest.
- Parameters:
- Returns: java.util.List>java.lang.String<
- TODO:
- Return table instead of Java list.
quests:getQuest
quests:getQuest questName
- Retrieves the IQuest object for a named quest.
- Parameters:
- questName string Name of quest.
- Returns:
IQuest
Quest instance or
nilif doesn't exist.
quests:getQuestFromSlot
quests:getQuestFromSlot questSlot
- Retrieves the
IQuestobject for a quest. - Parameters:
- questSlot string Quest identifier string.
- Returns:
IQuest
Quest instance or
nilif doesn't exist.
quests:getRepeatable
quests:getRepeatable player
- Retrieves a list of quests a player has completed, and can now do again.
- Parameters:
- player Player Player instance to be checked.
- Returns: java.util.List>java.lang.String<
- TODO:
- Return table instead of Java list.
quests:isLoaded
quests:isLoaded quest
- Checks if a quest has been loaded.
- Parameters:
- quest IQuest Quest instance to check.
- Returns:
bool
trueif the instance matches stored quests.
quests:list
quests:list player, questName
- Creates a report on a specified quest for a player.
- Parameters:
- Returns: string Report.
quests:listAll
quests:listAll player
- List all quests the player knows about.
- Parameters:
- player Player Player to create the report for.
- Returns: string Report.
quests:listStates
quests:listStates player
- Dumps the internal quest states for the specified player. This is used for the InspectAction.
- Parameters:
- player Player Player to create the report for.
- Returns: string Report.
quests:load
quests:load quest
- Adds a quest to the world.
- Parameters:
- quest IQuest The quest instance to be loaded.
quests:register
quests:register quest
- DEPRECATED: Call
registerdirectly from the quest instance. - Caches a quest for loading at startup. Alias for
quests:cache. - Parameters:
- quest IQuest Quest instance to be cached.
quests:unload
quests:unload questName
- Removes a quest from the world.
- Parameters:
- questName string Name of the quest to be removed.
Classes
LuaQuest
See: LuaQuest
Public Members
LuaQuest.completedCheck
LuaQuest.completedCheck
- Called by
LuaQuest.isCompleted. - Type: function
LuaQuest.formattedHistory
LuaQuest.formattedHistory
- Called by
LuaQuest.getFormattedHistory. - Type: function
LuaQuest.history
LuaQuest.history
- Called by
LuaQuest.getHistory. - Type: function
LuaQuest.init
LuaQuest.init
- Called by IQuest.addToWorld.
- Type: function
LuaQuest.remove
LuaQuest.remove
- Called by IQuest.removeFromWorld.
- Type: function
LuaQuest.repeatableCheck
LuaQuest.repeatableCheck
- Called by
LuaQuest.isRepeatable. - Type: function
LuaQuest.startedCheck
LuaQuest.startedCheck
- Called by
LuaQuest.isStarted. - Type: function
Public Methods
LuaQuest:addToWorld
LuaQuest:addToWorld
- See IQuest.addToWorld.
LuaQuest:getFormattedHistory
LuaQuest:getFormattedHistory player
LuaQuest:getHistory
LuaQuest:getHistory player
LuaQuest:getMinLevel
LuaQuest:getMinLevel
LuaQuest:getNPCName
LuaQuest:getNPCName
LuaQuest:getName
LuaQuest:getName
- See IQuest.getName
LuaQuest:getOriginalName
LuaQuest:getOriginalName
- Retrieves unformatted quest name.
- Returns: string Unmodified quest name string.
LuaQuest:getRegion
LuaQuest:getRegion
- See IQuest.getRegion
LuaQuest:getSlotName
LuaQuest:getSlotName
LuaQuest:isCompleted
LuaQuest:isCompleted player
LuaQuest:isRepeatable
LuaQuest:isRepeatable
LuaQuest:isStarted
LuaQuest:isStarted player
- See IQuest.isStarted
LuaQuest:isVisibleOnQuestStatus
LuaQuest:isVisibleOnQuestStatus
LuaQuest:register
LuaQuest:register
LuaQuest:register func
- Registers quest to be added to world at server startup. If called without parameters
LuaQuest.initmust be set first. - Parameters:
- func
function
Function to execute when
quests:loadQuestis called.
- func
function
Function to execute when
LuaQuest:removeFromWorld
LuaQuest:removeFromWorld
LuaQuest:setAddFunction
LuaQuest:setAddFunction func
- DEPRECATED: Set
LuaQuest.initdirectly. - Sets the function for adding the quest to the game.
- Parameters:
- func
function
Function to invoke when
LuaQuest.addToWorldis called.
- func
function
Function to invoke when
LuaQuest:setCompletedCheckFunction
LuaQuest:setCompletedCheckFunction func
- Sets the function for checking if the quest is started.
- Parameters:
- func
function
Function to invoke when
LuaQuest.isCompletedis called.
- func
function
Function to invoke when
LuaQuest:setDescription
LuaQuest:setDescription desc
- Sets the quest description string.
- Parameters:
- desc string Quest description string.
LuaQuest:setFormattedHistoryFunction
LuaQuest:setFormattedHistoryFunction func
- Sets the function for retrieving formatted history of quest state.
- Parameters:
- func
function
Function to invoke when
LuaQuest.getFormattedHistoryis called.
- func
function
Function to invoke when
LuaQuest:setHistoryFunction
LuaQuest:setHistoryFunction func
- Sets the function for retrieving history of quest state.
- Parameters:
- func
function
Function to invoke when
LuaQuest.getHistoryis called.
- func
function
Function to invoke when
LuaQuest:setMinLevel
LuaQuest:setMinLevel level
- Sets the recommended minimum level.
- Parameters:
- level
int
Level to return when
LuaQuest.getMinLevelis called.
- level
int
Level to return when
LuaQuest:setNPCName
LuaQuest:setNPCName name
- Sets the NPC name.
- Parameters:
- name
string
NPC name to return when
LuaQuest.getNPCNameis called.
- name
string
NPC name to return when
LuaQuest:setName
LuaQuest:setName name
- Sets the quest name string.
- Parameters:
- name
string
Quest name string to be returned when
LuaQuest.getNameis called.
- name
string
Quest name string to be returned when
LuaQuest:setRegion
LuaQuest:setRegion region
- Sets the quest region.
- Parameters:
- region
string
Region string to be returned when
LuaQuest.getRegionis called.
- region
string
Region string to be returned when
LuaQuest:setRemoveFunction
LuaQuest:setRemoveFunction func
- DEPRECATED: Set
LuaQuest.removedirectly. - Sets the function for removing the quest from the game.
- Parameters:
- func
function
Function to invoke when
LuaQuest.removeFromWorldis called.
- func
function
Function to invoke when
LuaQuest:setRepeatable
LuaQuest:setRepeatable
- Sets the repeatable status of the quest (overrides
LuaQuest.setCompletedCheckFunction). - Parameters:
- repeatable
bool
If
true, the quest is repeatable.
- repeatable
bool
If
LuaQuest:setRepeatableCheckFunction
LuaQuest:setRepeatableCheckFunction func
- Sets the function for checking if the quest is repeatable.
- Parameters:
- func
function
Function to invoke when
LuaQuest.isRepeatableis called.
- func
function
Function to invoke when
LuaQuest:setSlotName
LuaQuest:setSlotName slot
- Sets the quest identifier string.
- Parameters:
- slot
string
Slot identifier string to be returned when
LuaQuest.getSlotNameis called.
- slot
string
Slot identifier string to be returned when
LuaQuest:setStartedCheckFunction
LuaQuest:setStartedCheckFunction func
- Sets the function for checking if the quest is started.
- Parameters:
- func
function
Function to invoke when
LuaQuest.isStartedis called.
- func
function
Function to invoke when
LuaQuest:setVisibleOnQuestStatus
LuaQuest:setVisibleOnQuestStatus visible
- Sets whether or not the quest should be shown in the travel log.
- Parameters:
- visible
bool
If
true, quest will be displayed in travel log.
- visible
bool
If
Usage Examples
Standard quest example:
local loadStep1 = function()
...
end
local loadStep2 = function()
...
end
local myQuest = quests:create("my_quest", "My Quest")
myQuest:register(function()
loadStep1()
loadStep2()
end)
Example of CoalForHaunchy quest manuscript converted to Lua:
local itemBuilder = quests:createBuilder("BringItemTask")
itemBuilder:info()
:name("Coal for Haunchy")
:description("Haunchy Meatoch is afraid of his BBQ grillfire. Will his coal last till the steaks are ready or will he need some more?")
:internalName("coal_for_haunchy")
:repeatableAfterMinutes(2 * 24 * 60)
:minLevel(0)
:region(Region.ADOS_CITY)
:questGiverNpc("Haunchy Meatoch")
itemBuilder:history()
:whenNpcWasMet("Haunchy Meatoch welcomed me to the Ados market.")
:whenQuestWasRejected("He asked me to fetch him some pieces of coal but I don't have time to collect some.")
:whenQuestWasAccepted("The BBQ grill-heat is low and I promised Haunchy to help him out with 25 pieces of coal.")
:whenTaskWasCompleted("I found 25 pieces of coal for the Haunchy and think he will be happy.")
:whenQuestWasCompleted("Haunchy Meatoch was really happy when I gave him the coal, he has enough for now. He gave me some of the best steaks which I ever ate!")
:whenQuestCanBeRepeated("But I'd bet his amount is low again and needs more. Maybe I'll get more grilled tasty steaks.")
itemBuilder:offer()
:respondToRequest("I cannot use wood for this huge BBQ. To keep the heat I need some really old stone coal but there isn't much left. The problem is, that I can't fetch it myself because my steaks would burn then so I have to stay here. Can you bring me 25 pieces of #coal for my BBQ please?")
:respondToUnrepeatableRequest("The coal amount behind my counter is still high enough. I will not need more for some time.")
:respondToRepeatedRequest("The last coal you brought me is mostly gone again. Will you bring me some more?")
:respondToAccept("Thank you! I'll be sure to give you a nice and tasty reward.")
:respondTo({"coal"}):saying("Coal isn't easy to find. You normally can find it somewhere in the ground but perhaps you are lucky and find some in the old Semos Mine tunnels... Will you help me?")
:respondToReject("Oh, never mind. I thought you love BBQs like I do. Bye then.")
:rejectionKarmaPenalty(10.0)
:remind("Luckily my BBQ is still going. But please hurry up to bring me 25 coal as you promised.")
entities:getNPC("Haunchy Meatoch"):addReply("coal", "Sometime you could do me a #favor ...")
itemBuilder:task()
:requestItem(25, "coal")
itemBuilder:complete()
:greet("Ah, I see, you have enough coal to keep my BBQ on! Is it for me?")
:respondToReject("Well then, hopefully someone else will help me before my BBQ goes out.")
:respondToAccept(nil)
:rewardWith(actions:create("IncreaseXPAction", {200}))
:rewardWith(actions:create("IncreaseKarmaAction", {20}))
:rewardWith(actions:create("EquipRandomAmountOfItemAction", {"grilled steak", 1, 4, 1,
"Thank you! Take [this_these] [number_item] from my grill!"}))
quests:register(quests:createManuscript(itemBuilder))