Documentation › Lua

Player

The Player module reads your character's data: HP, mana, level, skills, states, equipment and party. The values come from the packets the server sends; before the first packet, most of them return 0.

Identity#

Player.getId()#

Player.getId() → number

Your creature id. Returns 0 when not in game.

lua
print(Player.getId())

Player.getName()#

Player.getName() → text or nil

Character name. Returns nil when not in game.

lua
print("Logged in as " .. (Player.getName() or "?"))

Player.getVocation()#

Player.getVocation() → number (extra)

Vocation, as in Enums.Vocations. Returns 0 until the server sends the character's basic data.

lua
if Player.getVocation() == Enums.Vocations.ELITE_KNIGHT then print("EK") end

Player.isPremium()#

Player.isPremium() → boolean

Whether the account is premium. Returns false until the basic data arrives.

lua
print(Player.isPremium())

Player.hasReceivedBasicData()#

Player.hasReceivedBasicData() → boolean

Whether the server has already sent the basic data (vocation, premium). Use it before reading getVocation and isPremium.

lua
if Player.hasReceivedBasicData() then print(Player.getVocation()) end

HP, mana and status#

Player.getHealth() and Player.getMaxHealth()#

Player.getHealth() → number · Player.getMaxHealth() → number (extra)

Current and max HP.

lua
print(Player.getHealth() .. "/" .. Player.getMaxHealth())

Player.getMana() and Player.getMaxMana()#

Player.getMana() → number · Player.getMaxMana() → number (extra)

Current and max mana.

lua
print(Player.getMana() .. "/" .. Player.getMaxMana())

Player.getHealthPercent() and Player.getManaPercent()#

Player.getHealthPercent() → number · Player.getManaPercent() → number

HP and mana in percent (0 to 100).

lua
if Player.getHealthPercent() < 40 then Game.talk("exura vita") end

Player.getMagicShield() and Player.getMaxMagicShield()#

Player.getMagicShield() → number · Player.getMaxMagicShield() → number

Current and max points of the magic shield (utamo vita and magic shield potion).

lua
print(Player.getMagicShield())

Player.getCapacity()#

Player.getCapacity() → number

Free cap as the server sends it, in hundredths of an oz. Divide by 100 to get oz.

lua
local oz = Player.getCapacity() / 100
if oz < 100 then Client.showMessage("Low cap: " .. oz .. " oz") end

Player.getSoulPoints()#

Player.getSoulPoints() → number

Soul points.

lua
print(Player.getSoulPoints())

Player.getStamina()#

Player.getStamina() → number

Stamina as the server sends it (in minutes). 0 until the status packet arrives.

lua
if Player.getStamina() < 14 * 60 then print("orange stamina") end

Player.isHungry()#

Player.isHungry() → boolean

true when food regeneration has run out.

lua
if Player.isHungry() then Game.useItem(3725) end -- 3725 = brown mushroom

Player.getSpeed()#

Player.getSpeed() → number (extra)

Current speed.

lua
print(Player.getSpeed())

Level and experience#

Player.getLevel()#

Player.getLevel() → number

Current level.

lua
print(Player.getLevel())

Player.getLevelPercent()#

Player.getLevelPercent() → number

Percent to the next level.

lua
print(Player.getLevelPercent() .. "%")

Player.getExperience()#

Player.getExperience() → number

Total experience.

lua
print(Player.getExperience())

Player.getXpBoostTime()#

Player.getXpBoostTime() → number

Seconds left of the store XP boost.

lua
print(math.floor(Player.getXpBoostTime() / 60) .. " min of boost")

Skills#

Player.getSkills()#

Player.getSkills() → table

Skills, magic level and bonuses. Each skill comes with its level and percent (<skill>Percent).

FieldDescription
fist, club, sword, axe, distance, shield, fishingSkill level (and fistPercent, clubPercent...)
magic, magicPercentMagic level and percent
criticalChance, criticalDamageCritical, in percent
lifeLeechDamage, manaLeechDamageLeech, in percent
lifeLeechChance, manaLeechChance100 when you have leech, otherwise 0
onslaughtOnslaught, in percent
lua
local s = Player.getSkills()
print("ML " .. s.magic .. " (" .. s.magicPercent .. "%)")

Position and state#

Player.getPosition()#

Player.getPosition() → {x, y, z} (extra)

Your position.

lua
local p = Player.getPosition()
print(p.x, p.y, p.z)

Player.isInPz()#

Player.isInPz() → boolean (extra)

Whether you are in a protection zone.

lua
if Player.isInPz() then print("in PZ") end

Player.isInCombat()#

Player.isInCombat() → boolean (extra)

Whether you are in combat.

lua
if not Player.isInCombat() then Game.talk("utani hur") end

Player.getState(state)#

Player.getState(state) → boolean or nil

Whether you have a state (condition icon).

ParameterTypeDescription
statenumberA value of Enums.States (0 to 27)

Returns true or false, or nil for a number outside 0 to 27.

lua
if Player.getState(Enums.States.STATE_PARALYZE) then Game.talk("exura ico") end

Player.getTargetId()#

Player.getTargetId() → number

Id of the creature you are attacking. Returns 0 with no target.

lua
local id = Player.getTargetId()
if id ~= 0 then print(Creature.new(id):getName()) end

Player.getFollowId()#

Player.getFollowId() → number

Id of the last creature the client was told to follow (0 = none).

lua
print(Player.getFollowId())

Equipment and containers#

Player.getInventorySlot(slot)#

Player.getInventorySlot(slot) → table or nil

The item in an equipment slot.

ParameterTypeDescription
slotnumberEnums.InventorySlot (1 to 10)

Returns {id, count, tier, holdingCount} or nil when the slot is empty. tier is always 0. holdingCount is how many of this item you have in total (equipment and open containers).

lua
local ammo = Player.getInventorySlot(Enums.InventorySlot.CONST_SLOT_AMMO)
if ammo then print("arrows: " .. ammo.count) end

Player.getContainers()#

Player.getContainers() → list or nil

Indexes of the open containers, in order. Returns nil when none is open.

lua
for _, i in ipairs(Player.getContainers() or {}) do
  print(i, Container.new(i):getName())
end

Protection and skull#

Player.getBlessingState()#

Player.getBlessingState() → number

Blessing state, as in Enums.BlessingState: -1 unknown, 0 none, 1 some, 2 all (7 or more).

lua
if Player.getBlessingState() ~= Enums.BlessingState.FULL then print("no bless!") end

Player.getUnjustifiedData()#

Player.getUnjustifiedData() → table

Unjustified frags: dayProgress, dayLeft, weekProgress, weekLeft, monthProgress, monthLeft and skullDuration. All 0 until the server sends them.

lua
print("frags today: " .. Player.getUnjustifiedData().dayProgress)

Coins and points#

Balances#

All return a number, 0 until the server sends the value.

FunctionWhat it returns
Player.getTotalGoldBalance()Total gold the server reports
Player.getDusts() / Player.getDustsMaximum()Forge dust and the limit
Player.getHuntingPoints()Hunting task points
Player.getPreyWildcards()Prey wildcards
Player.getBountyPoints()Task board points
Player.getSoulSeals()Soul seals
lua
print("gold: " .. Player.getTotalGoldBalance())

Player.getHuntingTaskPrices()#

Player.getHuntingTaskPrices() → table

Hunting task prices: rerollPrice, cancelPrice, selectionListPrice, rewardRerollPrice. On 15.20 or newer servers these prices come with the task board and stay 0 here.

lua
print(Player.getHuntingTaskPrices().rerollPrice)

Monk#

Player.getHarmony(), Player.isSerene() and Player.getMonkPassiveType()#

Player.getHarmony() → number · Player.isSerene() → boolean · Player.getMonkPassiveType() → number

The monk's harmony, serene state and passive virtue (Enums.MonkPassiveType). 0/false until the server sends them.

lua
print("harmony: " .. Player.getHarmony())

Player.getStances()#

Player.getStances() → list

Active stances. Today it always returns an empty list.

lua
print(#Player.getStances())

Party#

Player.inviteParty(id), Player.joinParty(id) and Player.passLeadershipParty(id)#

Player.inviteParty(playerId) · Player.joinParty(playerId) · Player.passLeadershipParty(playerId)

Invites a player, accepts a leader's invite and passes the leadership.

ParameterTypeDescription
playerIdnumberThe player's creature id
lua
local friend = Map.getPlayerOnScreen("Friend Name")
if friend then Player.inviteParty(friend:getId()) end

Player.enableSharedExpParty(enable)#

Player.enableSharedExpParty(enable)

Turns the party's shared experience on (true) or off (false).

lua
Player.enableSharedExpParty(true)

Player.leaveParty()#

Player.leaveParty()

Leaves the party.

lua
Player.leaveParty()