📓
TFS Guide
  • Preface
  • Progress
  • Unique TFS Concepts
  • Interface - Actions
    • Registration
    • Scripting
    • Revscriptsys
  • Interface - Chatchannels
    • Registration
    • Scripting
  • Interface - Creaturescripts
    • Registration
    • Scripting
    • Revscriptsys
  • Interface - Events
    • Registration
    • Scripting
  • Interface - Globalevents
    • Registration
    • Scripting
    • Revscriptsys
  • Interface - Monster
    • Registration
    • Scripting
    • Revscriptsys
  • Interface - Movements
    • Registration
    • Scripting
    • Revscriptsys
  • Interface - NPC
    • Registration
    • Scripting
  • Interface - Spells
    • Registration
    • Scripting
  • Interface - Talkactions
    • Registration
    • Scripting
  • Interface - Weapons
    • Registration
    • Scripting
  • Source Editing
    • Creating new events
    • Creating new Lua functions
  • Function Documentation
    • Game
Powered by GitBook
On this page
  • Script Structure
  • Examples

Was this helpful?

  1. Interface - Globalevents

Revscriptsys

Script Structure

Constructor:

  • GlobalEvent(eventName)

  • eventName: Equivalent to the name tag in XML.

Events:

  • onStartup()

  • onShutdown()

  • onTime(time)

  • onThink(interval)

  • onRecord(current, old)

Methods:

  • register(): Finalizes the definition of the global event and registers it.

  • type(eventType):

  • eventType: Equivalent to the type tag in XML.

  • time(executionTime):

  • executionTime: Equivalent to the time tag in XML.

  • interval(executionInterval):

  • executionInterval: Equivalent to the interval tag in XML.

Examples

local annoyPlayers = GlobalEvent("annoy players")
annoyPlayer:interval(100) -- executes onThink every 100 milliseconds

function annoyPlayers.onThink(interval)
    Game.broadcastMessage("...")    
    return true
end

annoyPlayers:register()
local recordEvent = GlobalEvent("new record")
recordEvent:type("record")

function recordEvent.onRecord(current, old)
    Game.broadcastMessage("New player record: " .. current)    
    return true
end

recordEvent:register()
PreviousScriptingNextRegistration

Last updated 5 years ago

Was this helpful?