Commit graph

1093 commits

Author SHA1 Message Date
Celtic Minstrel
bf746a0207 Update mainline content to use the wesnoth.scenario module 2021-05-11 14:52:21 -04:00
Celtic Minstrel
1410b5cef9 Allow accessing variables through the new APIs in the mapgen kernel
This also reverses the deprecation of wml.tovconfig and friends in the mapgen kernel.
2021-05-11 14:52:20 -04:00
Celtic Minstrel
05b0b7a1df Update uses of wesnoth.fire 2021-05-11 14:52:20 -04:00
Celtic Minstrel
e8381ea9da Update uses of eval_conditional 2021-05-11 14:52:20 -04:00
Celtic Minstrel
2ea92baa13 Move some more functions to the wml module
- eval_conditional and fire
- the internal set|get_variable functions
2021-05-11 14:52:20 -04:00
Celtic Minstrel
603ecdfb99 Move the deprecation for wesnoth.modify_ai to Lua so that it honours --strict-lua 2021-05-11 14:52:19 -04:00
Celtic Minstrel
9bf189a615 Move wesnoth.create_side -> wesnoth.sides.create 2021-05-11 14:52:19 -04:00
Celtic Minstrel
1205e3fd25 Move the Lua global variable helpers from WC to a new "experimental" module 2021-05-11 14:52:19 -04:00
Celtic Minstrel
c88e60b98e Now color_adjust takes three arguments instead of a config
Consider it part of the public API now.
2021-05-11 14:52:19 -04:00
Celtic Minstrel
ea5367de17 Move create_animator and create_weapon into the units module 2021-05-11 14:52:18 -04:00
Celtic Minstrel
7b2ceb863c Move open_help to the gui module (as show_help)
This also exposes it in kernels besides the game kernel.
2021-05-11 14:52:18 -04:00
Celtic Minstrel
6e9826cfcd Update mainline content to use the wesnoth.audio module 2021-05-11 14:52:18 -04:00
Celtic Minstrel
dddd551765 Add an audio module 2021-05-11 14:52:17 -04:00
Celtic Minstrel
2a1fc43860 Add a versions userdata for a cleaner way to compare and manipulate game versions 2021-05-11 14:50:29 -04:00
Hejnewar
16c8fcc49c Remove remaining uses of wesnoth.special_locations 2021-05-10 11:26:12 +02:00
Hejnewar
e1a79988b4 Fix deprecation message 2021-05-10 11:23:54 +02:00
Celtic Minstrel
1dccc3ad76 Update mainline content to use the mathx module 2021-05-08 17:20:49 -04:00
Celtic Minstrel
1fc31c23d0 Replace all uses of get_time_stamp -> ms_since_init 2021-05-08 17:20:49 -04:00
Celtic Minstrel
7e1f3bc27f Rename get_time_stamp to ms_since_init
This better reflects what it actually does - it is not and has never been a timestamp.
2021-05-08 17:20:49 -04:00
Celtic Minstrel
a09f88c1c9 Start a Lua mathx module to hold round, shuffle, random, and a few other things 2021-05-08 17:20:47 -04:00
Celtic Minstrel
900c576fe8 Fix bug in wesnoth.map.read_location 2021-05-08 17:15:02 -04:00
sigurdfdragon
f67f28d7a9 Fix deprecation message 2021-05-03 11:26:40 -04:00
Steve Cotton
24e2f8f767 Whitespace fixes for no newline at end of file
The new CI script whitespace-checking script changes these, but not on Linux.
2021-05-03 11:52:40 +02:00
Pentarctagon
454130fd94
Fix trailing whitespace. 2021-04-25 21:58:20 -05:00
Celtic Minstrel
31421f3558
Add a Lua unit_test module only available in [test] scenarios (#5708)
It contains fire_wml_menu_item along with a set of new assert functions
2021-04-25 21:04:50 -04:00
Pentarctagon
d203b061f9
Whitespace cleanup of lua files. 2021-04-25 15:11:09 -05:00
Hejnewar
f5ea3b0906
Update code of [unstore_unit] 2021-04-22 01:32:06 +02:00
Steve Cotton
ad1c42ca8f Make [store_reachable_locations]range=vision calculate vision
Previously it calculated max movement, and then added the adjacent hexes. This
version should correctly handle:
* units with vp different to max mp
* units with vision costs different to movement costs
* jamming by enemy units

Draft changelog entry for this:
* `[store_reachable_locations]range=vision` now calculates vision, instead of using movement costs and max movement points (issue #4179)
2021-04-16 02:05:42 +02:00
Steve Cotton
147cd90527 Move lua implementation of [store_reachable_locations] to its own file 2021-04-16 02:05:42 +02:00
Celtic Minstrel
f737013203 Fix some issues with wesnoth.map.read_location and wesnoth.map.get 2021-03-28 10:55:03 -04:00
Celtic Minstrel
96fba6b833
Fix wesnoth.set_terrain without a mode 2021-03-19 21:02:56 -04:00
Celtic Minstrel
e0c1ac2626
Fix [unstore_unit]x,y=recall,recall
Fixes #5604
2021-03-12 19:46:35 -05:00
Celtic Minstrel
37fde7aaee
Allow hex references to hold auxiliary user values 2021-03-06 18:44:29 -05:00
mattsc
cadb233d6c Update some deprecated Lua uses 2021-03-06 15:08:54 -08:00
Celtic Minstrel
a2d7a26365
Fix several Lua issues, mostly unintentional globals (#5587) 2021-03-06 17:01:53 -05:00
mattsc
44e279cb2f Lua location_set: fix a variable name 2021-03-06 10:53:02 -08:00
Celtic Minstrel
c7b2dcca3f Oh look, a deprecated thing that was missed sometime in the past 2021-02-28 18:16:33 -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
Celtic Minstrel
6558c7981b Add a wesnoth.terrain_types table 2021-02-28 18:16:33 -05:00
Celtic Minstrel
cf71af4e11 Add a terrain hex reference API
This adds a metatable to all locations returned from wesnoth.map.find.
2021-02-28 18:16:32 -05:00
Celtic Minstrel
90e6db0330 Rename two functions for consistency of terminology 2021-02-28 18:16:31 -05:00
Celtic Minstrel
7e1414e249 Rename existing map functions in the map generation kernel 2021-02-28 18:16:31 -05:00
Celtic Minstrel
2d5ea6312e Move various functions into the map module 2021-02-28 18:16:31 -05:00
Celtic Minstrel
e6efc7de6c Refactor the game map to permit exposing it to Lua via wesnoth.current.map
The method of accessing terrain on the map has drastically changed.
- wesnoth.get_terrain and wesnoth.set_terrain are both deprecated
- wesnoth.terrain_mask still works but is moved into the wesnoth.map module and now takes the map object as the first parameter
- The map's terrain is now accessed exclusively via indexing on the map object, ie map[{x,y}]
- You set terrain by assigning a terrain code; the position of ^ in the terrain code now determines the merge mode
- The replace_if_failed option is now manifested as a function that converts any terrain code into a special value that, when assigned to a location on the map, uses the replace if failed logic.

The map object has a few attributes in it:
- width and height are the total size, including borders
- playable_width and playable_height are the values returned from wesnoth.get_map_size, which is now deprecated
- border_size is the third value from wesnoth.get_map_size
- data converts the map to a string
- Special locations are now part of the map object. The length operator is deprecated.
- other than that, wesnoth.map is treated as if it were the metatable of the map object
2021-02-28 18:16:30 -05:00
Celtic Minstrel
51cf2621f7 Add a utility function to extract a location from the front of a variadic parameter pack
The purpose of this is to make it easy for functions implemented in Lua to handle locations
in the same way as functions implemented in C++.

The location_set module has been updated to make use of this functionality in its setter functions.

Usage example:

Imagine a function foo with the following signature:

foo(bar : string, home : location, mode : string, target : location, moo : boolean) -> boolean

With the new read_location function it could be implemented as follows:

function foo(...)
	-- First argument goes in bar
	local bar = ...
	-- Read location starting at the second argument
	local home, n = wesnoth.mP.read_location(select(2, ...))
	-- note: n will be 0 if a location wasn't found at that position
	-- This could be an error, or it could be handled as an optional parameter
	-- Next argument after that goes in mode
	local mode = select(n + 2, ...)
	-- Then read a location into target
	local target, m = wesnoth.map.read_location(select(n + 2, ...))
	-- Finally, read a parameter into moo
	local moo = select(m + n + 2, ...)
	-- Do stuff with all these parameters
	return true
end

With that code, all the following invocations of foo work:

foo('a', 'b', true) -- both optional locations omitted
foo('a', 1, 2, 'q', 5, 6, false) -- locations given as separate integer parameters
foo('a', 'm', {1, 7},  true) -- first location omitted, second given as 2-element array
foo('a', some_unit, 'z', {x = 5, y = 10}, false) -- a unit also functions as a location
foo('a', 7, 12, 'q', my_leader, true) -- mixing different forms also works
2021-02-28 18:16:30 -05:00
Celtic Minstrel
dacd5b323e Add some utility functions to help clarify the merge mode being used when assigning terrains 2021-02-28 18:16:30 -05:00
Celtic Minstrel
f473aabe99 Add another note in [test_condition] for a simple case of using [have_location] to verify that a hex has a particular terrain 2021-02-27 21:24:01 -05:00
Celtic Minstrel
a97a04e2e9 Update [test_condition] to be a little more verbose and make use of newer features 2021-02-27 19:43:42 -05:00
Celtic Minstrel
1dca42ca0e
Fix [modify_side]reset_maps=true
I have no idea how this was missed...
2021-02-22 09:52:56 -05:00
Celtic Minstrel
862668911a Split core.lua up by module to make things easier to find
Core is now a directory instead of a file. The Lua kernel automatically loads all files in that directory when it starts up.
2021-02-20 21:32:29 -05:00