summaryrefslogtreecommitdiff
path: root/src/scripting/luautil.cpp
AgeCommit message (Collapse)AuthorFilesLines
2013-01-09Micro-optimizations for pushing strings to LuaThorbjørn Lindeijer1-2/+2
Use lua_pushliteral and lua_pushlstring instead of lua_pushstring, which avoids Lua having to determine the length of the string.
2012-07-21Fixed an error message and inlined some one-linersThorbjørn Lindeijer1-22/+1
2012-07-21Removed raiseScriptErrorThorbjørn Lindeijer1-12/+0
It wasn't really adding anything since errors raised using luaL_error are already logged anyway. Reviewed-by: Erik Schilling
2012-04-04Renamed Thing to EntityThorbjørn Lindeijer1-4/+4
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 Schilling1-7/+16
- 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 Schilling1-0/+12
Reviewed-by: bjorn.
2012-03-10Moved the managing of NPC script coroutines into C++Thorbjørn Lindeijer1-0/+12
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-07Added a function that returns the current map or raises an errorThorbjørn Lindeijer1-0/+25
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-05Improved Lua API argument checkingThorbjørn Lindeijer1-8/+31
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-03Improved handling of item and monster class parametersThorbjørn Lindeijer1-7/+69
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-02-03Added a generic Lua user data cacheThorbjørn Lindeijer1-0/+59
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 Lindeijer1-5/+0
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
2011-10-15Added script bindings for reading map objectsErik Schilling1-0/+5
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-08-19Created function to make getting monsters easier in scripts.Erik Schilling1-0/+11
2010-12-08Fix many compiler warnings.Freeyorp1-2/+2
Reviewed-by: 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-22Some coding style tweaksThorbjørn Lindeijer1-6/+12
2010-05-28Modified the npc_trade() lua function to permit selling the whole player ↵Yohann Ferreira1-1/+12
inventory. It permits to open a sell box with every items in the player inventory as requested by Striker. Also added different return value support to both the buy selling functions, and made fixes where relevant. The test.lua script will be upgraded to show examples in a next commit. What's left to be done is to fix the inventory handling for both selling functions. (Sigh...) Concerns: Manasource mantis: #78, #101. Reviewed-by: Jaxad0127
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-01-22Reduced the size of lua.cpp by putting the class LuaScript and the utility ↵Philipp Sehmisch1-0/+91
functions in separate files leaving only the script bindings themself. Unified internal and external names of lua script bindings.