OSRS Plugin API
    Preparing search index...

    Class Npc

    Lua class representing a runtime NPC.

    Implements

    Index

    Constructors

    Methods

    • Returns the name of the entity.

      Returns string

      Returns the name of the entity as a string.

      npcs = osrs.ClientOp.getNpcIdAll()
      for index, npc_id in pairs(npcs) do
      npc = osrs.ClientOp.getNpcObj(npc_id)
      osrs.print(npc:getName())
      end
    • Returns the type of the npc.

      Returns number

      Returns the category number of the npc.

      npcs = osrs.ClientOp.getNpcIdAll()
      for index, npc_id in pairs(npcs) do
      npc = osrs.ClientOp.getNpcObj(npc_id)
      if npc:getType() == 1540 then
      osrs.print("I am a thrall!")
      end
      end
    • Gets the data type of the current runtime NPC.

      Returns NpcType

    • Returns if the entity is dead.

      Returns boolean

      Returns true if the entity is dead, false if not.

      local players = osrs.ClientOp.getPlayerIdAll()
      for index, player_id in pairs(players) do
      player = osrs.ClientOp.getPlayerObj(player_id)
      osrs.printf("player %s isDead=%s", player:getName(), (player:isDead() and "true" or "false") )
      end
    • Returns whether or not the npc is a follower (such as a pet) of any online player.

      Returns boolean

      Returns true if the npc is a follower, false if not.

      npcs = osrs.ClientOp.getNpcIdAll()
      for index, npc_id in pairs(npcs) do
      npc = osrs.ClientOp.getNpcObj(npc_id)
      if npc:isFollower() then
      osrs.print("I am a follower!")
      end
      end
    • Returns if the entity has a headbar that is empty.

      Returns boolean

      Returns true if the entity has a headbar that is empty, false if not.

      npcs = osrs.ClientOp.getNpcIdAll()
      for index, npc_id in pairs(npcs) do
      npc = osrs.ClientOp.getNpcObj(npc_id)
      if npc:isHeadbarEmpty() then
      osrs.printf("npc %d has an empty headbar", npc_id)
      end
      end
    • Returns if the entitys healthbar is rendered.

      Returns boolean

      Returns true if the entitys healthbar is rendered, false if not.

      players = osrs.ClientOp.getPlayerIdAll()
      for index, player_id in pairs(players) do
      player = osrs.ClientOp.getPlayerObj(player_id)
      if player:isHealthbarRendered() then
      osrs.printf("player %d healthbar is rendered!", player_id)
      end
      end
    • Returns the id of the entity that this entity is interacting with, returns -1 if there is none.

      Returns number

      Returns the id of the entity that this entity is interacting with.

      local npcs = osrs.ClientOp.getNpcIdAll()
      for index, npc_id in pairs(npcs) do
      local npc = osrs.ClientOp.getNpcObj(npc_id)
      local target_id = npc:isInteracting()
      if target_id ~= -1 then
      local target = osrs.ClientOp.getNpcObj(target_id)
      osrs.printf("NPC %s is interacting with %s", npc:getName(), target:getName())
      end
      end
    • Returns whether or not the npc is a follower (such as a pet) of the local player.

      Returns boolean

      Returns true if the npc is a follower of the local player, false if not.

      npcs = osrs.ClientOp.getNpcIdAll()
      for index, npc_id in pairs(npcs) do
      npc = osrs.ClientOp.getNpcObj(npc_id)
      if npc:isLocalFollower() then
      osrs.print("I am a follower of the local player!")
      end
      end
    • Returns whether or not the entitys 2D elements are rendered.

      Returns boolean

      Returns true if the the entitys 2D elements are rendered, false if not.

      npcs = osrs.ClientOp.getNpcIdAll()
      for index, npc_id in pairs(npcs) do
      npc = osrs.ClientOp.getNpcObj(npc_id)
      if npc:isRendered2D() == 1540 then
      osrs.printf("NPC %d 2D elements are rendered!", npc_id)
      end
      end
    • Returns whether or not the entitys 3D elements are rendered.

      Returns boolean

      Returns true if the the entitys 3D elements are rendered, false if not.

      players = osrs.ClientOp.getPlayerIdAll()
      for index, player_id in pairs(players) do
      player = osrs.ClientOp.getPlayerObj(player_id)
      if player:isRendered3D() then
      osrs.print("player %d is rendered!", player_id)
      end
      end
    • Changes the rendering of the entitys 2D elements based on the given boolean.

      Parameters

      • shouldRender: boolean

        Boolean that will render 2D elements when true, and does not when false.

      Returns void

      npcs = osrs.ClientOp.getNpcIdAll()
      for index, npc_id in pairs(npcs) do
      npc = osrs.ClientOp.getNpcObj(npc_id)
      -- npcs will no longer have 2D elements rendered
      npc:render2D(false)
      end
    • Changes the rendering of the entitys 3D elements based on the given boolean.

      Parameters

      • shouldRender: boolean

        Boolean that will render 3D elements when true, and does not when false.

      Returns void

      players = osrs.ClientOp.getPlayerIdAll()
      for index, player_id in pairs(players) do
      player = osrs.ClientOp.getPlayerObj(player_id)
      -- all players will no longer be rendered
      player:render3D(false)
      end