Commit graph

204 commits

Author SHA1 Message Date
gfgtdf
5438ec8a48 side specific variables.
http://gna.org/bugs/?23490

This makes it possible to store variables inside the side with the lua
functions get/set_side_variable. These variables are carried over along
other side specific data(units, gold)
2015-10-08 22:29:17 +02:00
gfgtdf
a77fada784 add access to tables via unit.variables
unit.variables now uses the same functionality as
wesnoth.get/set_variable (just for the unit variable instead of the game
variables) which makes it possible to access table values. Its also
posible to access subvariables as
unit.variables["list1[2].list2.length"]
2015-10-08 21:37:29 +02:00
gfgtdf
dd1b681d59 add support for overlays to lua units poxies 2015-10-07 18:44:36 +02:00
Celtic Minstrel
21e06ef482 Add accuracy/parry to Lua unit attacks table 2015-10-06 22:49:38 -04:00
Celtic Minstrel
af7ba3e527 Fix spelling 2015-10-06 22:13:57 -04:00
gfgtdf
83cc82185e add custom [effect]s with wesnoth.effects
Note that is not possible to use untore_unit/put unit inside those
effects becasue it will casue infinite recirsion.

Intead you can eigher use direct lua unit modification or use reuse
effects with wesnoth.add_modification(u, ..., , ..., false)

The main problem here was, that [effect]s are often applied in unit's
constructor where is was previously not possible to create a lua_unit
refering to that unit, to fix that i had to change lua_unit, luaW_checkunit
and luaW_getunit.
2015-10-06 00:15:04 +02:00
gfgtdf
11d6c3f199 fix assertion failue in wesnth.random 2015-10-06 00:14:59 +02:00
gfgtdf
eaa192ffa8 fix [lua] tags beeing lost on reload 2015-10-06 00:14:57 +02:00
gfgtdf
f74d89d166 more lua modifyable unit properties 2015-10-06 00:14:55 +02:00
Celtic Minstrel
e00b57cdcd Lua API: Change wesnoth.put_unit, add wesnoth.erase_unit 2015-09-23 22:22:03 -04:00
Celtic Minstrel
6a60f79d15 Lua API: Add wesnoth.unit_(vision|jamming)_cost 2015-09-23 22:21:55 -04:00
Celtic Minstrel
ffe8b4baa7 Lua API: Change wesnoth.get_unit, removing 1-argument underlying ID form
- Removes 1-argument form accepting an integer ID
- Adds 1-argument form accepting a string ID
- Now accepts locations either as 2 arguments or as {i,j} or {x=i,y=j}
2015-09-23 22:21:42 -04:00
Celtic Minstrel
2b5c887f6b Lua API: Let wesnoth.message accept translatable strings 2015-09-23 22:21:31 -04:00
Celtic Minstrel
a20c88c8a3 Simplify unit method names 2015-09-23 22:21:23 -04:00
Celtic Minstrel
0b42f43d2a Lua API: Add some existing wesnoth.* functions as proxy unit methods 2015-09-23 22:21:16 -04:00
gfgtdf
2c245afdc2 add description parameter to wesnoth.synchronize_choice(s)
and removed the 'tagname' parmaeter which is now always "input"
2015-09-21 00:13:56 +02:00
gfgtdf
61fabacd36 fix compiler warnings. 2015-09-20 22:32:22 +02:00
gfgtdf
3c11aa63f8 move get_user_choice function to a new file 2015-09-20 21:52:47 +02:00
gfgtdf
9c9f8f5a6e split wesnoth.synchronize_choice function
previously there was one function which sometimes returned a wml table
and sometimes a map integer to wml tables dependent on its parameters.

Now there are 2 different functions: wesnoth.synchronize_choice and
wesnoth.synchronize_choices. the first one handles the case where you just
want to get a choice from one side and thus it returns just one wml
table. The second function handles the case where you want to get
choices from multiple sides. that function retruns a table of wml
tables.

I also added an optional string parameter to that function specifying
the type of that choice (this is useful to make replays more robust and
readable)
2015-09-20 21:47:31 +02:00
Celtic Minstrel
e74c119b9b Merge pull request #488 from CelticMinstrel/backstab 2015-09-19 15:42:35 -04:00
Celtic Minstrel
4ca0aeb506 Expose the extra filter unit to the Lua API 2015-09-19 12:31:12 -04:00
Celtic Minstrel
907d527cc3 Lua API: Replace wesnoth.skipping_replay() with is_skipping_messages() and skip_messages() 2015-09-19 12:13:40 -04: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
d4835b0157 Port [message] ActionWML tag from C++ to Lua
Lua API additions:
- wesnoth.skipping_replay()
- wesnoth.deselect_hex()

Note: vultraz and aetheryn deserve partial credit for the Lua implementation
2015-09-19 12:13:23 -04:00
Ignacio R. Morelle
928b6e8008 Comment spelling fixes 2015-09-15 23:22:37 -03:00
gfgtdf
f01252a42c add [unsynced] actionwml
This can be used like in the following example (note that without the
[unsynced] it would cause OOS becasue rand= might or might not be
called.):

[unsynced]
[store_side]
variable = "side"
side = "$side_number"
[/store_side]
[if]
[variable]
name = "side.controller"
equals = "human"
[/variable]
[then]
[set_variable]
name = "num"
rand = _ "two,four,seven"
[/set_variable]
[message]
message = _ "I want $num stones"
[/message]
[/then]
[/if]
[unsynced]
2015-09-11 22:33:30 +02:00
gfgtdf
12e839b9b7 remove level_ member of game_lua_kernel
the intention is to be able to remove the level cfg.
2015-09-09 16:31:30 +02:00
Ignacio R. Morelle
df9908932d Merge branch 'amla' of https://github.com/CelticMinstrel/wesnoth into staging/pr-468 2015-08-23 21:40:31 -03:00
Nils Kneuper
c51c913156 converted some old C style casts to new c++ style casts
Those casts created warnings that broke building with cmake and gcc 4.9.3.
2015-08-23 11:05:06 +02:00
Celtic Minstrel
ad62e1d4fd Add deprecated warnings for [advance] 2015-08-22 23:43:50 -04:00
Celtic Minstrel
7a5ba33f5a Change [advance] modifications to [advancement]
This change maintains backwards compatibility
- [advance] will still work if present
- attempts to add [advance] via Lua will instead add [advancement].
2015-08-22 07:58:47 -04:00
Celtic Minstrel
af6d3060e2 Add new "category" and "creator" properties to map labels
- The "category" property is mainly for use by scenario designers; players will be able to hide labels based on this
- The "creator" property is meant to allow players to hide labels placed by specific other players
- Map editor allows setting the "category" property
2015-08-06 23:27:11 -04:00
gfgtdf
2cd2cf47c0 add wesnoth.random lua function
wesnoth.random has the same interface as math.random. So it can
substitute that function easily.
2015-08-04 22:36:52 +02:00
gfgtdf
49219ad0fd add team share_vision=all/shroud/none
previously there were 2 flags share_view=yes/no and share_maps=yes/no,
but only 3 possible settings (share both, share none, only share shroud)
(so share_maps= was ignored if share_viewv=yes). This made the wml code and
the c++ code needlessly complicated.

Now these 2 flags are replaced by share_vision=all/shroud/none
2015-07-23 14:00:08 +02:00
gfgtdf
1cbde8d0d3 simplify wesnoth.set_next_scenario and wesnoth.set_end_campaign_credits
luaL_checkstring never returns NULL so we can skip this check.
2015-07-21 17:32:34 +02:00
Elvish_Hunter
4360679c2a Upstream merged 2015-07-15 20:48:48 +02:00
gfgtdf
55662b9960 add parameter to wesnoth.allow_undo
now it can also disallow undoing.
https://gna.org/bugs/?23506
2015-07-14 18:21:38 +02:00
gfgtdf
31796c0b46 add wesnoth,.current.event_context.unit_x/y
http://gna.org/bugs/?23507
2015-07-14 15:32:29 +02:00
Ignacio R. Morelle
bcfdc85568 Use prefix instead of postfix increment/decrement
Found by cppcheck.
2015-07-06 22:31:24 -03:00
gfgtdf
fc220fee26 make units advancements modifyable in lua.
http://gna.org/bugs/?23677

units advancements is an array of wml tables.

This also adds template lua_push/lua_check functions wich also accept
vectors or similar. The file scripting/push_check.hpp was written using msvc
which implements look-up in template functions differently so it might be
necessary to fix it for other compilers by adding forward declarations of
those template functions.
2015-07-06 23:26:21 +02:00
Elvish_Hunter
d52c8c7f1d Lua: added support for unit.level field (read only) 2015-07-04 23:32:22 +02:00
gfgtdf
cee449106a add wesnoth.get_viewing_side
http://gna.org/bugs/?22822
2015-06-25 20:44:34 +02:00
gfgtdf
9e1aae1f79 inform the server about turn changes by wml
The server uses this to display the current turn in the lobby.
2015-06-10 14:26:08 +02:00
gfgtdf
da1c8bf60e rewrite MAKE_ENUM macro
Instead of creating an enum, the MAKE_ENUM macro now creates a struct
which holds an enum and provides functions for enum <-> string
conversion.

This has multiple advantages:
1) We don't need MAKE_ENUM_STREAM_OPS anymore.
2) The generated struct is much easier to use in templates
3) We don't allow implicit to int conversions anymore.
4) The enum values are now declared inside the structs scope.
2015-06-04 02:08:02 +02:00
gfgtdf
e2b85cf756 make zoc, variation, gender and race accessible for lua unit proxies 2015-04-17 03:30:48 +02:00
Chris Beck
f3a639fc62 move [print] to game_lua_kernel 2015-04-11 22:55:14 -04:00
Chris Beck
a5d3c64d10 move "modify_ai" to the game lua kernel 2015-04-11 22:09:40 -04:00
Chris Beck
f14341ce59 move last lua callbacks (place/remove shroud) to use extraspace 2015-04-10 17:01:49 -04:00
Chris Beck
0a4a385e50 move most of the remaining lua callbacks not to use boost bind 2015-04-10 15:38:48 -04:00
Chris Beck
97ce93af03 change many callbacks in game_lua_kernel to use lua extraspace 2015-04-10 15:23:22 -04:00