summaryrefslogtreecommitdiff
path: root/src/scripting/script.h
AgeCommit message (Collapse)AuthorFilesLines
2013-08-26Moved AttributeInfo into a seperate fileErik Schilling1-1/+1
2013-08-26Allowed to push attributeinfos for the attribute recalculationErik Schilling1-0/+4
While on it I replaced the id usage in the server with the usage of the AttributeInfo directly. Next steps: - Dehardcode the core attribute ids and store their attributeinfos somewhere in AttributeManager (for now i simply wrapped the ids with getAttributeInfo(). - Move AttributeInfo out of AttributeManager to shorten the usage + to allow using a pointer in ModifierLocation without forward declaring it.
2013-04-14Removed NPC and character parameters from NPC functionsThorbjørn Lindeijer1-0/+4
These functions can only be used in the context of a character talking to an NPC, so these parameters can be deduced from that context rather than passing them explicitly all the time. Simplifies NPC scripting.
2013-04-11Converted Being into a ComponentErik Schilling1-2/+1
I did not really care too much about staying consistent with the use of static_casts to Actors since they are only temporary anyway until Actor is a component too.
2013-02-21Introduced Script::ContextErik Schilling1-15/+35
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-18/+4
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-04-04Renamed Thing to EntityThorbjørn Lindeijer1-5/+5
In preparation for using an entity/component system for the entities in the game world, this name will be more recognizable and easier to talk about. Reviewed-by: Yohann Ferreira
2012-03-11Removed the create_npc wrapper and the last two NPC callbacksThorbjørn Lindeijer1-1/+12
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-9/+67
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-03Removed the last direct call to global script functionThorbjørn Lindeijer1-6/+0
The ScriptAction of the TriggerArea (which can be created by mana.trigger_create) was still using a named global function for its callback. Now it also uses a reference to a script function. Since it was the last occurrence of a call to a global script function, I've also removed the Script::prepare(std::string) overload. Reviewed-by: Erik Schilling Mantis-issue: 299
2012-03-03Added further missing callbacksErik Schilling1-0/+9
Reviewed-by: bjorn.
2012-03-02Converted functions called by LuaScript to callbacksThorbjørn Lindeijer1-7/+10
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-4/+29
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-17/+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-4/+8
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/+1
Reviewed-by: Bjorn, Bertram.
2011-04-27Added a simple crafting systemPhilipp Sehmisch1-0/+8
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
2011-03-12Removed a bunch of silly documentationThorbjørn Lindeijer1-6/+0
A C++ developer should be able to recognize a constructor and a destructor by just looking at it, so let's stop writing down the obvious. :)
2010-11-14Renamed .hpp files into .h for consistency.Yohann Ferreira1-0/+170
Also added an header to the autoattack.{h,cpp} files. Big but trivial fix.