summaryrefslogtreecommitdiff
path: root/example/scripts/global_events.lua
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-02-26 23:28:43 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-03-02 18:12:17 +0100
commita36e231883d595bcba91d44e19f24b31eaf0431b (patch)
tree879aad2008eb3675153bb9912c4cc724253f87c6 /example/scripts/global_events.lua
parent34ac0d64e23f2b2d3981dbb0ea72157f334805dd (diff)
downloadmanaserv-a36e231883d595bcba91d44e19f24b31eaf0431b.tar.gz
manaserv-a36e231883d595bcba91d44e19f24b31eaf0431b.tar.bz2
manaserv-a36e231883d595bcba91d44e19f24b31eaf0431b.tar.xz
manaserv-a36e231883d595bcba91d44e19f24b31eaf0431b.zip
A bunch of cleanups to example Lua scripts
Mostly removed bulky copyright headers and fixed indentation and line length. Reviewed-by: Yohann Ferreira Reviewed-by: Erik Schilling
Diffstat (limited to 'example/scripts/global_events.lua')
-rw-r--r--example/scripts/global_events.lua79
1 files changed, 36 insertions, 43 deletions
diff --git a/example/scripts/global_events.lua b/example/scripts/global_events.lua
index 548351a8..fe4175be 100644
--- a/example/scripts/global_events.lua
+++ b/example/scripts/global_events.lua
@@ -1,47 +1,43 @@
--------------------------------------------------------------
--- Global event script file --
--- --
--- This file allows you to modify how certain events which --
--- happen frequently in the game on different maps are --
--- supposed to be handled. It is a collection of script --
--- functions which are always called when certain events --
--- happen, regardless on which map. Script execution is --
--- done in the context of the map the event happens on. --
-----------------------------------------------------------------------------------
--- Copyright 2010 Manasource Development Team --
--- --
--- This file is part of Manasource. --
--- --
--- Manasource is free software; you can redistribute it and/or modify it --
--- under the terms of the GNU General Public License as published by the Free --
--- Software Foundation; either version 2 of the License, or any later version. --
-----------------------------------------------------------------------------------
+--[[
+
+ Global event script file
+
+ This file allows you to modify how certain events which happen frequently in
+ the game on different maps are supposed to be handled. It is a collection of
+ script functions which are always called when certain events happen,
+ regardless on which map. Script execution is done in the context of the map
+ the event happens on.
+
+--]]
-- This function is called when the hit points of a character reach zero.
function on_chr_death(ch)
- mana.being_say(ch, "Noooooo!!!")
+ mana.being_say(ch, "Noooooo!!!")
end
--- This function is called when the player clicks on the �OK� button after
--- the death message appeared. It should be used to implement the respawn
+-- This function is called when the player clicks on the OK button after the
+-- death message appeared. It should be used to implement the respawn
-- mechanic (for example: warp the character to the respawn location and
-- bring HP above zero in some way)
function on_chr_death_accept(ch)
- mana.being_heal(ch) -- restores to full hp
- -- mana.being_heal(ch, 1) --restores 1 hp (in case you want to be less nice)
- mana.chr_warp(ch, 1, 815, 100) --warp the character to the respawn location
+ -- restores to full hp
+ mana.being_heal(ch)
+ -- restores 1 hp (in case you want to be less nice)
+ -- mana.being_heal(ch, 1)
+ -- warp the character to the respawn location
+ mana.chr_warp(ch, 1, 815, 100)
end
-- This function is called after chr_death_accept. The difference is that
-- it is called in the context of the map the character is spawned on after
-- the respawn logic has happened.
function on_chr_respawn(ch)
- -- calls the local_respawn_function of the map the character respawned
- -- on when the script of the map has one
- if local_respawn_function ~= nil then
- local_respawn_function(ch)
- end
+ -- calls the local_respawn_function of the map the character respawned
+ -- on when the script of the map has one
+ if local_respawn_function ~= nil then
+ local_respawn_function(ch)
+ end
end
@@ -49,30 +45,27 @@ end
-- first time. This can, for example, be used to give starting equipment
-- to the character and/or initialize a tutorial quest.
function on_chr_birth(ch)
- -- this message is shown on first login.
- mana.chat_message(0, ch, "And so your adventure begins...")
+ -- this message is shown on first login.
+ mana.chat_message(0, ch, "And so your adventure begins...")
end
-- This function is called when a character logs into the game. This can,
-- for example, be utilized for a message-of-the-day or for various
-- handlings of offline processing mechanics.
function on_chr_login(ch)
- mana.chat_message(0, ch, "Welcome to Manasource")
+ mana.chat_message(0, ch, "Welcome to Manasource")
end
-- This function is called when a character is disconnected. This could
-- be useful for various handling of offline processing mechanics.
function on_chr_logout(ch)
- -- notifies nearby players of logout
- local around = mana.get_beings_in_circle(
- posX(ch),
- posY(ch),
- 1000)
- local msg = mana.being_get_name(ch).." left the game."
- for b in pairs(around) do
- if mana.being_type(b) == TYPE_CHARACTER then
- mana.chat_message(0, b, msg)
- end
- end
+ -- notifies nearby players of logout
+ local around = mana.get_beings_in_circle(posX(ch), posY(ch), 1000)
+ local msg = mana.being_get_name(ch).." left the game."
+ for b in pairs(around) do
+ if mana.being_type(b) == TYPE_CHARACTER then
+ mana.chat_message(0, b, msg)
+ end
+ end
end