lua: allow functions to be called without giving all of its args (#2744)

This makes usage of native functions that normally use pointer args easier to deal with.
This commit is contained in:
Quentin 2024-02-21 13:02:29 +01:00 committed by GitHub
parent 26686402c3
commit 80f28134a5
2 changed files with 21 additions and 2 deletions

View File

@ -61,8 +61,7 @@
#include "services/notifications/notification_service.hpp"
#include "services/translation_service/translation_service.hpp"
#define SOL_ALL_SAFETIES_ON 1
#include "lua/sol.hpp"
#include "lua/sol_include.hpp"
#include <script/types.hpp>

20
src/lua/sol_include.hpp Normal file
View File

@ -0,0 +1,20 @@
#pragma once
#define SOL_SAFE_USERTYPE 1
#define SOL_SAFE_REFERENCES 1
#define SOL_SAFE_FUNCTION 1
#define SOL_SAFE_NUMERICS 1
#define SOL_SAFE_GETTER 1
#define SOL_NO_CHECK_NUMBER_PRECISION 1
// This is intended to be disabled.
// Allow functions to be called without giving all of its args.
// Enabling it would make current usage of native functions like
// local r, g, b = VEHICLE.GET_VEHICLE_COLOR(spawnedVehicle)
// much more annoying due to how pointer args are handled,
// there is no way to know unless by hardcoding manually all of them that
// a pointer arg is an in or out parameter.
//
// #define SOL_SAFE_FUNCTION_CALLS
#include "lua/sol.hpp"