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.
print(Player.getId())Player.getName()#
Player.getName() → text or nil
Character name. Returns nil when not in game.
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.
if Player.getVocation() == Enums.Vocations.ELITE_KNIGHT then print("EK") endPlayer.isPremium()#
Player.isPremium() → boolean
Whether the account is premium. Returns false until the basic data arrives.
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.
if Player.hasReceivedBasicData() then print(Player.getVocation()) endHP, mana and status#
Player.getHealth() and Player.getMaxHealth()#
Player.getHealth() → number · Player.getMaxHealth() → number (extra)
Current and max HP.
print(Player.getHealth() .. "/" .. Player.getMaxHealth())Player.getMana() and Player.getMaxMana()#
Player.getMana() → number · Player.getMaxMana() → number (extra)
Current and max mana.
print(Player.getMana() .. "/" .. Player.getMaxMana())Player.getHealthPercent() and Player.getManaPercent()#
Player.getHealthPercent() → number · Player.getManaPercent() → number
HP and mana in percent (0 to 100).
if Player.getHealthPercent() < 40 then Game.talk("exura vita") endPlayer.getMagicShield() and Player.getMaxMagicShield()#
Player.getMagicShield() → number · Player.getMaxMagicShield() → number
Current and max points of the magic shield (utamo vita and magic shield potion).
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.
local oz = Player.getCapacity() / 100
if oz < 100 then Client.showMessage("Low cap: " .. oz .. " oz") endPlayer.getSoulPoints()#
Player.getSoulPoints() → number
Soul points.
print(Player.getSoulPoints())Player.getStamina()#
Player.getStamina() → number
Stamina as the server sends it (in minutes). 0 until the status packet arrives.
if Player.getStamina() < 14 * 60 then print("orange stamina") endPlayer.isHungry()#
Player.isHungry() → boolean
true when food regeneration has run out.
if Player.isHungry() then Game.useItem(3725) end -- 3725 = brown mushroomPlayer.getSpeed()#
Player.getSpeed() → number (extra)
Current speed.
print(Player.getSpeed())Level and experience#
Player.getLevel()#
Player.getLevel() → number
Current level.
print(Player.getLevel())Player.getLevelPercent()#
Player.getLevelPercent() → number
Percent to the next level.
print(Player.getLevelPercent() .. "%")Player.getExperience()#
Player.getExperience() → number
Total experience.
print(Player.getExperience())Player.getXpBoostTime()#
Player.getXpBoostTime() → number
Seconds left of the store XP boost.
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).
| Field | Description |
|---|---|
fist, club, sword, axe, distance, shield, fishing | Skill level (and fistPercent, clubPercent...) |
magic, magicPercent | Magic level and percent |
criticalChance, criticalDamage | Critical, in percent |
lifeLeechDamage, manaLeechDamage | Leech, in percent |
lifeLeechChance, manaLeechChance | 100 when you have leech, otherwise 0 |
onslaught | Onslaught, in percent |
local s = Player.getSkills()
print("ML " .. s.magic .. " (" .. s.magicPercent .. "%)")Position and state#
Player.getPosition()#
Player.getPosition() → {x, y, z} (extra)
Your position.
local p = Player.getPosition()
print(p.x, p.y, p.z)Player.isInPz()#
Player.isInPz() → boolean (extra)
Whether you are in a protection zone.
if Player.isInPz() then print("in PZ") endPlayer.isInCombat()#
Player.isInCombat() → boolean (extra)
Whether you are in combat.
if not Player.isInCombat() then Game.talk("utani hur") endPlayer.getState(state)#
Player.getState(state) → boolean or nil
Whether you have a state (condition icon).
| Parameter | Type | Description |
|---|---|---|
| state | number | A value of Enums.States (0 to 27) |
Returns true or false, or nil for a number outside 0 to 27.
if Player.getState(Enums.States.STATE_PARALYZE) then Game.talk("exura ico") endPlayer.getTargetId()#
Player.getTargetId() → number
Id of the creature you are attacking. Returns 0 with no target.
local id = Player.getTargetId()
if id ~= 0 then print(Creature.new(id):getName()) endPlayer.getFollowId()#
Player.getFollowId() → number
Id of the last creature the client was told to follow (0 = none).
print(Player.getFollowId())Equipment and containers#
Player.getInventorySlot(slot)#
Player.getInventorySlot(slot) → table or nil
The item in an equipment slot.
| Parameter | Type | Description |
|---|---|---|
| slot | number | Enums.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).
local ammo = Player.getInventorySlot(Enums.InventorySlot.CONST_SLOT_AMMO)
if ammo then print("arrows: " .. ammo.count) endPlayer.getContainers()#
Player.getContainers() → list or nil
Indexes of the open containers, in order. Returns nil when none is open.
for _, i in ipairs(Player.getContainers() or {}) do
print(i, Container.new(i):getName())
endProtection and skull#
Player.getBlessingState()#
Player.getBlessingState() → number
Blessing state, as in Enums.BlessingState: -1 unknown, 0 none, 1 some, 2 all (7 or more).
if Player.getBlessingState() ~= Enums.BlessingState.FULL then print("no bless!") endPlayer.getUnjustifiedData()#
Player.getUnjustifiedData() → table
Unjustified frags: dayProgress, dayLeft, weekProgress, weekLeft, monthProgress, monthLeft and skullDuration. All 0 until the server sends them.
print("frags today: " .. Player.getUnjustifiedData().dayProgress)Coins and points#
Balances#
All return a number, 0 until the server sends the value.
| Function | What 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 |
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.
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.
print("harmony: " .. Player.getHarmony())Player.getStances()#
Player.getStances() → list
Active stances. Today it always returns an empty list.
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.
| Parameter | Type | Description |
|---|---|---|
| playerId | number | The player's creature id |
local friend = Map.getPlayerOnScreen("Friend Name")
if friend then Player.inviteParty(friend:getId()) endPlayer.enableSharedExpParty(enable)#
Player.enableSharedExpParty(enable)
Turns the party's shared experience on (true) or off (false).
Player.enableSharedExpParty(true)Player.leaveParty()#
Player.leaveParty()
Leaves the party.
Player.leaveParty()
Comments
to comment.