Commit graph

46 commits

Author SHA1 Message Date
Celtic Minstrel
c7741907c2 [LuaDoc] Fix several errors in the inline documentation 2024-02-06 19:04:00 -05:00
Tommy
3127178e17 Add a submerge value to items, to control submerge amount
It defaults to 0, which is no submersion.
2022-07-30 14:56:38 +12:00
Celtic Minstrel
e1300e29b0
Lua API: Add inline documentation for pretty much everything and convert existing docs (#6483)
The new format is EmmyLua-based and can be used with (at least) Visual Studio Code.
2022-02-17 13:43:31 -05:00
Celtic Minstrel
9d3bf196b0 Update everything to use the new wesnoth.map module
- get_terrain and set_terrain replaced with direct indexing operations
- get_map_size mostly replaced with either the iterator or an on_board call.
  Only a few cases really needed to know the size of the map for some other purpose.
- shroud and fog operations, village owner, time areas, and location filters
- get_terrain_info replaced with terrain_types table
- Map generation functions create_map and create_filter
2021-02-28 18:16:33 -05:00
gfgtdf
2a5ba5ace7 add wesnoth.interface.get_items
returns all items on a locations, this allows is to
remove quite a bit of code in the dropping.lua file
of world conquest since that can now just use items.lua
instead
2020-08-26 14:52:07 +02:00
Celtic Minstrel
c366998021 Fix an issue with items and location sets
Fixes #4621
2019-12-07 17:21:03 -05:00
Celtic Minstrel
732b7942bb Replace all references to deprecated functions in the helper module
(and remove the require if this meant it was no longer used)
2019-12-02 01:10:34 -05:00
Celtic Minstrel
74e004c265 Use a location set in the implementation of the item functions and WML tags 2019-12-01 22:30:31 -05:00
Celtic Minstrel
9da5d4adfd fixup! Declare wesnoth.interface.remove_overlay directly instead of declaring it local and then assigning it
Missed updating the deprecation line and used the wrong new name
2019-12-01 21:50:56 -05:00
Celtic Minstrel
57bb4224b0 Declare wesnoth.interface.remove_overlay directly instead of declaring it local and then assigning it 2019-12-01 20:25:47 -05:00
Celtic Minstrel
0ee05637d9 Lua: Replace uses of deprecated (moved) interface functions 2019-11-16 12:35:20 -05:00
gfgtdf
daf054752a support item_name= in [store_items]
we use it in SotA16 to make the scenario more robust against
[modification]s that might add [item]s for decoration.
2019-03-20 20:27:33 +01:00
gfgtdf
a32e49e32f
fix [item] z_order being lost after reload 2019-01-01 20:33:39 +01:00
Celtic Minstrel
2f9bca43af
Fix erroneous deprecation 2018-11-15 23:12:55 -05:00
Jyrki Vesterinen
68f3a8e846 Lua fixes 2018-11-16 05:47:28 +02:00
Celtic Minstrel
55a6c16810 Lua API reorganization: interface module deprecations 2018-11-15 21:06:55 -05:00
Celtic Minstrel
e3e80b4a99 Lua API reorganization: interface module 2018-11-15 21:06:55 -05:00
jostephd
e766cdc7cc WML: Support [filter_side] in [item]. (#3533)
* WML: Support [filter_side] in [item].

If [filter_side] is present then "team_name" is ignored.

Fixes #1477.

* WML: Compare [item]team_name to [side]team_name using intersection.

Fixes problems with substrings and when one or the other is a
comma-separated list. See #3533

* WML: Rename [item][filter_side] to [item][filter_team]

* Add changelog entry

(cherry-picked from commit 3a3b752881)
2018-10-07 03:25:20 +00:00
mattsc
0e017d9f7c Lua code: replace deprecated wesnoth.set_variable() calls
(cherry-picked from commit ce7faae4f4)
2018-10-07 03:21:07 +00:00
Celtic Minstrel
a314876bf2 Use new persistent tags interface for [object] [objectives] [item] 2018-03-17 17:16:23 -04:00
Charles Dang
0103959c36 Cleaned up deprecated API usage in core Lua
[ci skip]
2018-03-13 16:55:36 +11:00
vgaming
728204665c fix code problems found by luacheck (#2388)
fix code problems found by luacheck

Second iteration of the process, now handling data/lua/wml/*.lua

luacheck command used to find bugs:
  luacheck ./*.lua --globals wesnoth wml --codes --ignore 542 213
Additionally, error code 211 (unused variables) could be ignored,
as using underscore convention `_` is controversial in
wesnoth ( see https://github.com/wesnoth/wesnoth/pull/2380#discussion_r162519341 )

Actual bugs found:
* items.lua, access of global `write_name` instead of local `cfg.write_name`
* kill.lua, typo `primary_unit` -> `primary`
* bad code style: global `i` instead of local `i`
  (would conflict with 3-rd party code if it would use global `i`, too)
2018-01-23 13:35:04 -06:00
Celtic Minstrel
8d4cf3cf62 Shorten requires where possible 2017-05-03 02:42:25 -04:00
gfgtdf
5caa9dd95b cleanup wml_actions.store_items 2016-02-03 22:58:23 +01:00
gfgtdf
08236f8953 added name= attribute to [item]
name= has no effect but can be used to delete the item. I also changed
[item] to automatically create an id (in case no id was given) and
return that (only usable if called from lua).

I used the id= field from overlay class for this, it was previously only
used by the editor. Not sure if it is a good idea to reuse the id field.
2016-01-31 02:25:46 +01: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
Anonymissimus
6f7e76cbac introduce [item]redraw=yes|no (def yes) parameter
This allows WML/lua authors to optionally skip [item]'s implicit redraw
call. shadowmaster was experiencing some negative
visual effects due to this.
2012-04-09 19:48:51 +00:00
Steven Panek
b2bb325104 Removed support for the deprecated [removeitem]. 2012-02-07 00:16:29 +00:00
Alexander van Gessel
6eb9efd2fd Revert "Add a warning for empty [remove_item]"
This reverts commit 2012-02-05T16:05:43Z!ai0867@gmail.com.
2012-02-05 23:08:03 +01:00
Alexander van Gessel
86ef26478c Add a warning for empty [remove_item] 2012-02-05 17:05:43 +01:00
Anonymissimus
d3d0400ed0 revert part of 2011-09-08T19:16:01Z!thonsew@yahoo.com (resonless change to [item] behavior) 2011-09-27 23:01:26 +00:00
Anonymissimus
febb9da2ca Reverted 2011-09-21T21:44:58Z!thonsew@yahoo.com and 2011-09-20T21:21:21Z!thonsew@yahoo.com.
thonsew: The lua interface is not your playground. This is not the way
I want the lua files or its C++ interface to be modified. You are
invited to talk with me on IRC.

some of the main reasons:

-Your revisions contain lots of unneccessary changes, some of which
 break existing lua or wml without a reason. Do you ever look at the
 diffs?

-Your revisions pack a lot of unrelated stuff together into one.

2011-09-21T21:44:58Z!thonsew@yahoo.com makes sense in some parts and is what you should have
done in the first place.
2011-09-22 17:09:50 +00:00
Thonsew
e59dc97260 Added support for t_token to lua code.
1. Created a t_token metatable along with support code for indexing,
garbage collection, tostring, tonumber, comparison and concatenation.

2. Adjusted string comparison and lookup in lua code to work with
either t_token or string.

This addresses in part bug #18631, bug #18695.  Before this lua was
treating all t_token as either tstrings or strings.
2011-09-20 21:21:21 +00:00
Thonsew
2bf6377351 Changed config and vconfig to use a token representation...
...t_token in place of std::string.  t_token compares, copies, copy
constructs and hashes in 1 operation instead of proportional to the
length of the string.
2011-09-08 19:16:01 +00:00
Anonymissimus
e8f6531a86 Completely removed the old x,y=$x1,$y1 default in [remove_item],
since when running into this rare exception (if the SLF doesn't
matching anything) it could be hard to figure out what happens.

[remove_item] does nothing in this case now.
2011-09-01 19:06:56 +00:00
Anonymissimus
75bf37ed86 improved [store_items] to store only items on locs matching given SLF 2011-08-21 17:39:11 +00:00
Anonymissimus
fdb74894be added new wml tag store_items 2011-08-17 18:38:07 +00:00
Anonymissimus
e7688ed406 add SLF support to [event][remove_item] 2011-08-14 00:24:58 +00:00
Anonymissimus
38091cb48a add SLF support to [event][item] 2011-08-14 00:24:42 +00:00
Guillaume Melquiond
bec8a218da Preserved item orders at load and save time. (Fix for bug #16771.) 2010-12-24 10:00:20 +00:00
Guillaume Melquiond
33db0a937e Added a public interface for functions handling WML tile overlays. 2010-11-01 18:32:50 +00:00
Guillaume Melquiond
6e222f37cb Modified [removeitem] deprecation message so that it is no longer fatal. 2010-10-03 13:30:39 +00:00
Steven Panek
3a6eb75ee8 Renamed [removeitem] to [remove_item]; deprecated [removeitem]. 2010-10-01 23:42:21 +00:00
Guillaume Melquiond
bb47837b3b Fixed tag naming. 2010-08-28 18:59:21 +00:00
Guillaume Melquiond
cb92c6d196 Moved handling of toplevel [item] tags to Lua. 2010-08-28 18:56:15 +00:00
Guillaume Melquiond
05902d29eb Moved item-related tags to their own file. 2010-08-28 18:56:12 +00:00