Commit graph

98 commits

Author SHA1 Message Date
Celtic Minstrel
87f750e3df Reorganize loading of initial Lua packages
- Now uses the internal (old) require function to load package.lua,
  and the external (new) require function to load other packages.
2017-05-05 13:07:47 -04:00
Celtic Minstrel
2f15a08b78 Add a Lua file for things to be automatically loaded by the engine in all contexts 2017-05-04 20:17:00 -04:00
Celtic Minstrel
cef3e0d266 Add wesnoth.show_message_box function 2017-05-04 20:09:52 -04:00
Celtic Minstrel
a15e6379c2 Lua: Rename wesnoth.map_location -> wesnoth.map
Eventually, game_lua_kernel will add additional stuff to this table.
2017-05-04 19:20:41 -04:00
Celtic Minstrel
072ddc4dc1 Reimplement wesnoth.require function in Lua 2017-05-03 02:40:34 -04:00
Celtic Minstrel
37c0ccafa3 Allow wesnoth.dofile to forward arbitrary arguments to the file's "..." 2017-05-02 22:23:46 -04:00
Celtic Minstrel
efb0fe05e9 Accept [story] as ActionWML 2017-05-02 20:49:10 -04:00
Charles Dang
323516d3d8 Avoid copy initialization of arrays (use direct instead) 2017-04-21 03:10:07 +11:00
Charles Dang
e90d11d02a Renamed namespace 'random' to 'randomness'
This is because GCC 4.x has a problem with symbol name collisions with 'random'
2017-04-21 03:05:52 +11:00
Charles Dang
d8ed11c2b1 Drop the _new suffix from random_new
The 'old' random code has long been removed.
2017-04-20 08:48:47 +11:00
Celtic Minstrel
27b4a8f4ed Some changes to the undocumented location Lua API
- Remove parse_direction and write_direction; instead just always require directions as strings
- Remove zero, as it's pointless - just use {0,0}
- Add vector_diff
2017-03-20 12:00:22 +11:00
Celtic Minstrel
b4dc11ce36 Belated 2017 copyright update 2017-03-19 10:05:38 -04:00
Charles Dang
e22c8967ee Cleaned up global.hpp includes 2016-12-17 15:21:04 +11:00
gfgtdf
283fd32077 remove added widget definitions on lua kernel destruction. 2016-12-07 04:10:11 +01:00
gfgtdf
118d18ec7a add lua add_widget_definition function
http://gna.org/bugs/?25337
2016-12-07 04:10:10 +01:00
Celtic Minstrel
e0614251c4 Rename exception classes to avoid t- prefix 2016-11-09 01:13:17 -05:00
Celtic Minstrel
a9dd8da443 New Lua function to match WML against a filter 2016-11-02 00:11:00 -04:00
Jyrki Vesterinen
e7c2105c48 Add a script to simulate heavy lobby traffic
Plus a bunch of changes which were necessary for the script to work:
* The "simulate lobby activity" plugin now exits when the server is shut
  down.
* The plugin now uses wesnoth.random() for random number generation.
  Math.random() uses a fixed seed, which would make all the clients
  perform the exact same actions.
* Exposed wesnoth.random() to plugins to allow the change above.
* --nogui no longer implies --wconsole on Windows. With implied --wconsole
  the clients attached themselves to the standard output of the Python
  script, which made it impossible to see the output of the script itself.
2016-10-23 16:52:36 +03:00
Celtic Minstrel
205aafc832 Minor improvement to Lua error messages 2016-10-22 10:24:28 -04:00
Chris Beck
e9d72ad7ed partially revert 797613f760
attempts to fix bug reported by tad_carlucci

discussed on #wesnoth-dev 10-19-2016
2016-10-19 20:56:51 -04:00
Celtic Minstrel
200b57e721 Improve Lua console tab completion
(Also some minor code cleanup in another function)

The two main improvements from this commit are:
- Tab completion can now work for any valid variable path, including ones that contain brackets or even ones that are not tables
- Tab completion no longer returns attributes that are not valid identifiers

There's also a new mechanism for userdata to hook into the tab completion using a metafunction.
At present no userdata uses this mechanism, so it is untested.
2016-10-18 23:01:50 -04:00
Celtic Minstrel
09d35947f4 Fix Lua-invoked dialogs not showing before prestart
Instead of passing the video object to the Lua kernel, the game now simply
fetches the video singleton when displaying dialogs. This means there is
no longer any need to store a reference to the video object.
2016-10-18 12:48:15 -04:00
GregoryLundberg
8839a5ee8e Only on gcc
Use #if guard to prevent gcc pragma being seen elsewhere.
2016-10-17 10:34:43 -05:00
Gregory A Lundberg
fb82f6a259 Add Lua utf8 library
Safe for scripting. Let the users have it.
2016-10-17 10:34:42 -05:00
Gregory A Lundberg
8e7b28cde2 Move local changes to proper place
luaconf.h provides a place for us to make changes, avoiding the need to change the original definitions. Move everything down there. This encompases the following changes:

1) Disable compatibility with old versions of Lua in the C++. Compatability is maintained only for the Lua runtime. Only one correction was needed: in application_lua_kernel.cpp

2) Change how the backpointer is defined, for forward compatability with Lua 5.3. This effected only one line: in lua_kernel_base.cpp. Using the Lua 5.3 macro caused a GCC warning, suppressed it for that line.

3) Certain Windows-only features are no longer available in the Lua runtime. These features are all in the Lua io module, which we don't allow access to, so this is a non-change for the runtime.

4) Lua will behave as if it is a standard C environment. This, again, mainly effects the Windows environment and features we don't allow access to in the runtime.
2016-10-17 10:34:41 -05:00
Chris Beck
4dea265113 add code comments and minor fixups in lua_kernel_base
adds code comments for a number of method declarations in header,
and in the implementation file, prefixes many method calls with
`this->`. This convention disambiguates whether the call is a method
of the class or a function at global scope. On some projects like
gcc, it is part of the coding standard to do this to avoid subtle
bugs -- I have come to believe that it makes your code more easily
readable, even if it is a little more typing.
2016-10-07 19:35:02 -04:00
Chris Beck
d82d8c9137 fixup previous commit: don't compare std::function with nullptr 2016-10-07 19:15:03 -04:00
Jyrki Vesterinen
c2d3607d49 Restrict preference access to plugins
@gfgtdf pointed out that preferences contain MP passwords. We can't allow
untrusted code to access them. Since we only need preference access from
plugins for now, the simplest way to avoid security issues is to block Lua
code outside of plugins from accessing preferences at all.
2016-09-24 18:16:55 +03:00
Jyrki Vesterinen
76d407e733 Expose preferences to Lua 2016-09-24 18:16:41 +03:00
Celtic Minstrel
144ce315c3 Lua GUI2: Support stacked widgets and unit preview pane, and add show_menu function 2016-08-28 00:24:19 -04:00
Celtic Minstrel
30b7ab8b2d Reduce use of const_cast 2016-08-20 20:38:46 -04:00
Celtic Minstrel
4dd99b881f Implement Lua placement new 2016-08-20 20:38:46 -04:00
Celtic Minstrel
797613f760 Refactor some duplicate code in Lua API 2016-08-20 20:38:46 -04:00
Charles Dang
24577e117d Merge pull request #716 from wesnoth/boost_trimming
Boost-related cleanups
2016-07-30 15:51:30 +11:00
Charles Dang
d778db8af6 Convert uses of boost integer types to their stdlib equivalents 2016-07-29 23:18:10 -04:00
gfgtdf
6f021631e1 replace some std::bind with lambdas 2016-07-29 14:36:22 +02:00
Charles Dang
05092ba2f6 Refactor most boost pointer related stuff to use their stdlib counterparts
This constitutes drop-in replacements for:

* boost::shared_ptr
* boost::scoped_ptr
* boost::weak_ptr
* boost::enable_shared_from_this
* boost::static_pointer_cast
* boost::dynamic_pointer_cast

This excludes boost::intrusive_ptr, except for stray includes. Refactoring that is more complicated.
2016-07-25 09:28:42 +11:00
Celtic Minstrel
7286ea8e0f Merge pull request #661 from spixi/name_and_map_generator
Improvements in the name and map generators
2016-07-18 01:10:46 -04:00
Celtic Minstrel
7e04c7f8e9 Fix issues with constructing name generators from Lua 2016-07-12 11:08:34 -04:00
Celtic Minstrel
c39af95a44 Move name generator and formula API to base Lua kernel 2016-07-12 11:08:33 -04:00
gfgtdf
bbc32856f1 handle [args] also in [lua] tags outside events. 2016-07-09 21:42:10 +02:00
Charles Dang
0ca4e6c943 Convert uses of boost functional to standard library variants
This commit converts the following function calls:

* boost::bind                          -> std::bind
* boost::function and boost::functionN -> std::function
* boost::ref and boost::cref           -> std::ref and std::cref
* boost::bad_function_call             -> std::bad_function_call

In the process, it was discovered that std::bind has trouble with overloaded
functions. There were two such cases in the code:

* gui2::twindow had an ancient unused overload to draw(). The overload was removed.
* gui2::trepeating_button was binding tdispatcher::fire. This case was converted
  to a lambda.
2016-04-04 02:20:52 +11:00
Celtic Minstrel
86b4680371 Use vector/templating for Lua-like bulk registration functions 2016-03-31 02:13:38 -04:00
Celtic Minstrel
3ac7f8d970 NULL -> nullptr
A few cases of NULL were missed, since changing them led to errors
(Mainly instances where it was passed to a boost::function)
2016-03-31 00:42:38 -04:00
gfgtdf
9c59311b41 add function wesnoth.read_file
It can for example used to read map files.
2016-02-18 23:08:39 +01:00
Chris Beck
ba51524f6e update copyright to year 2016
using this shell script:

find src -type f -print0 | xargs -0 sed -i "s|Copyright (C) \([[:digit:]]*\)\([ ]*\)-\([ ]*\)2015|Copyright (C) \1\2-\32016|g"
2016-01-02 23:59:31 -05:00
Elvish_Hunter
9b7b1751fd Removed trailing tabs and whitespaces from C++ source
I used this command line: find <source directory> -name \*.\[ch\]pp -print0 | xargs -0 sed -i 's/[[:blank:]]*$//'
2015-12-21 20:39:46 +01:00
Celtic Minstrel
376020097f Port [object] ActionWML tag from C++ to Lua
Lua API additions:
- wesnoth.show_popup_dialog()
- optional write_to_mods parameter to wesnoth.add_modification
2015-09-19 12:13:25 -04:00
Celtic Minstrel
91ac90db11 Lua API: Add wesnoth.show_message_dialog() 2015-09-18 00:23:54 -04:00
Ignacio R. Morelle
b4de73f83b Add wesnoth.set_dialog_visible function
Sets a given widget's visibility property.
2015-08-22 23:07:03 -03:00