OTS Guide
  • Introduction
  • Compiling
    • Compile on Arch
    • Compiling on CentOS
    • Compiling on Debian GNU Linux
    • Compiling on Fedora
    • Compiling on FreeBSD
    • Compiling on Gentoo
    • Compiling on Mac OS X
    • Compiling on Ubuntu
    • Compiling on Windows
    • Compiling on Windows (vcpkg)
  • Running your first OT Server
    • Setting up your first server
    • Connecting to your server
    • Editing your datapack
    • Opening your server to the public
  • TFS documentation
    • TFS 1.4 official release
    • LuaScript Interface
      • Action
      • ChatChannel
      • CreatureEvent
      • GlobalEvents
      • MoveEvent
    • Lua functions
    • Metatables
      • Game
  • Glossary
  • Running your first ubuntu linux OT
Powered by GitBook
On this page
  • What are the languages used
  • TFS scripting interface

Was this helpful?

  1. Running your first OT Server

Editing your datapack

PreviousConnecting to your serverNextOpening your server to the public

Last updated 5 years ago

Was this helpful?

What are the languages used

There are two main languages used when working with TFS: XML and Lua. Depending on your knowledge, you may also want to edit the sources, which would mean you would have to work with C++ as well. XML is a markup language that lets you register Lua scripts and store information, while Lua is used for scripting and interacting with the game world. You can start learning Lua with or .

TFS scripting interface

There are a few main functions that are needed when creating scripts.

The current scripting interfaces are: Actions, Chatchannels, Creaturescripts, Events, Globalevents, Monsters, Movements, Npc, Spells, Talkactions and Weapons.

For scripting purposes, you should use some reference or memorize the main functions used in these interfaces:

Actions:

function onUse(player, item, fromPosition, target, toPosition, isHotkey)

Chatchannels:

function canJoin(player)
function onSpeak(player, type, message)

Creaturescripts:

function onLogin(player)
function onLogout(player)
function onThink(creature, interval)
function onPrepareDeath(creature, killer)
function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified)
function onKill(creature, target)
function onAdvance(player, skill, oldLevel, newLevel)
function onModalWindow(player, modalWindowId, buttonId, choiceId)
function onTextEdit(player, item, text)
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
function onManaChange(creature, attacker, manaChange, origin)
function onExtendedOpcode(player, opcode, buffer)

Globalevents:

function onThink(interval)
function onStartup()
function onShutdown()
function onRecord(current, old)
function onTime()

Monsters:

function onThink(interval)
function onCreatureMove(creature, newTile, newPos, oldTile, oldPos, teleport)
function onCreatureDisappear(creature, isLogout)
function onCreatureAppear(creature, isLogin)
function onCreatureSay(creature, type, text)

Movements:

function onStepIn(creature, item, toPosition, fromPosition)
function onStepOut(creature, item, toPosition, fromPosition)
function onEquip(player, item, slot)
function onDeEquip(player, item, slot)
function onAddItem(moveitem, tileitem, pos)
function onRemoveItem(moveitem, tileitem, pos)

Npc:

function onCreatureAppear(cid)
function onCreatureDisappear(cid)
function onCreatureSay(cid, type, msg)
function onThink()

Spells:

function onCastSpell(creature, variant)

Talkactions:

function onSay(player, words, param)

Weapons:

function onUseWeapon(player, variant)
Programming in Lua
Stigma's Lua guide