Commit graph

717 commits

Author SHA1 Message Date
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
Chris Beck
9922b98fa3 move wml [inspect] impl to lua (and lua_gui2 namespace) 2014-12-24 05:00:44 -05:00
Chris Beck
ca58a71793 move WML [modify_side] implementation to lua 2014-12-24 04:44:25 -05:00
Chris Beck
0246026940 move WML [event] impl to lua, fixup core wml vs lua loading order
This commit moves [event] to be implemented in lua/wml-tags.lua.
It turns out that because of some questionable ordering in
data/core/_main.cfg, none of the tags defined in
data/lua/wml-tags.lua are actually defined at the time that core
is read, instead they are defined right after this. This is broken,
the entire wml library should be defined before core is read. Thus
we reorder some directives in data/core/_main.cfg to ensure this.

This commit adds lua callbacks `wesnoth.add_event_handler`,
`wesnoth.remove_event_handler` as well.
2014-12-24 04:21:58 -05:00
Chris Beck
0e365efc1a move WML [label] impl to lua 2014-12-24 03:16:49 -05:00
Chris Beck
29da15e1c0 move wml [end_turn] impl to lua 2014-12-24 03:07:49 -05:00
Chris Beck
177b4d5da1 move WML [color_adjust] impl to lua 2014-12-24 02:57:42 -05:00
Chris Beck
96c35f6560 move WML [redraw] impl to lua 2014-12-24 02:44:31 -05:00
Chris Beck
2cc38505dc move WML [scroll] implementation to lua 2014-12-24 01:06:44 -05:00
Chris Beck
defb9e5051 move replace_schedule impl to lua 2014-12-23 23:35:10 -05:00
Chris Beck
fa32be5602 add time_area registration impl to lua 2014-12-23 23:05:02 -05:00
Chris Beck
09ce8b5774 move clear_menu_item to lua implementation 2014-12-23 22:23:22 -05:00
Chris Beck
41e54fd009 move allow_undo, allow_end_turn impl's to lua 2014-12-23 22:08:45 -05:00
Chris Beck
0d76ac3be7 move the place, remove shroud WML tags to lua implementation 2014-12-23 21:04:45 -05:00
Chris Beck
eb71fc4d3b move "set_menu_item" to be implemented via lua rather than C++ 2014-12-23 19:34:17 -05:00
Chris Beck
1d7e45db23 lua [find_path]: always declare max_cost as a local
this is faster since it avoids repeated global lookup, and
suppresses lua_strict errors.
2014-12-20 21:10:25 -05:00
Chris Beck
3740b24b28 fixup ilua _pretty_print function
had some global vs local problems after making this a module loaded
with require rather than a dofile script
2014-11-23 18:33:50 -05:00
Chris Beck
d31253f585 bugfix: invalid variable reference
variable v does not exist... the function is not commented so I
can't be sure of the intention, but the most backwards-compatible
fix is to not pass argument v, so that it will be nil as before.

this bug was revealed by enabling lua "strict mode"
2014-11-22 16:43:27 -05:00
Chris Beck
a65d168317 enable "strict mode" in wesnoth lua
Enables an ilua feature called "strict mode" in all of our lua
environments. This change causes lua to report an error if a global
variable is used before it is assigned. The benefits of this are:
- Improved maintainability of lua-based add-ons, since you get
better error reporting in case of a typo.
- Improved behavior of the lua interpreter console, since mistyped
or gibberish lines resolve to an error rather than "nil", which
the console treats as a legal return value.

It is possible to disable this or work around it in individual
scripts. For more info see release notes.
2014-11-22 15:19:19 -05:00
Chris Beck
ba4276ea31 add "ilua" helper functions for lua interpreter 2014-11-21 22:22:43 -05:00
Bär Halberkamp
db028708c4 Added a lua implementation for FULL_HEAL and PUT_TO_RECALL_LIST 2014-10-21 19:41:36 +02:00
Chris Beck
b75f417982 fix a check in move_unit
The logic is supposed to be, if (x,y) == (prev_x, prev_y), then
skip the "find_vacant_hex" function because we don't have to move.
Instead we effectively had, if (x == prev_x OR y == prev_y), then
we can skip the check.

This revises a commit
72f138c544

in the hopes to fix a bug reported here:
http://forums.wesnoth.org/viewtopic.php?f=4&t=41084
2014-10-18 15:37:38 -04:00
Chris Beck
8308f7d3b9 fix whitespace at end of line 2014-09-05 16:52:03 -04:00
unknown
72f138c544 Fix bug #22306: move_unit moves a unit even when it shouldn't
Modified the lua script for wml_action.move_unit. In the
loop to check for vacant tile, if the current location
is equal to the previous location we don't look for a
vacant tile since our location is free (where we are).
2014-08-07 10:59:38 -04:00
Chris Beck
762efc278f add error reporting to [insert_tag] if it has no variable= field
The lack of reporting here is somewhat annoying so i patched it.
2014-06-21 18:13:42 -04:00
aquileia
1715ab3145 gitignore: Include more rules from subdirectories
That is: data/lua/, scons/, and utils/
2014-06-09 01:00:45 +02:00
Chris Beck
df71897d2f add error reporting when [if] is evaluated with no actions
I frequently make the mistake of using {IF_VAR} but forgetting to
use [then] with it. One solution is to use my own macro, but the
better solution is to add proper error reporting to if. If the
engine parses an [if] tag with no [then], [else], or [elseif], it
should flag an error... otherwise these mistakes are generally
silent and very difficult to find.
2014-06-05 19:49:57 -04:00
Elvish_Hunter
082992beed Removed sanity checks for missing variable=, [case] and value= in [switch] 2014-04-12 10:15:28 +02:00
Elvish_Hunter
c35e08dbfd Removed sanity check for missing [do] in [while] 2014-04-12 10:15:28 +02:00
Elvish_Hunter
729ebd58ff Restored support for [if] tags not containing [else] tags 2014-04-05 10:36:06 +02:00
Elvish_Hunter
df3063ed70 [switch]: implemented checks for missing [case], variable= and value=, Lua part 2014-04-03 12:33:20 +02:00
Elvish_Hunter
7e4beb8630 Get rid of obsolete if_while_handler function 2014-04-03 12:30:22 +02:00
Elvish_Hunter
cf55cf84e6 [while]: added sanity checks for missing [do] tags 2014-04-03 12:28:17 +02:00
Elvish_Hunter
2cff4662e2 Added [elseif] support, Lua part. Also included sanity checks for missing [then] tags inside [if] 2014-04-03 12:19:05 +02:00
Aishiko
a723d5fa59 Add single unit instance recall_costs
Add the variables, lua, and wml support variables to allow a scenario
designer the ability to define different from the standard recall costs
or team recall costs for both individual units and unit types.
from least to highest order of precendent we'll have default, team/side,
unit_type, and finally individual units.

The tag in the scenarios and in the unit config files is recall_cost=int.
2014-03-15 10:03:56 -04:00
Alexander van Gessel
62b287354f Fix Fisher-Yates implemenation of Lua helper.shuffle (bug #21706) 2014-03-04 11:57:19 +01:00
Chris Beck
9fb47d7f1f negate the output of location_set:empty, fixing logic error and
ensuring that a boolean value is returned
2014-02-16 19:36:09 -05:00
Ignacio R. Morelle
80d093b2b9 Add support for flag and flag_icon to [store_side] 2013-12-18 23:30:39 -03:00
Alexander van Gessel
255504870d Add side filters to [scroll_to] and [scroll_to_unit] 2013-11-25 20:23:54 +01:00
mattsc
5ee8e35568 Update animation when [un]petrifying units using WML tags
Previously, when a unit was petrified with [petrify] or [harm_unit], it
would continue its standing animation.  Also, it would not start its
standing animation when unpetrifying it with [unpetrify] or
[heal_unit].  Now the animation stops/starts correctly when the status
is changed.
This fixes bug #20124
2013-11-10 19:15:32 -08:00
anonymissimus
a7ce537ee6 .gitignore code.lua
It makes sense to add this in a .gitignore as the filename must be the same
in different checkouts.
2013-08-25 21:04:01 +02:00
Ignacio R. Morelle
74915e33bf Add scroll_to_leader field to the [store_side] WML action 2013-08-20 18:25:03 -04:00
Alexander van Gessel
38b224c1ff Revert "Revert "Merge branch 'master' of github.com:wesnoth/wesnoth-old""
This reverts commit 23b72d6956.
2013-08-09 00:13:46 +02:00
Thibault Févry
23b72d6956 Revert "Merge branch 'master' of github.com:wesnoth/wesnoth-old"
This reverts commit 5fa5c03411, reversing
changes made to 06374c64ba.
2013-08-08 18:50:46 +02:00
Elvish_Hunter
095b7b772f [allow_recruit], [disallow_recruit]: added a less cryptic error message if type= is missing 2013-07-23 22:29:04 +02:00
Ignacio R. Morelle
f6cc3acbaf Add [move_unit] force_scroll attribute
Defaults to using the [move_unit_fake] default.
2013-07-05 20:13:53 -04:00
Elvish_Hunter
f8996cbc14 [harm_unit]: removed two accidental plus signs that broke the tag 2013-06-14 23:36:23 +02:00
Elvish_Hunter
1861b9656a [harm_unit]: added animate keys to wml_actions.unstore_unit tables 2013-06-14 23:28:16 +02:00