summaryrefslogtreecommitdiff
path: root/src/scripting
AgeCommit message (Collapse)AuthorFilesLines
2012-04-04Renamed Thing to EntityThorbjørn Lindeijer6-22/+22
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-04-04Enhanced special supportErik Schilling6-46/+162
- Made the current charge being saved. - Added script binds: - chr_set_special_recharge_speed - chr_get_special_recharge_speed - chr_set_special_mana - chr_get_special_mana - get_special_info - Added special info lua class. Functions: - name - needed_mana - rechargeable - on_use - on_recharged - category Further the engine no longer sets charge to 0 after using of specials this allows more flexbilillity (like failing specials). Changes on the xml database: - recharge renamed to rechargeable (needed by client and server) - needed - the needed mana to trigger a special (server only) - rechargespeed - the defailt recharge speed in mana per tick (server only) - target - the type of target (either being or point) (server and client) I also made the lua engine pushing nil instead of a 0 light userdata when the pointer was 0. Database update needed. Change is tested. Mana-Mantis: #167, #156 Reviewed-by: bjorn.
2012-03-17Made skill related function capable of taking the skill name as parameterErik Schilling3-5/+27
Reviewed-by: bjorn.
2012-03-17Added map update function, moved schedules there to keep map contextErik Schilling1-2/+15
Reviewed-by: bjorn.
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-14Added chr_kick() lua bindErik Schilling1-2/+16
Another step towards scriptable @commands. Reviewed-by: bjorn.
2012-03-14Added being_get_mapid lua bindErik Schilling1-2/+18
Another step for being able to make @commands scriptable Reviewed-by: bjorn.
2012-03-14Added get_character_by_name lua bindErik Schilling1-0/+18
Step to be able to handle chatcommands by scripts. Reviewed-by: bjorn.
2012-03-13Added script bind to set walkmask for beingsErik Schilling1-0/+42
TODO: Inform client about this change. Reviewed-by: bjorn.
2012-03-11Removed "mana." from script function documentationThorbjørn Lindeijer1-102/+99
Forgot to do this in the previous commit.
2012-03-11Register Lua script API functions into the global namespaceThorbjørn Lindeijer1-2/+3
Scripts mostly execute the Mana script API, and it seems like just unnecessary verbosity to refer to the 'mana' table all the time. This table no longer exists now. Reviewed-by: Erik Schilling
2012-03-11Removed the create_npc wrapper and the last two NPC callbacksThorbjørn Lindeijer5-40/+54
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-11Added callbacks for map/worldvar changesErik Schilling2-3/+27
Reviewed-by: bjorn.
2012-03-10Moved the managing of NPC script coroutines into C++Thorbjørn Lindeijer7-154/+341
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-07Fixed compileThorbjørn Lindeijer1-1/+1
This was meant to be amended to the previous commit...
2012-03-07Added a function that returns the current map or raises an errorThorbjørn Lindeijer5-136/+80
The new function 'checkCurrentMap' will raise an error when no current map has been set, eliminating the need to do custom error handling all over the place. This also fixes several functions that would otherwise have simply crashed when there was no current map. Also cleaned up some "empty string parameter" checks. Reviewed-by: Erik Schilling
2012-03-05Added lua function for getting pvp status of mapErik Schilling1-0/+13
mana.map_get_pvp() now returns one of the constants in libmana-constants.lua Reviewed-by: Bertram.
2012-03-05Added possibility to make a being attack an other beingErik Schilling1-7/+33
This allows the script to let the character perform a scripted attack but the character still gets xp and killed monsters give drops. You can now call: mana.being_damage(target, dmg, dmg_delta, accurancy, type, element, source, skill) While on it I also added checks to the being_damage function. Reviewed-by: bjorn, Bertram.
2012-03-05Improved Lua API argument checkingThorbjørn Lindeijer3-580/+194
It's a bit embarrassing the way this has gotten out of hand. The error checking was inconsistent, and in some cases wrong. A host of new helper functions, starting with 'check' rather than 'get', perform error handling on function arguments (they will not return when encountering an error). Reviewed-by: Erik Schilling
2012-03-03Removed the last direct call to global script functionThorbjørn Lindeijer4-32/+15
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-03Improved handling of item and monster class parametersThorbjørn Lindeijer3-163/+108
Item and monster classes could already be identified by either their id or their name. Now the explicit values returned by 'get_item_class' and 'get_monster_class' can also be used as parameter. In addition the above two getters learned to understand all three types of parameter as well, rather than only supporting a name. Reviewed-by: Erik Schilling
2012-03-03Use callbacks for items, monsters and status effectsThorbjørn Lindeijer2-37/+97
Previously, global function names were defined in the respective XML definitions of items, monsters and status effects. This was reasonable when they all had the same state, but now they're sharing the single global Lua state. Now the Lua API provides access to the ItemClass, MonsterClass and StatusEffect instances, on which callbacks for both standard and custom events can be explicitly set. Reviewed-by: Erik Schilling
2012-03-03Added further missing callbacksErik Schilling5-6/+154
Reviewed-by: bjorn.
2012-03-02Converted functions called by LuaScript to callbacksThorbjørn Lindeijer5-46/+108
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 Lindeijer7-22/+81
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-02Simplified some of the Lua backendThorbjørn Lindeijer2-70/+30
Mainly introduced a helper function for getting to the Script instance for the current Lua state. Reviewed-by: Erik Schilling Reviewed-by: Yohann Ferreira
2012-03-02Merged all the different Lua states into oneThorbjørn Lindeijer4-107/+168
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
2012-02-03Added a generic Lua user data cacheThorbjørn Lindeijer3-9/+106
Based on a native Lua table with weak values, so that the user data objects that are created can be garbage collected when no longer referenced. Reviewed-by: Yohann Ferreira
2012-01-31Use a full user data object for MapObject referencesThorbjørn Lindeijer3-53/+84
Based on a templated helper class, MapObject references in Lua scripts are now full user data objects. Using the '__index' member of their metatable, a library is associated with it so that member functions can be called directly on the object. Reviewed-by: Yohann Ferreira Reviewed-by: Erik Schilling
2012-01-30Fixed some lua_newtable/createtable usageThorbjørn Lindeijer2-5/+5
When creating a Lua table, it is possible to specify in advance how many array elements and how many non-array elements this table will contain, to avoid dynamic reallocations while filling the table. This wasn't used optimally by the pushSTLContainer helper methods and some other cases. Reviewed-by: Erik Schilling Reviewed-by: Yohann Ferreira
2012-01-25Fixed use of checkstring method in the script functionsErik Schilling1-4/+7
luaL_checkstring might not return so the destructor of string will not be called. Reviewed-by: Bjorn.
2012-01-22Added announce(text [, sender]) lua functionErik Schilling1-4/+18
The function will cause a global announcement. If no sender ist set "Server" will be used. Reviewed-by: Bjorn.
2012-01-18Added the chr_get_inventory and chr_get_equipment functions.Yohann Ferreira1-0/+137
Those will make the scripters able to get a full view of the current player's possessions. Use with care. + Fixes following Ablu's review. Resolves: Mana-Mantis #207. Reviewed-by: Ablu
2012-01-18Fixed the chr_inv_count function to handle equipment.Yohann Ferreira1-6/+11
the function can now count in the inventory and/or the player's equipment. I also fixed the script function and added a use case in the example map. + Fixes after Ablu's review. + 2nd fix after Ablu's review: Fix the inventory remove behaviour. Resolves: Mana-Mantis #288 Reviewed-by: Ablu
2012-01-16Made the lua item_drop script function returns whether it succeeded.Yohann Ferreira1-4/+4
Part of Mana-Mantis #339. Reviewed-by: Ablu
2012-01-16Added several script warnings on errors.Yohann Ferreira1-7/+10
As requested by Ablu. Reviewed-by: Ablu.
2012-01-10Random small fixes linked to lua c++ scripting functions.Yohann Ferreira1-10/+39
Reviewed-by: Ablu
2012-01-10Added unequip lua script functions.Yohann Ferreira1-0/+65
You can unequip using the slot or an item id. + Fixes from Ablu's review. Resolves: Mana-Mantis #350. Reviewed-by: Ablu.
2012-01-10Added equip lua script functions.Yohann Ferreira1-0/+71
One per inventory slot, one per item id or name. + Fixes from 2 Ablu's reviews. Reviewed-by: Ablu. 1st part of Mana-Mantis #339, 350.
2012-01-02Made all beings capable of having a genderErik Schilling1-17/+21
Reviewed-by: o11c, bjorn, Bertram.
2011-11-07Merged three global script states into oneThorbjørn Lindeijer4-59/+29
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-11-01Merge github.com:mana/manaservYohann Ferreira3-1/+20
Conflicts: src/game-server/character.cpp src/scripting/lua.cpp
2011-10-23Added function to determine the script engine by the file name extensionjurkan2-0/+19
Reviewed-by: Bjorn, Bertram.
2011-10-22Fixed the get_level doxygen documentation.Yohann Ferreira1-1/+1
Thanks to Ablu.
2011-10-22Added the chr_get_level script function.Yohann Ferreira1-0/+18
Reviewed-by: Ablu.
2011-10-22Added the chr_set_gender() script function.Yohann Ferreira1-0/+20
Reviewed-by: Ablu.
2011-10-19Merge branch 'master' of github.com:mana/manaservYohann Ferreira3-4/+156
Conflicts: src/game-server/accountconnection.cpp
2011-10-19Made get_beings_in_circle capable of taking a being as argument.Erik Schilling1-3/+16
Instead of giving the x, y coordinates of the circle you can give a being which is in the center of the circle.
2011-10-15Added script bindings for reading map objectsErik Schilling3-1/+140
map_get_objects([string filter]): returns all object of the current map optionally filtered by type. map_get_object_property(handle object, string key): returns the value of the property of the object. map_get_object_bounds(handle object): returns x, y, width, height of an object. map_get_object_name(handle object): returns name of an object. map_get_object_type(handle object): returns type of an object. Mantis-issue: 397 Reviewed-by: Thorbjørn Lindeijer
2011-09-28Added the chr_set_gender() script function.Yohann Ferreira1-0/+20