Class LuaQuestHelper.LuaQuest

java.lang.Object
games.stendhal.server.maps.quests.AbstractQuest
games.stendhal.server.core.scripting.lua.LuaQuestHelper.LuaQuest
All Implemented Interfaces:
IQuest
Enclosing class:
LuaQuestHelper

public static class LuaQuestHelper.LuaQuest extends AbstractQuest
Class to aid with quest manipulation in Lua.
  • Field Details

    • init

      public org.luaj.vm2.LuaFunction init
      Function executed when StendhalQuestSystem.loadQuest is called.
    • remove

      public org.luaj.vm2.LuaFunction remove
    • history

      public org.luaj.vm2.LuaFunction history
    • formattedHistory

      public org.luaj.vm2.LuaFunction formattedHistory
    • startedCheck

      public org.luaj.vm2.LuaFunction startedCheck
    • repeatableCheck

      public org.luaj.vm2.LuaFunction repeatableCheck
    • completedCheck

      public org.luaj.vm2.LuaFunction completedCheck
  • Method Details

    • register

      public void register()
      Registers quest to be added to world. LuaQuest.init must be set before this is called. (alternatively call questSystem:cacheQuest(LuaQuest))
    • register

      public void register(org.luaj.vm2.LuaFunction func)
      Registers quest to be added to world.
      Parameters:
      func - Function to execute when StendhalQuestSystem.loadQuest is called.
    • getName

      public String getName()
      Description copied from interface: IQuest
      Returns the name of the quest.
      Specified by:
      getName in interface IQuest
      Specified by:
      getName in class AbstractQuest
      Returns:
      name
    • getOriginalName

      public String getOriginalName()
      Retrieves unformatted quest name.
      Returns:
      Unmodified quest name string.
    • getSlotName

      public String getSlotName()
      Description copied from class: AbstractQuest
      The slot-name in !quests.
      Specified by:
      getSlotName in interface IQuest
      Specified by:
      getSlotName in class AbstractQuest
      Returns:
      the slot's name
    • getHistory

      public List<String> getHistory(Player player)
      Description copied from interface: IQuest
      Gets a the quest history for the given player, written in the first person.
      Parameters:
      player - Player
      Returns:
      list of history item-names
    • getFormattedHistory

      public List<String> getFormattedHistory(Player player)
      Specified by:
      getFormattedHistory in interface IQuest
      Overrides:
      getFormattedHistory in class AbstractQuest
    • getMinLevel

      public int getMinLevel()
      Description copied from interface: IQuest
      Returns the minimum level of player expected to start the quest. Used for choosing which hints to give. To set a hard minimum level requirement for doing the quest, use level related ChatConditions in the quest methods
      Specified by:
      getMinLevel in interface IQuest
      Overrides:
      getMinLevel in class AbstractQuest
      Returns:
      level
    • getRegion

      public String getRegion()
      Description copied from class: AbstractQuest
      Returns the region where the quest adventure takes place (or begins), or null for global quests
      Specified by:
      getRegion in interface IQuest
      Overrides:
      getRegion in class AbstractQuest
      Returns:
      region, or null for global quests
    • getNPCName

      public String getNPCName()
      Description copied from class: AbstractQuest
      Returns the starter NPC for the quest, or null if there is none
      Specified by:
      getNPCName in interface IQuest
      Overrides:
      getNPCName in class AbstractQuest
      Returns:
      NPC name, or null for quests with no starter NPC
    • isVisibleOnQuestStatus

      public boolean isVisibleOnQuestStatus()
      Description copied from class: AbstractQuest
      Denotes whether quest details should be included in travel log. Override to create custom checks.
      Specified by:
      isVisibleOnQuestStatus in interface IQuest
      Overrides:
      isVisibleOnQuestStatus in class AbstractQuest
      Returns:
      `true` if details should be included.
    • isStarted

      public boolean isStarted(Player player)
      Description copied from interface: IQuest
      Was the quest started?
      Specified by:
      isStarted in interface IQuest
      Overrides:
      isStarted in class AbstractQuest
      Parameters:
      player - Player
      Returns:
      true, if it was started, false otherwise
    • addToWorld

      public void addToWorld()
      Description copied from interface: IQuest
      adds the quest to the game world (e.g. by placing SpeakerNPCs there)
      Specified by:
      addToWorld in interface IQuest
      Specified by:
      addToWorld in class AbstractQuest
    • removeFromWorld

      public boolean removeFromWorld()
      Description copied from class: AbstractQuest
      removes a quest from the world.
      Specified by:
      removeFromWorld in interface IQuest
      Overrides:
      removeFromWorld in class AbstractQuest
      Returns:
      true, if the quest could be removed; false otherwise.
    • isRepeatable

      public boolean isRepeatable(Player player)
      Description copied from interface: IQuest
      May the quest be repeated?
      Specified by:
      isRepeatable in interface IQuest
      Overrides:
      isRepeatable in class AbstractQuest
      Parameters:
      player - Player
      Returns:
      true, if it can be repeated, false otherwise
    • isCompleted

      public boolean isCompleted(Player player)
      Description copied from interface: IQuest
      Was the quest completed? Note: A quest can be completed without its status being "Done" (e. g. rejected, failed).
      Specified by:
      isCompleted in interface IQuest
      Overrides:
      isCompleted in class AbstractQuest
      Parameters:
      player - Player
      Returns:
      true, if it was completed, false otherwise
    • setName

      public void setName(String name)
      Sets the quest name string.
      Parameters:
      name - Quest name string to be returned when getName() is called.
    • setDescription

      public void setDescription(String desc)
      Sets the quest description string.
      Parameters:
      desc - Quest description string.
    • setSlotName

      public void setSlotName(String slotName)
      Sets the quest identifier string.
      Parameters:
      slotName - Slot identifier string to be returned when getSlotName() is called.
    • setMinLevel

      public void setMinLevel(Integer minLevel)
      Sets the recommended minimum level.
      Parameters:
      minLevel - Level to return when getMinLevel() is called.
    • setRegion

      public void setRegion(String region)
      Sets the quest region.
      Parameters:
      region - Region string to be returned when getRegion() is called.
    • setNPCName

      public void setNPCName(String npcName)
      Sets the NPC name.
      Parameters:
      npcName - NPC name to return when getNPCName() is called.
    • setVisibleOnQuestStatus

      public void setVisibleOnQuestStatus(boolean visible)
      Sets whether or not the quest should be shown in the travel log.
      Parameters:
      visible - If `true`, quest will be displayed in travel log.
    • setRepeatable

      public void setRepeatable(boolean repeatable)
      Sets the repeatable status of the quest. (overrides setCompletedCheckFunction)
      Parameters:
      repeatable - If `true`, the quest is repeatable.
    • setAddFunction

      @Deprecated public void setAddFunction(org.luaj.vm2.LuaFunction func)
      Deprecated.
      Set LuaQuest.init directly.
      Sets the function for adding the quest to the game.
      Parameters:
      func - Function to invoke when addToWorld() is called.
    • setRemoveFunction

      @Deprecated public void setRemoveFunction(org.luaj.vm2.LuaFunction func)
      Deprecated.
      Set LuaQuest.remove directly.
      Sets the function for removing the quest from the game.
      Parameters:
      func - Function to invoke when removeFromWorld() is called.
    • setHistoryFunction

      public void setHistoryFunction(org.luaj.vm2.LuaFunction history)
      Sets the function for retrieving history of quest state.
      Parameters:
      history - Function to invoke when getHistory() is called.
    • setFormattedHistoryFunction

      public void setFormattedHistoryFunction(org.luaj.vm2.LuaFunction formattedHistory)
      Sets the function for retrieving formatted history of quest state.
      Parameters:
      formattedHistory - Function to invoke when getFormattedHistory() is called.
    • setStartedCheckFunction

      public void setStartedCheckFunction(org.luaj.vm2.LuaFunction startedCheck)
      Sets the function for checking if the quest is started.
      Parameters:
      startedCheck - Function to invoke when isStarted() is called.
    • setRepeatableCheckFunction

      public void setRepeatableCheckFunction(org.luaj.vm2.LuaFunction repeatableCheck)
      Sets the function for checking if the quest is repeatable.
      Parameters:
      repeatableCheck - Function to invoke when isRepeatable() is called.
    • setCompletedCheckFunction

      public void setCompletedCheckFunction(org.luaj.vm2.LuaFunction completedCheck)
      Sets the function for checking if the quest is completed.
      Parameters:
      completedCheck - Function to invoke when isCompleted() is called.