Scripting

Events are unique, unlike the other interfaces where you have the event in its own script. Each function in the events folder is executed only once.

Monster

Monster:onDropLoot(corpse)

Parameters:

  • self: Monster who has died and is now dropping loot.

  • corpse: Container containing the corpse dropped by the monster.

Return Value:

  • None

Creature

Creature:onChangeOutfit(outfit)

Parameters:

  • self: Creature that is changing their outfit.

  • outfit: Outfit table.

  • lookType

    lookTypeEx

    lookHead

    lookBody

    lookLegs

    lookFeet

    lookAddons

    lookMount

Return Value:

  • true: Creature will change outfit.

  • false: Creature will not be allowed to change outfit.

Creature:onAreaCombat(tile, isAggressive)

Parameters:

  • self: Creature targeting the tile.

  • tile: Tile being targeted.

  • isAggressive: True/false depending on if the combat is aggressive or not.

Return Value:

  • ReturnValue Enum type (seen Here)

Creature:onTargetCombat(target)

Parameters:

  • self: Creature who's targeting.

  • target: Target chosen by the creature.

Return Value:

  • ReturnValue Enum type (seen Here)

Party

Party:onJoin(player)

Parameters:

  • self: Party userdata.

  • player: Player attempting to join the party.

Return Value:

  • true: Player will be allowed to join the party.

  • false: Player will not be allowed to join the party.

Party:onLeave(player)

Parameters:

  • self: Party userdata.

  • player: Player attempting to leave the party.

Return Value:

  • true: Player will be allowed to leave the party.

  • false: Player will not be allowed to leave the party.

Party:onDisband()

Parameters:

  • self: Party userdata.

Return Value:

  • true: Party will be disbanded.

  • false: Party will not be disbanded.

Party:onShareExperience(exp)

Parameters:

  • self: Party userdata.

  • exp: Base experience.

Return Value:

  • New calculated experience distributed across all party members.

Player

Player:onBrowseField(position)

Parameters:

  • self: Player attempting to browse field.

  • position: Position where the player is attempting to browse field at.

Return Value:

  • true: Player will be able to browse field.

  • false: Player will be unable to browse field.

Player:onLook(thing, position, distance)

Parameters:

  • self: Player who is looking at the thing.

  • thing: Thing the player is looking at (Creature / Item)

  • position: Position where the player is looking at.

  • distance: Distance from the player and the thing.

Return Value:

  • None.

Player:onLookInBattleList(creature, distance)

Parameters:

  • self: Player looking at the creature.

  • creature: Creature being looked at.

  • distance: Distance in sqm from the player and creature.

Return Value:

  • None.

Player:onLookInTrade(partner, item, distance)

Parameters:

  • self: Player who is looking at an item in trade.

  • partner: Trade partner of the player looking at the item (owner of the item).

  • item: Item being looked at.

  • distance: Distance in sqm from the player and the item being looked at.

Return Value:

  • None.

Player:onLookInShop(itemType, count)

Parameters:

  • self: Player looking at the item.

  • itemType: Item Type of the item being looked at.

  • count: Item count.

Return Value:

  • true: Item description will be sent to the player.

  • false: Item description will not be sent.

Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)

Parameters:

  • self: Player attempting moving the item.

  • item: Item being moved.

  • count: Item count.

  • fromPosition: Position where the item is being moved from.

  • toPosition: Position where the player is attempting to move the item to.

  • fromCylinder: Cylinder where the item belongs to.

  • toCylinder: Cylinder where the player is attempting to move the item to.

Return Value:

  • true: Item will be moved.

  • false: Item will not be moved.

Player:onItemMoved(item, count, fromPosition, toPosition, fromCylinder, toCylinder)

Parameters:

  • self: Player that moved the item.

  • item: Item that was moved.

  • count: Item count.

  • fromPosition: Position the item was at before it was moved.

  • toPosition: Position the item is being moved to.

  • fromCylinder: Cylinder the item belonged to before it was moved.

  • toCylinder: Cylinder the item was moved to.

Return Value:

  • None.

Player:onMoveCreature(creature, fromPosition, toPosition)

Parameters:

  • self: Player moving the creature.

  • creature: Creature being moved by the player.

  • fromPosition: Position where the creature is currently standing.

  • toPosition: Position where the player is attempting to move the creature.

Return Value:

  • true: Creature will be moved.

  • false: Creature will not be moved.

Player:onReportRuleViolation(targetName, reportType, reportReason, comment, translation)

Parameters:

  • self: Player who is reporting target / targetName.

  • targetName: Player being reported.

  • reportType: ID for the report type (List of IDs found Here).

  • reportReason: Report reason selected from the report window.

  • comment: Details given by the player.

  • translation: Translation of the comment.

Return Value:

  • None.

Player:onReportBug(message, position, category)

Parameters:

  • self: Player reporting the bug.

  • message: Description of the bug.

  • position: Position where the bug is being reported from (only valid for BUG_CATEGORY_MAP).

  • category: Bug category / type (List of categories found Here)

Return Value:

  • None.

Player:onTurn(direction)

Parameters:

  • self: Player attempting to turn.

  • direction: Direction which the player is attempting to turn to (Direction list found Here).

Return Value:

  • true: Player will be able to turn.

  • false: Player will be unable to turn.

Player:onTradeRequest(target, item)

Parameters:

  • self: Player who initialized the trade request.

  • target: Target for the trade request.

  • item: Player's item offer.

Return Value:

  • true: Trade will be initialized and request will be send to the target.

  • false: Trade will not be initialized.

Player:onTradeAccept(target, item, targetItem)

Parameters:

  • self: Player who initialized the trade.

  • target: Target user for the trade.

  • item: Player's item being transferred.

  • targetItem: Target's item being transferred.

Return Value:

  • true: Trade will go through.

  • false: Trade will not be accepted.

Player:onGainExperience(source, exp, rawExp)

Parameters:

  • self: Player gaining experience.

  • source: Source of the experience gain, can be nil (through Player:addExperience).

  • exp: Base experience being gained, meant to be modified and returned.

  • rawExp: Raw experience, copy of exp, meant to be left unmodified.

Return Value:

  • Modified experience value.

Player:onLoseExperience(exp)

Parameters:

  • self: Player losing experience.

  • exp: Total experience being lost.

Return Value:

  • Modified experience value.

Player:onGainSkillTries(skill, tries)

Parameters:

  • self: Player gaining the skill tries.

  • skill: Skill ID that the tries is being applied to (Skill IDs found Here)

  • tries: Number of skill tries being applied.

Return Value:

  • Modified skill try amount.

Last updated