Class LuaEntityHelper

java.lang.Object
games.stendhal.server.core.scripting.lua.LuaEntityHelper

public class LuaEntityHelper extends Object
Exposes some entity classes & functions to Lua.
  • Field Details

  • Method Details

    • get

      public static LuaEntityHelper get()
      Retrieves the static instance.
      Returns:
      Static EntityHelper instance.
    • create

      public Entity create(org.luaj.vm2.LuaTable lt)
      Creates a new `Entity` instance.
      Parameters:
      lt - Entity definition table.
      Returns:
      New `Entity` instance.
    • getPlayer

      public Player getPlayer(String name)
      Retrieves a logged in Player.
      Parameters:
      name - Name of player.
      Returns:
      Logged in player or `null`.
    • getNPC

      public SpeakerNPC getNPC(String name)
      Retrieves an existing SpeakerNPC.
      Parameters:
      name - Name of NPC.
      Returns:
      SpeakerNPC instance or `null`.
    • getItem

      public Item getItem(String name)
      Retrieves a registered Item.
      Parameters:
      name - Name of the item.
      Returns:
      Item instance or `null` if not a registered item.
    • getStackableItem

      public StackableItem getStackableItem(String name)
      Retrieves a registered StackableItem.
      Parameters:
      name - Name of the item.
      Returns:
      StackableItem instance or `null` if not a registered stackable item.
    • createSpeakerNPC

      @Deprecated public games.stendhal.server.core.scripting.lua.LuaEntityHelper.LuaSpeakerNPC createSpeakerNPC(String name)
      Deprecated.
      Use `LuaEntityHelper.create`.
      Creates a new SpeakerNPC instance.
      Parameters:
      name - Name of new NPC.
      Returns:
      New SpeakerNPC instance.
    • createSilentNPC

      @Deprecated public SilentNPC createSilentNPC()
      Deprecated.
      Use `LuaEntityHelper.create`.
      Creates a new SilentNPC instance.
      Returns:
      New SilentNPC instance.
    • createItemSpawner

      public PassiveEntityRespawnPoint createItemSpawner(String name, int meanTurns, boolean initOnAdded)
      Creates an item spawner.
      Parameters:
      name - Name of item to be spawned.
      meanTurns - Average number of turns for item to respawn.
      initOnAdded - If `true`, sets to full grown and initializes respawn timer when added to zone.
      Returns:
      PassiveEntityRespawnPoint instance.
    • createItemSpawner

      public PassiveEntityRespawnPoint createItemSpawner(String name, int meanTurns)
      Creates an item spawner.
      Parameters:
      name - Name of item to be spawned.
      meanTurns - Average number of turns for item to respawn.
      Returns:
      `PassiveEntityRespawnPoint` instance.
    • setPath

      @Deprecated public void setPath(RPEntity entity, org.luaj.vm2.LuaTable table, Boolean loop)
      Deprecated.
      Use {@link games.stendhal.server.entity.GuidedEntity#setPath(FixedPath).
      Helper function for setting an NPCs path.
      Parameters:
      entity - The NPC instance of which path is being set.
      table - Lua table with list of coordinates representing nodes.
      loop - If `true` entity will restart path upon completion.
    • setPathAndPosition

      @Deprecated public void setPathAndPosition(RPEntity entity, org.luaj.vm2.LuaTable table, Boolean loop)
      Helper function for setting an NPCs path & starting position.
      Parameters:
      entity - The NPC instance whose path is being set.
      table - Lua table with list of coordinates representing nodes.
      loop - If `true` entity will restart path upon completion.
    • createSign

      @Deprecated public Sign createSign()
      Deprecated.
      Use `LuaEntityHelper.create(LuaTable)`.
      Creates a new Sign entity.
      Returns:
      New Sign instance.
    • createSign

      @Deprecated public Sign createSign(boolean visible)
      Deprecated.
      Use `LuaEntityHelper.create(LuaTable)`.
      Creates a new Sign entity.
      Parameters:
      visible - If `false`, sign does not have a visual representation.
      Returns:
      New Sign instance.
    • createShopSign

      @Deprecated public ShopSign createShopSign(String name, String title, String caption, Boolean seller)
      Deprecated.
      Use `LuaEntityHelper.create(LuaTable)`.
      Creates a new ShopSign entity.
      Parameters:
      name - The shop name.
      title - The sign title.
      caption - The caption above the table.
      seller - `true`, if this sign is for items sold by an NPC (defaults to `true` if `null`).
      Returns:
      New ShopSign instance.
    • summonCreature

      public int summonCreature(org.luaj.vm2.LuaTable table)
      Summons a creature into the world.
      Parameters:
      table - Creature attributes.
      Returns:
      0 = success 1 = creature not found 2 = zone not found
    • fixedPath

      public FixedPath fixedPath(org.luaj.vm2.LuaTable table, boolean loop)
      Creates a path for a guided entity.
      Parameters:
      table - List of path coordinates.
      loop - Whether the path should loop.
      Returns:
      Instance of `games.stendhal.server.core.pathfinder.FixedPath`.
    • addKnownChatOptions

      public void addKnownChatOptions(SpeakerNPC npc, org.luaj.vm2.LuaTable keywords)
      Helper function as SpeakerNPC.addKnownChatOptions cannot seem to handle array of LuaString.
      Parameters:
      npc - NPC to which options should be added.
      keywords - Keyword(s) to be added.