364 Commits

Author SHA1 Message Date
Celtic Minstrel
6200f60c79 Split some utility functions from wml-tags.lua into a new file 2015-09-19 12:13:21 -04: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
Charles Dang
1a606a51b1 Allow [modify_unit] to modify [advancement] 2015-09-03 01:24:14 +11:00
gfgtdf
0038448fcb make helper.shuffle synced
using helper.shuffle now doesn't casue OOS anymore used. It is possible
to get the old behaviour by passing math.random as a second parameter.
2015-08-04 22:36:54 +02:00
Elvish_Hunter
79d44d0486 Bugfixes in [role] tag
The following fixes were applied:
* cfg.__shallow_literal -> helper.shallow_literal, to allow calling the tag
  from Lua as wesnoth.wml_actions.role
* added trim() to the for cycle
* deleted filter.role and filter.type after having copied their data, because
  when calling the tag from Lua they ended up being deleted too early
* unit.role = cfg.role -> unit.role = role
2015-06-13 21:19:56 +02:00
Elvish_Hunter
787bd1b9c5 Moved [role] to Lua
This fixes indirectly bug #23630
2015-06-10 22:36:08 +02:00
Elvish_Hunter
88c0eb33e7 [label]: added SLF support when used inside an event 2015-05-24 21:34:54 +02:00
Charles Dang
f69d0e07e7 Simplified [switch] implementation 2015-05-24 13:00:10 +11:00
Charles Dang
435aafad3e Removed an unused var causing issues in [unit_worth] 2015-04-18 14:04:31 +11: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
gfgtdf
cd0029eac1 add accelerate in [delay]
If accelerate =yes (default no) then the delay time will be affected by
the acceleration set in the preferences.
See https://gna.org/bugs/?21335
2015-04-06 00:48:48 +02:00
Bär Halberkamp
ae0a2fe2cc Removed [full_heal] 2015-04-03 19:34:16 +02:00
Charles Dang
7533cc79ae Dropped support for [gold][filter_side] 2015-04-03 07:13:14 +11:00
gfgtdf
ed5650c758 add wesnoth.advance_unit lua function
previously this was only possible by storing the unit and then unstoring
with advance=yes. Unstoring a unit can cause a lot of overhead if the
unit is complicated. so i added a way to do it without [unstore_unit]
2015-03-28 21:37:26 +01:00
Charles Dang
d8b36e5d08 Add a newline between objective sections
This is set up that there will be no newlines at the end of any section, unless you have
only a summary key, which no one would do. However, there will be a newline at the top of
the dialog if you don't have a win objective, but no one would do that either.

Note that because of newlines not showing up properly on Windows, this won't be viable
on that platform.
2015-03-21 20:55:38 +11:00
Charles Dang
3a6579b9c2 Further simplify [if] implementation 2015-02-13 19:55:07 +11:00
Charles Dang
c1e95bcf14 Simplified [if] implementation 2015-02-13 05:49:58 +11:00
Charles Dang
9c9cbf2901 Fixup 84a7f3fb3135, use shallow_parsed 2015-02-03 11:06:59 +11:00
Charles Dang
84a7f3fb31 Parse [terrain] config. This fixes bug #23236 2015-02-03 11:03:37 +11:00
gfgtdf
78d6808e1a support wml arrays in [sync_variable] 2015-01-28 22:49:41 +01:00
gfgtdf
0f71f9bda8 add [sync_variable] tag 2015-01-28 21:10:11 +01:00
Charles Dang
b297831eeb Allow [disallow_recruit] to disable the whole recruit list of a side if passed without type= 2015-01-26 08:35:50 +11:00
Charles Dang
1a1deeae8d Change uses of wml_actions.animate_unit() to directly call wesnoth.animate_unit() 2015-01-12 22:07:13 +11:00
gfgtdf
579bad7437 fix [store_starting_location]
fixes up 9cde1af9c8
2015-01-09 18:04:23 +01:00
Charles Dang
b4614de149 Fixup ee868fc82b09. Forgot to remove an 'end' key
Also re-added the parens around the get_child call
2015-01-09 22:11:56 +11:00
Charles Dang
ee868fc82b Misc code cleanup 2015-01-09 21:53:36 +11:00
gfgtdf
9cde1af9c8 fix explicit indexes for [store_unit]
and for [store_locations] [store_starting_location] [store_unit_type]

see comment for 201d83f608 (fix [store_side] to allow explicit indexes)

As a side effect, this commit now also alows mode="replace"/"append"/default for
[store_locations] [store_starting_location] [store_side] [store_unit_type] which was
previously only possible for store_unit
2015-01-09 00:51:41 +01:00
Chris Beck
748f872091 lua: make it easier to disable strict mode global variables
After this commit, the "strict mode" lua variable errors may be
disabled with

  ilua.strict = false

and reenabled with

  ilua.strict = true

There will typically be no noticeable performance difference from
previously to this commit.

This is a bit simpler than the other methods described which
include using pcall or resetting the metatable of _G.
2015-01-05 14:58:09 -05:00
gfgtdf
486fc8ed71 fixup HEAD 2015-01-05 17:29:46 +01:00
gfgtdf
201d83f608 fix [store_side] to allow explicit indexes
[store_side] variable= some_variable[0] ... [/store_side] would result in a wesnoth.set_variable(some_variable[0][0]. ...)  call which we don't allow in master after https://github.com/wesnoth/wesnoth/pull/231. 1.12 would just ignore the second index in this case. I decided to rather fix [store_side] than to restore the 1.12 behaviour of set_variable (which wouldn't be harder).
2015-01-05 17:11:27 +01:00
Charles Dang
e1e5169c95 Get [time_area] id from the config instead of passing it as a lua arg
This fixes [time_area] id= inadvertently becoming required, when it should be optional
2015-01-04 23:25:49 +11:00
Charles Dang
778c840483 Misc cleanup 2014-12-30 16:52:50 +11:00
Charles Dang
3acb30e1ca Cast arg as string in trim() and split() 2014-12-30 16:05:41 +11:00
8573
e23ff7009c Lua: Fix uses of tostring calls as LHSs to or
This commit changes occurrences of the pattern `tostring(x) or y` to
`tostring(x or y)` in the following Lua scripts:

  - `data/lua/wml-tags.lua`
  - `data/lua/wml/items.lua`

`tostring(x) or y` is unlikely to do what the author intended (and is
pointless unless `x` is an object of a custom type with unusual
behavior), because `tostring` returns a string (`"false"` or `"nil"`)
if `x` is a falsy value (`false` or `nil`), and all strings are truthy
in Lua — thus, `tostring(x) or y` will (unless `x` is of a custom
type) *always* evaluate to `tostring(x)`, never to `y`.

`tostring(x or y)` should, I expect, give the intended behavior.
2014-12-29 10:09:48 +00:00
Charles Dang
f8c811fa4f Simplified syntax for wml_actions.chat() 2014-12-29 17:28:06 +11:00
Charles Dang
c762937e74 Simplified object:method syntax for trim() and split() 2014-12-29 15:47:44 +11:00
Charles Dang
fa079a1b3f Return first value of trim() within the function as opposed to at the call 2014-12-29 15:44:19 +11:00
Charles Dang
e35c301ff4 Fixed clear_variable by only calling first argument of of trim() 2014-12-29 15:31:05 +11:00
Chris Beck
497ed6f516 move wml [heal_unit] impl to lua 2014-12-28 17:39:39 -05:00
Charles Dang
95c94bc192 Allowed a comma separated id list for [remove_event] and [event] remove=yes 2014-12-28 20:31:45 +11:00
Charles Dang
ec985105ef Eliminate local var from trim() 2014-12-28 19:15:21 +11:00
Charles Dang
9b6f357a27 Put split-string-at-comma code into a function 2014-12-28 19:14:30 +11:00
Chris Beck
53b1309691 Merge branch 'lua' 2014-12-26 17:18:22 -05:00
Charles Dang
8a3572a62b Added [remove_event] (equivalent to [event] id= remove=yes) 2014-12-26 22:33:09 +11:00
Chris Beck
017050df70 ilua: eliminate the "_" holds last executed command feature
the ilua `_pretty_print` feature has the property that it sets _
to be what was printed, as an interpreter feature so that _
represents the results of the previous expression. However it
appears that this may conflict with some parts of our api, for
instance the _ is used to hold the return value of
wesnoth.textdomain in the lua implementation of [harm_unit].

Note that there is no actual bug that I have observed, I merely
anticipate that this _ feature won't be compatible with our
established gettext conventions.
2014-12-26 00:06:05 -05:00
Chris Beck
e73c57ead7 move wml [endlevel] impl to lua, and split into many lua funcs
the [endlevel] tag does alot of things that could quite comfortably
be split into several parts, like setting the next scenario, the
end level text, message duration, credits. this commit adds
separate lua api for each of these, leaving the rest in end_level,
and the lua tag implementation calls these variously.
2014-12-24 16:17:24 -05:00
Chris Beck
d7bf5be356 move wml [animate_unit] to lua 2014-12-24 15:15:25 -05:00
Chris Beck
171f92a6a5 move wml [open_help] impl to lua
also fixes an issue where the help topic was being cast
unnecessarily to a tstring
2014-12-24 14:42:58 -05:00
Chris Beck
75767d3a77 move WML [kill] impl to lua 2014-12-24 05:43:37 -05:00