Questions tagged [lua-api]
Anything related to Lua C Application Programming Interface (Lua C-API).
lua-api
205
questions
0
votes
1
answer
76
views
lua api call, on lua functions int the stack
following code is not running, i get 0 when i print(lua_getstack()). i do not want to change the code's reasoning, i need it as simple as it seems to do wht i need.
Any suggestion?
int main() {
...
0
votes
2
answers
204
views
Why is this program using negative ints specifically?
I'm reading over the C API Lua documentation, and I notice in this code:
lua_pushnil(L); /* First key */
while (lua_next(L, t) != 0) {
/* Uses 'key' (at index -2) and 'value' (at index -1) */
...
1
vote
2
answers
244
views
Lua debugger, hooks, yield and resume
Im attempting to make a simple debugger for my game engine to allow to to step line by line through a lua script loaded from disk. All done via the c api.
I can setup a hook to trigger every line, or ...
1
vote
2
answers
160
views
Does Lua automatically free userdata? [duplicate]
I have code where I create userdata (a circle) which gets passed to Lua that I also store as a pointer in C++ and put into a vector. After I call lua_close(L), I try to delete the pointer, but this ...
1
vote
1
answer
57
views
(Lua C API in C++) creating a destroy function for metatable object
I have a way to create a circle object and put the pointer into a vector before passing the pointer to Lua. I want to be able to call a destroy function that will remove the pointer from the vector ...
0
votes
0
answers
53
views
How to add an empty table to an existing table in Lua using its C-API?
The core detail of my problem is: I don't know how to do it.
I encountered the problem I'm trying to solve by wanting to add a table to an existing table in Lua.
The major difficulty that prevented me ...
-2
votes
1
answer
312
views
Lua switch like statement with case fallthroughs, accessible via C api
Trying to build a table that looks up effects depending on integer results.
Some of the results are in a range, like 1 to 5, but ultimately there's a bunch of em.
http://lua-users.org/wiki/...
3
votes
1
answer
67
views
LUA_HOOKRET not working when function is called inside return
I am trying to setup a small profiler and in consequence I need to record every time the program enters and leaves a function.
The problem is that it doesn't work when the function called is inside a '...
2
votes
1
answer
348
views
Calling Lua Function from C: Minimal example results in LUA_ERRRUN
I want to call an external lua_5.2 function from C, so I made a minimal example to try it out.
The minimal testfile:
--- filename: play.lua
function hello()
print("Hello World!\n")
end
...
1
vote
0
answers
100
views
Port lua (5.2-5.4) C++ connection to lua 5.1?
I'm working on the mGBA project (https://github.com/mgba-emu/mgba) and I'm trying to fix some problems regarding the scripting API and Lua 5.1.
The project has the following functions:
Load the Lua ...
0
votes
1
answer
308
views
Lua (g hub api) mouse not moving
I have a problem with Lua mouse script using G hub api. Everything works except for mouse-move functions, for example MoveMouseTo or MoveMouseRelative. Even MoveMouseWheel works fine. Here is my code. ...
0
votes
0
answers
149
views
Modsecurity Custom Lua Rule Not Capturing REQUEST_HEADERS
I'm using Modsecurity 3.0.9 with Nginx version: nginx/1.23.4
I created custom rule which executes Lua (Lua5.3) script as the following:
SecRuleScript "/path/to/lua/script.lua" "id:1,...
0
votes
1
answer
111
views
Unprotected error when calling nested Lua C library function with lua_pcall()
I'm writing a C++ library function that takes in two tables and takes the values from the tables and puts them into a vector.
To reduce clutter I've also made a helper function that will read the ...
0
votes
0
answers
77
views
Calling next multiple times in loop causes stack overflow in ue4 Lua machine
I've been working on lua machine json object system. But I've hit a snag with the json object merger(You can see the functions code used below). When I try to iterate through a table using a while ...
2
votes
1
answer
343
views
How do user values in Lua C API and lua_newuserdatauv function in particular work?
The documentation for lua_newuserdatauv(lua_State *L, size_t size, int nuvalue) says
This function creates and pushes on the stack a new full userdata, with nuvalue associated Lua values, called user ...