summaryrefslogtreecommitdiff
path: root/src/scripting/script.cpp
AgeCommit message (Collapse)AuthorFilesLines
2022-08-19Apply C++11 fixitsThorbjørn Lindeijer1-2/+1
modernize-loop-convert modernize-deprecated-headers
2022-08-19Apply C++11 fixitsThorbjørn Lindeijer1-3/+3
modernize-use-auto modernize-use-nullptr modernize-use-override modernize-use-using
2013-04-27Use nullptr instead of NULL everywhereErik Schilling1-2/+2
2013-02-21Introduced Script::ContextErik Schilling1-8/+17
This should allow to finally call functions to lua without having to care about working around situations where a lua call causes a c++ call which needs to call to lua again. Tested against the source of tales repository data.
2013-01-09Replaced EventListener with signals based on libsigc++Thorbjørn Lindeijer1-2/+1
This replaces the rather hard to understand event dispatcher with a probably even harder to understand templated library, but fortunately we can rely on the available documentation. Hopefully it will also help with the readability of our code and with adding additional signals to other classes. Added libsigc++ to README and Travis CI configuration. Reviewed-by: Erik Schilling
2012-03-16Fixed fastRemoveOne when the element isn't foundThorbjørn Lindeijer1-1/+1
For a non-empty vectors that did not contain the element to remove, the loop would go on forever because a size_t can't become smaller than 0. Fixed by simply iterating forwards.
2012-03-11Removed the create_npc wrapper and the last two NPC callbacksThorbjørn Lindeijer1-1/+5
When creating an NPC, you now provide its optional talk and update functions directly rather than them being stored in a table on the Lua side and then called in response to a global callback. Also fixed an issue with a missing gender parameter to the delayed NPC creation callback used by NPCs defined on the map (found by Erik while reviewing this patch). Reviewed-by: Erik Schilling
2012-03-10Moved the managing of NPC script coroutines into C++Thorbjørn Lindeijer1-1/+41
Rather than wrapping NPC functions up in coroutines in the Lua side, they are now managed on the C++ side as "script threads", which are essentially the same thing. The main purpose is that the server can now know whether any of these long running script interactions are still active, which will probably be useful when adding the ability to reload scripts. Reviewed-by: Erik Schilling
2012-03-03Added further missing callbacksErik Schilling1-2/+16
Reviewed-by: bjorn.
2012-03-02Converted functions called by LuaScript to callbacksThorbjørn Lindeijer1-2/+0
This includes the quest reply, post reply, death notification and remove notification. Also, Script::Ref was changed from a typedef to a small class, automating initialization and making the check for validness clearer. Reviewed-by: Erik Schilling
2012-03-02Use callbacks for handling character death and respawnThorbjørn Lindeijer1-0/+2
Rather than relying on the availability of global functions with certain predefined names, the Lua script now calls API functions to set which function should be called on these global events. This mechanism should make it easier to avoid name collisions in the global namespace, which is important now that there is only a single script state. For these global events this was not likely to become a problem, but this solution can also be used for callbacks on specific item or monster types, or even allow setting callbacks on certain instances. Reviewed-by: Erik Schilling Reviewed-by: Yohann Ferreira
2012-03-02Merged all the different Lua states into oneThorbjørn Lindeijer1-90/+0
No more Lua state for each status effect, monster, item effect or map. All scripts are loaded into the same state. This should be more efficient overall and make it easier to implement dynamic reloading of the scripts in the future. Now, this introduces the problem of name collisions between different Lua scripts. For now this is solved by using more specific function names, like 'tick_plague' and 'tick_jump' rather than just 'tick'. The plan is however to get rid of these globals, and register these callbacks from the script, so that they can be local functions without the danger of colliding with other scripts. Reviewed-by: Erik Schilling Reviewed-by: Yohann Ferreira
2011-11-07Merged three global script states into oneThorbjørn Lindeijer1-14/+20
These scripts could trivially share one script state, since the methods called on them from the server are not overlapping. This does leave them open to access each other's global variables, but that's the problem with global variables. The one remaining global script file name is now configurable, so that it may also be set to a script in a different scripting language. The two related script options are: script_mainFile (default: scripts/main.lua) script_defaultEngine (default: lua) - renamed from defaultScriptEngine Reviewed-by: jurkan Reviewed-by: Yohann Ferreira
2011-10-23Added function to determine the script engine by the file name extensionjurkan1-0/+18
Reviewed-by: Bjorn, Bertram.
2011-04-27Added a simple crafting systemPhilipp Sehmisch1-0/+14
A client can craft something using the @craft command. The command needs a list of item names and amounts. The gameserver checks if the character has these items in the inventory and then passes the list together with the character handle to the lua script function on_craft in the script file scripts/crafting.lua. This function can then be used to evaluate if the list is a valid crafting combination and when this is the case take or give items. Implemented two example crafting scripts there, one which enforces exact item order and amount and one which doesn't. Both are disabled per default and one needs to be enabled by uncommenting a line. Also gave the player group permission to use the @craft command in permissions.xml and added two new items (wood and iron) required for the example crafting combination. Resolves: #333 Reviewed-by: bcs86, Bertram
2010-11-14Renamed .hpp files into .h for consistency.Yohann Ferreira1-3/+3
Also added an header to the autoattack.{h,cpp} files. Big but trivial fix.
2010-08-22Pass a script name to Lua for proper reporting of error locationsThorbjørn Lindeijer1-2/+2
Now the Lua file name shows up in the error message and stack traceback, or the map file and object name in case of a script embedded in a map file.
2010-08-22Rename some stuff to conform to naming conventionsThorbjørn Lindeijer1-7/+7
2010-07-23Added a simple sanity check to avoid a gameserver crash at login.Yohann Ferreira1-5/+11
No review asked.
2010-07-09Added LUA script bindings for manipulating the specials available to a ↵Philipp Sehmisch1-0/+30
character. Added script call for getting the cost of a special (recharge only for now) Deleting specials works server-sided but the client isn't informed about it properly. Specials without recharge cost don't appear for the player. Both of these features require an additional netcode message. Reviewed-by: Freeyorp
2010-05-29Only skip the UTF-8 BOM for Lua scriptsThorbjørn Lindeijer1-3/+12
libxml2 should be able to handle files with a BOM fine. Reviewed-by: Bertram
2010-05-16Changed and split up the default location for loading dataThorbjørn Lindeijer1-4/+4
Instead of loading data from a 'data' directory in the current working directory, the server now uses clientDataPath and serverDataPath as specified in the configuration. This removes the need to set up symbolic links in order to merge these two types of data. The default values point to example/clientdata and example/serverdata, where a minimal example world can be developed to make setting up an initial server quick and easy. The XML::Document convenience class was copied over from the client. Also, the ResourceManager is now shared between both servers, since the account client is reading items.xml. Reviewed-by: Jared Adams
2010-04-25Added a Byte Order Mask (BOM) filter to the ResourceManager.Bertram1-1/+2
Reviewed by: Jaxad0127
2010-04-11Implemented global event function call to on_chr_deathPhilipp Sehmisch1-0/+17
Reviewed-by: Jared Adams <Jaxad0127@gmail.com>
2010-04-11Added global lua event script (only on_being_death_accept for now)Philipp Sehmisch1-0/+1
Reviewed-by: Jared Adams <Jaxad0127@gmail.com>
2010-02-07Update Copyright date for Manaserv.Bertram1-1/+1
2009-12-06Fixed name of the project in copyright headersThorbjørn Lindeijer1-7/+6
Also updated the headers to refer to the GPL by URL instead of suggesting to contact the FSF by snail mail, as per the latest GPL usage instructions.
2009-04-26Standardize on the position of the const keywordBjørn Lindeijer1-4/+5
Same as for the client.
2009-01-31Added on_remove callback to lua APIPhilipp Sehmisch1-1/+1
2009-01-17Made script error reports more informative and readablePhilipp Sehmisch1-1/+5
2008-11-16Got rid of CVS/Subversion $Id$ markersBjørn Lindeijer1-2/+0
2008-07-07Implemented death listener for scripting engine.Philipp Sehmisch1-0/+5
2008-05-19Implemented NPC names. Implemented the theoretical possibility to have named ↵Philipp Sehmisch1-1/+2
monsters along the way. Note that the syntax of the LUA functions for creating NPCs has changed.
2007-10-27Made it compile with GCC 4.3Guillaume Melquiond1-0/+1
2007-09-22Cleaned both configuration and resource managers.Guillaume Melquiond1-3/+2
2007-08-20Prevented access to uninitialized engines.Guillaume Melquiond1-5/+8
2007-08-15Added helper functions for loading files and NPCs as scripts. Put Lua ↵Guillaume Melquiond1-1/+24
helpers into a separate library automatically loaded into new contexts.
2007-08-14Made it possible to load scripts from strings instead of files.Guillaume Melquiond1-7/+2
2007-08-09Added new scripting interface and Lua engine.Guillaume Melquiond1-0/+67