Commit Graph
101 Commits
Author SHA1 Message Date
Mike Nelson b49db4ef7b Add Lua global variables library (#6472)
* add global variables library

* nested namespaces
2025-01-06 17:36:59 +09:00
Mike Nelson 79d0c93ba5 Print in game options data to scripting output files (#6257) 2024-07-21 12:25:32 -04:00
BMagnu d87e997d79 Increase Lua safety (#6179)
* disable popen

* Check file type when opening with io lib

* Compile on Windows

* Windows include

* Properly conserve function environment

* Correctly copy fenv
2024-06-09 17:43:54 +02:00
Mike Nelson cf4cae7264 add dkjson as a default lua file (#5534) 2023-10-17 19:26:39 -04:00
Goober5000 3e0c7f0721 add lcase_equal and lcase_lessthan
The `SCP_string_lcase_equal_to()()` and `SCP_string_lcase_less_than()()` functors are rather unwieldy to use in non-functor situations, so this adds conventional function equivalents.
2023-05-20 18:21:37 -04:00
BMagnu 272d6261c4 Generic Lua Multiplayer RPC (#4835)
* Add automatic lua obj serialization function dispatch

* Implement fundamental and object de/serialization

* Proper default case for package deserialization

* Add No Multi func

* Add Serialization part

* Fix max encoding size for userdata

* Implement exception handling

* Start Implementing lua RPC

* Prepare waitAsync for RPC

* Add packet order enforcing and forwarding

* Add RPC registry

* Make RPCs callable

* Add waitRPC

* Add serializers

* Fix GCC error

* Explicitly specify lua_net_exception

* Fix Warnings

* Replace Seriliaze fundamental with cross-platform data types

* Appease Clang

* Prevent serialization CTD on invalid objects

* Actually use the temporaries assigned

* Fix OSWPT shadow

* Fix table deserialize order

* Incorporate Feedback

* Fix Warnigs

* ix WArnings 2

* Add sanity checks for OSWPT wing serialization

* Multi Bump

* Forgot we have american-style dates there
2023-03-28 03:07:03 +09:00
BMagnu f2f53b718d Actually assign enum value for constants (#4896) 2022-11-15 15:28:47 +09:00
wookieejedi 0c2a6a4f28 Fix multi lib (#4692)
Just adding 1 missing include
2022-09-21 22:08:38 +00:00
Goober5000 826dfd01fc clean up Lua frame handling a bit
There's no need to keep all this infrastructure to run every frame for a barely used situation.  This cleans it up a bit and does the position reset in the actual drawString function.
2022-07-08 18:59:10 -04:00
d38cc1f3db Controls6: Keyboard Localization and Scripted Contols (#4133)
Locale Sensitive Controls and Textfield Input
+ Add Keyboard Layout sensitive InputBoxes
+ Remove obsolete helper function

* Fig [] usage and remove old keybinding names
+ Fix Compile Warnings
+ Fix Compile Warnings 2
+ Fix Clang Warnings
+ Fix faulty style + remove lambda
+ Change reverse-lookup map to iterating function
+ Added controlconfigdefault.tbl generator
+ Fixed gcc warning
+ Fixed msvc warning
+ make debug console keyboard layout independent
+ Expand DCF Functionality for saving control presets
+ Address Issues

* Controls/update tbl (#5)

Updates controlconfigdefaults.tbl to write Primary and Secondary bindings.

* Added Scripting Hooks for controlsconfigdefault.tbl (#6)

* Handle Asserted Switch cases

* Controls is a library and should be in the libs folder

* Add Lock & EnableScripting Functionality and expose it to scripting API

* Added scripting isLocked

* Move Key Hooks to register-able callback

* Add option to remove hook

* Repurpose CCI.used for Axes

* Morph bitfield into a singleton class

* Add encoding conversion helpers
+ Add keyname conversion if needed
+ Merge refactored encoding functions
+ Change keycode encoding call
+ remove bad type modifier
+ Move Conversion functions to util/unicode
+ Change Encoding Enum to Enum Class
+ Adapt KeyName call for encoding enum class
+ Fix Warning due to enum class
+ Change validation to own function

* Make mActionToVal Assertion more helpful
* Fix typo
* Fix style
* Use constant, not magic number
* Document Ignored_keys[]
* Doxy class controls_lua_override_cache a bit better
* Put NameToVal safeties back in
* Reorder the +Disable and $Disable: options, and be exclusive
* Reorder the +Locked and $Loacked options, and be exclusive
* Revert changes in ValToJoy
* Revert errant duplicates
* Refactor printJoyJSON() to use getJsonArray for consistency
* Remove unused FS2toSDL map
* Remove ADE_FUNC(AxisActionInverted)

* Address gcc-5 issues
* Remove unused param for textify_scancode
* Declare textify_scancode_universal() in controlsconfig.h for use
* Clean up textify_scancode() and *_universal() a smidge for clarity

* Address most clang-9 issues

* Modernize NULL to nullptr

* Expand logic and document in controlsconfig::check_control() for clarity.
* Fix typo

* Remove unecassary static_cast
*  Use Assertion instead of Assert within control_config_common_read_section()
* mprintf()'s need new lines!

Co-authored-by: Birk Magnussen <[email protected]>
Co-authored-by: Birk Magnussen <[email protected]>
2022-06-05 10:19:46 -05:00
Goober5000 ee1330669a add Lua BitOp 1.0.2
Adds the standard Lua extension library for bit operations in Lua 5.1.
http://bitop.luajit.org/

Note that this library is normally called "bit", but it is added here as "luabit" because there is already a FSO scripting library called "bit".
2022-05-31 10:23:44 -04:00
Goober5000 f3bca4384f additional case functions and checks
This refactors the tolower/toupper code to use standards-conformant logic, and also adds some helpful utility functions.  Regular tolower/toupper must be supplied a value that can be represented as `unsigned char`, but the std:: functions are a bit more robust.
2021-02-18 04:23:08 -05:00
asarium bb0631ab6e Support vararg specifiers in Lua documentation
This was the last thing that was missing for complete support of all
function parameter declarations.

To ensure parameter lists stay valid a unit test was added that will
validate the argument lists and cause the test to fail if they cannot be
parsed.
2020-10-12 17:59:57 +02:00
asarium 2303785717 Improve scripting hook variable system
The previous system was kind of hacky and made things a bit inflexible.
This improves that system quite a bit and also adds unit tests for the
hook variable functionality.
2020-08-29 10:27:41 +02:00
asarium 4a6628e16f Unify and clean up Lua documentation generation
I added a pretty generic container structure for the scripting
documentation when adding JSON output. However, I did not use that new
structure for the HTML output since that was just too much work.

This moves the HTML output over to the new structure so now the
scripting API handling code is independent from how the resulting
documentation is generated. I also moved that code out of the main
scripting code which removes quite a lot of clutter in those files.

This is mostly a straight port of the old code with no significant
changes (except the changes to make it use the new data).
2020-06-13 16:46:26 +02:00
asarium ebcf686cf7 Add Lua API for promises and async coroutines
This adds a Lua API for representing asynchronous operations and running
coroutines based on those operations comfortably. This is very similar
to features other languages have introduced such as C# or JavaScript. In
fact, the whole "promise" thing is derived from how JavaScript
represents these operations.

This is the initial and very basic system for supporting async
coroutines in Lua. There is no native support for running these
operations at specific points (they run whenever the awaited promise
resolved) or making sure they do not leak through different game states.
2020-05-24 12:36:01 +02:00
asarium 544029f66f Add capability to have a pure lua script
This adds the capability to have a Lua script that does not need to use
our table syntax at all but instead defines the hooks by calling API
functions. This also makes it possible to add hook functions at runtime
if the script requires that.

Also clean up some unused debug stuff.
2020-05-03 14:33:42 +02:00
Allen A. Babb bb2f19c176 Merge pull request #2198 from FSCyborg/Mark-VM_EXTERNAL_CAMERA_LOCK-Deprecated
Add deprecation warning for VM_EXTERNAL_CAMERA_LOCKED
2019-12-15 18:53:16 -06:00
FSCyborg d16a3fa5cf Add deprecation warning for VM_EXTERNAL_CAMERA_LOCKED
Previously deprecated enum for hasViewmode() lua function didn't have a warning.  This fixes that.

Also, I am adding a check to ignore it while writing scripting.hmtl.
2019-12-15 15:03:00 -05:00
asarium b825f57bf4 Add scripting API support for model paths
This adds a scripting API for querying the paths of a model.
2019-12-14 09:15:44 +01:00
asarium 4ca589a61c Make Lua documentation generation more generic
This adds JSON as an additional scripting documentation output format.
This can be used by external tools to examine the scripting
documentation and generate interface declarations or documentation for
any language. The existing documentation code is left largely in place.
2019-12-01 12:53:51 +01:00
asarium ad1ede7b74 Add new options system
This is a system for storing arbitrary data in the config file and then
easily retrieving it later on. This has full Lua support for exposing
the available options in a custom UI and changing the values of the
options. This ported some of the existing command line options over to
the new system which is opt-in for the moment by using a mod_table flag.
2019-03-02 14:02:21 +01:00
asarium 5c07d181ad Test Windows compilation with Travis CI
Travis CI recently added support for running builds in Windows. This
adds support for testing compilation on Windows using that feature.

The newer version of Visual Studio and MinGW required some code changes
and an update of Google Test which is included in this commit.
2018-10-20 23:44:10 +02:00
asarium 7173299ca7 Add new libRocket UI system
This new system allows to create a user interface that goes beyond the
existing UI system.
2018-09-16 13:55:29 +02:00
m!m aede65107b Merge pull request #1805 from asarium/feature/scriptingParsingApi
Add scripting API for accessing parsing system
2018-07-22 22:15:48 +02:00
asarium 8c4ec9b91c Add scripting API for accessing parsing system
This allows scripts to use the same parsing functions which are also
used by the engine for parsing tables.
2018-07-22 11:47:33 +02:00
asarium ba5fcb971a Format changes with clang-format 2018-07-15 18:10:40 +02:00
asarium a34ca578ba Add a lua loader that uses the CFile system
This allows to use the built-in lua "require" function with our file
system. This will help organize complicated scripts and it will also
allow to use libraries which were designed for this system.

To enable this change, this includes a new mechanism which allows to
load scripts from the default file system so that the files don't need
to be included in every mod. The default files can be overridden by a
mod if a special mod-table option has been set, similar to how external
shaders are handled right now.
2018-07-15 18:10:40 +02:00
asarium 06a21a0f9b Add scripting API for displaying movie files
This adds an API for the scripting system which allows it to load and
display movie files using the standard movie player code which includes
multi-threaded frame decoding.
2018-07-13 21:54:41 +02:00
asarium f63e18957b Add scripting API for manipulating mission background
This adds a scripting API which can be used for adding and removing
background from a mission similarly to the existing SEXPs but with full
support for floating point numbers.

This was requested by Axem on Discord.
2018-06-30 23:22:07 +02:00
asarium 43e540cc4c Add true Unicode support
This adds proper Unicode support by allowing the parse system to read
UTF-8 encoded files. The new mode is controlled by a mod option which
allows older mods to continue using the legacy text encoding.

That option changes the behavior of several systems in FSO. It disallows
the usage of Volition fonts since they don't support Unicode encoding
and changes a few usages of special characters to their unicode
counterparts of generic rendering solutions.

This fixes #1415.
2017-11-30 13:26:20 +01:00
z64555 1b2eece53a Adds LUA versioning info to the scripting.html output
* Credits roll now grabs the LUA copyright info from liblua, instead of being hardcoded
* Credits roll now has LUA version info as well
2017-06-20 08:22:25 -05:00
asarium c17dcb1835 Move source files into category directories 2016-12-30 19:13:39 +01:00
asarium 6e5531adcc IT IS DONE! Moved testing library into separate file 2016-12-30 18:59:19 +01:00
asarium ad6ab9b95b Move tables scripting library into separate file 2016-12-30 18:52:34 +01:00
asarium ad6cbfb328 Move mission scripting library to separate file 2016-12-30 18:48:21 +01:00
asarium 9b8b7e0dce Move Hook variables library into separate folder 2016-12-30 18:33:02 +01:00
asarium 1cb5dbf99b Add include for the hud library 2016-12-30 18:24:59 +01:00
asarium 46116362c5 Move graphics scripting library into separate file 2016-12-30 12:57:03 +01:00
asarium 2c85c93136 Move hud scripting library into separate file 2016-12-30 12:33:32 +01:00
asarium 9251ec56ce Move controls scripting library to separate file 2016-12-30 12:33:32 +01:00
asarium deff6c9ec1 Remove now unused lua.h file 2016-12-30 12:33:32 +01:00
asarium 3fa4a8dbdc Move cfile scripting library into separate file 2016-12-30 12:33:32 +01:00
asarium bf2d996bd0 Move base scripting library to separate file 2016-12-30 12:33:32 +01:00
asarium 79709b2372 Move audio library into separate file 2016-12-30 12:33:32 +01:00
asarium 584b9cadd7 Move particle scripting class into separate file 2016-12-30 12:33:32 +01:00
asarium 2f1057f3c3 Move control_info scripting class into separate file 2016-12-30 12:33:32 +01:00
asarium 374bcacddd Move camera scripting class into separate file 2016-12-30 12:33:32 +01:00
asarium 94c7fbda6b Move player scripting class into separate file 2016-12-30 12:33:32 +01:00
asarium a049152e99 Move beam scripting class into separate file 2016-12-30 12:33:32 +01:00